CentOS 搭建 LAMP服务器
CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙。 1、关闭firewall: systemctl stop firewalld.service #停止firewall systemctl disable firewalld.service #禁止firewall开机启动 2、安装iptables防火墙 yum install iptables-services #安装 vi /etc/sysconfig/iptables #编辑防火墙配置文件 # Firewall configuration written by system-config-firewall # Manual customization of this file is not recommended. *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT :wq! #保存退出 systemctl restart iptables.service #最后重启防火墙使配置生效 systemctl enable iptables.service #设置防火墙开机启动 二、关闭SELINUX vi /etc/selinux/config #SELINUX=enforcing #注释掉 #SELINUXTYPE=targeted #注释掉 SELINUX=disabled #增加 :wq! #保存退出 setenforce 0 #使配置立即生效 |
一、安装Apache
yum install httpd #根据提示,输入Y安装即可成功安装
systemctl start httpd.service #启动apache
systemctl stop httpd.service #停止apache
systemctl restart httpd.service #重启apache
systemctl enable httpd.service #设置apache开机启动
二、安装MariaDB
yum install mariadb mariadb-server #询问是否要安装,输入Y即可自动安装,直到安装完成
systemctl start mariadb.service #启动MariaDB
systemctl stop mariadb.service #停止MariaDB
systemctl restart mariadb.service #重启MariaDB
systemctl enable mariadb.service #设置开机启动
cp /usr/share/mysql/my-huge.cnf /etc/my.cnf #拷贝配置文件(注意:如果/etc目录下面默认有一个my.cnf,直接覆盖即可)
2、为root账户设置密码
mysql_secure_installation
回车,根据提示输入Y
输入2次密码,回车
根据提示一路输入Y
最后出现:Thanks for using MySQL!
MySql密码设置完成,重新启动 MySQL:
systemctl restart mariadb.service #重启MariaDB
三、安装PHP
安装PHP组件,使PHP支持 MariaDB
yum install php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash
#这里选择以上安装包进行安装,根据提示输入Y回车
systemctl restart mariadb.service #重启MariaDB
systemctl restart httpd.service #重启apache
配置篇
一、Apache配置
vi /etc/httpd/conf/httpd.conf #编辑文件
ServerSignature On #添加,在错误页中显示Apache的版本,Off为不显示
Options Indexes FollowSymLinks #修改为:Options Includes ExecCGI FollowSymLinks(允许服务器执行CGI及SSI,禁止列出目录)
#AddHandler cgi-script .cgi #修改为:AddHandler cgi-script .cgi .pl (允许扩展名为.pl的CGI脚本运行)
AllowOverride None #修改为:AllowOverride All (允许.htaccess)
AddDefaultCharset UTF-8 #修改为:AddDefaultCharset GB2312 (添加GB2312为默认编码)
#Options Indexes FollowSymLinks #修改为 Options FollowSymLinks(不在浏览器上显示树状目录结构)
DirectoryIndex index.html #修改为:DirectoryIndex index.html index.htm Default.html Default.htm index.php(设置默认首页文件,增加index.php)
MaxKeepAliveRequests 500 #添加MaxKeepAliveRequests 500 (增加同时连接数)
:wq! #保存退出
systemctl restart httpd.service #重启apache
rm -f /etc/httpd/conf.d/welcome.conf /var/www/error/noindex.html #删除默认测试页
二、php配置
vi /etc/php.ini #编辑
date.timezone = PRC #把前面的分号去掉,改为date.timezone = PRC
disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname
#列出PHP可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用。
expose_php = Off #禁止显示php版本的信息
short_open_tag = ON #支持php短标签
open_basedir = .:/tmp/ #设置表示允许访问当前目录(即PHP脚本文件所在之目录)和/tmp/目录,可以防止php木马跨站,如果改了之后安装程序有问题(例如:织梦内容管 理系统),可以注销此行,或者直接写上程序的目录/data/www.osyunwei.com/:/tmp/
:wq! #保存退出
systemctl restart mariadb.service #重启MariaDB
systemctl restart httpd.service #重启apache
测试篇
cd /var/www/html
vi index.php #输入下面内容
<?php
phpinfo();
?>
:wq! #保存退出
注意:apache默认的程序目录是/var/www/html
权限设置:chown apache.apache -R /var/www/html
参考
转载于:https://www.cnblogs.com/amliaw4/p/5619909.html
CentOS 搭建 LAMP服务器相关推荐
- centos php管理面板,Centos 搭建LAMP平台 + Web控制面板管理
Centos 搭建LAMP平台 + Web控制面板管理 LAMP组合就是在Linux操作系统上配置Apache服务器.MySQL服务器,PHP应用程序服务器,组成强大的Web动态网站开发平台. Apa ...
- [记录]CentOS搭建SVN服务器(主从同步)
CentOS搭建SVN服务器(主从同步) 1.安装步骤如下: 1)安装: #yum install subversion 2)查看安装位置: #rpm -ql subversion 3)查看版本: # ...
- ngrok linux开机自启动,CentOS 搭建ngrok服务器
原标题:CentOS 搭建ngrok服务器 1一.前提条件 1. 准备好一台主机,带公网IP 2. 准备一个一级域名,做好泛解析(二级域名的没有配置成功,汗...) 切记 一定要做好域名泛解析 二.安 ...
- CentOS搭建Terraria服务器
CentOS搭建Terraria服务器 最近和好兄弟一起玩泰拉瑞亚,steam的服务器太卡了,总结了一些教程,自己搭建一个,记录一下过程,起飞. 准备工作 1.在系统中安装必要的软件 yum inst ...
- centos php服务器搭建教程,CentOS搭建PHP服务器环境简明教程
本文实例讲述了CentOS搭建PHP服务器环境的方法.分享给大家供大家参考,具体如下: 1. 先安装apache: yum install httpd 配置ServerName vi /etc/htt ...
- CentOS搭建CA服务器,都是科技狠活,快来看我
CentOS搭建CA服务器 CA服务器实现 安装opensll 创建CA自签证书 实验结果 总结测试 CA服务器实现 安装opensll 一般都是已经安装好的了,没有安装的可以自行使用yum安装,怎么 ...
- Centos搭建speedtest服务器教程
Centos搭建speedtest服务器教程 (无数据库版本) 安装apache服务器. 先检查是否已经安装 rpm -qa httpd 若已经安装会显示安装版本 若未安装则无显示 2.安装httpd ...
- linux centos 搭建wordpress 服务器 网站建设lamp php apache
linux 搭建wordpress 服务器 网站建设 linux 说是很难学,其实深度倒是没有,随便敲敲完成个东西原来可以很快的ok,当然离好还很远.不过有那么点样子是可以的,去他的也大同小异. 一门 ...
- csgo服务器怎么显示cmd,CentOS 搭建CSGO服务器
最近有一些空闲的服务器要搭建 CSGO 服务器,综合一位前辈的文章,进行了一些总结和优化 由于我不会用 Windows 或者其他 Linux 系系统,因此这只写如何在 CentOS 7 64bit 上 ...
最新文章
- mysql 联接结果集函数_Oracle 中函数如何返回结果集
- UVA1396 Most Distant Point from the Sea(AM - ICPC - Tokyo - 2007)(计算几何,半平面交 + 二分答案)
- 服务器登陆密码到期登不上去_英雄联盟手游注册系统炸服怎么回事?服务器瘫痪登不上解决方法[多图]...
- 稀疏自编码器符号一览表
- 传统的http请求存在那些缺点
- go语言中及格比较特殊的switch语法
- 使用自定义 HTTP Interceptor 记录 SAP Spartacus 发送的 OCC API 以及响应
- TFBOYS饭票上线引热议,骗局之外,区块链技术能重构娱乐产业吗?
- centos php安装redis扩展,Centos7编译安装redis、php安装phpredis扩展
- codeforces 486A-C语言解题报告
- java下载网络文件_java下载网络文件的方法有哪些
- MySQL vs. MongoDB: Choosing a Data Management Solution
- Eclipse语言包的安装与卸载
- Java 十大常用框架
- 迁移学习 Transfer Learning(可能是目前最全的迁移学习资料库?)
- 电动滑板车安全标准EN17128和电动自行车EN15194电磁兼容测试欧盟轻型电动车
- 【全基因组关联分析GWAS专题1】——群体结构
- 【经历史】风口上的雷军,小米是他最后一次创业~~传奇人生
- 浙江大学pta答案python第四章_浙大PTA-Python题库 编程题第一章(1-1~1-3)题解
- PWM和SPWM的区别
热门文章
- OpenGL Shader基本概念
- js中字符串编码函数escape()、encodeURI()、encodeURIComponent()区别详解
- [pytorch、学习] - 5.1 二维卷积层
- javascript --- 从数组中,找出比给定元素大一丁点的元素
- Halcon算子翻译——default
- Maven中使用本地JAR包
- spring-在配置文件中配置DAO时直接引用DataSource
- 15个实用的grep示例
- linux下rpm方式安装mysql(2012-5-12)
- malloc/free与new/delete的区别