1. 关闭防火墙和selinux
打开文件selinux
vim /etc/sysconfig/selinux
- 1
将文件中SELINUX=enforcing改为disabled,然后执行”setenforce 0″不用重启地关闭selinux。
SELINUX=disabled
- 关闭放火墙
systemctl stop firewalld.service
- 1
2.安装软件
2.1.MysqL安装
下载MysqL的repo源
wget http://repo.MysqL.com/MysqL-community-release-el7-5.noarch.rpm
- 安装MysqL-community-release-el7-5.noarch.rpm包
rpm -ivh MysqL-community-release-el7-5.noarch.rpm
- 安装MysqL
sudo yum install -y MysqL-server
- 更改MysqL用户权限:
sudo chown -R root:root /var/lib/MysqL
- 重启服务:
systemctl restart MysqL.service
- 登录,并修改密码:
MysqL -u root MysqL > use MysqL; MysqL > update user set password=password(‘123456‘) where user=‘root‘; MysqL > flush privilgegs; MysqL > exit;
- 1
- 2
- 3
- 4
- 5
2.2Nginx安装
下载对应当前系统版本的Nginx包
wget http://Nginx.org/packages/centos/7/noarch/RPMS/Nginx-release-centos-7-0.el7.ngx.noarch.rpm
- 建立Nginx的yum仓库(默认yum是没有Nginx的)
rpm -ivh Nginx-release-centos-7-0.el7.ngx.noarch.rpm
- 下载并安装Nginx
yum install -y Nginx
- Nginx启动
systemctl start Nginx.service
- 1
2.3安装PHP
rpm 安装 PHP7 相应的 yum源
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
- 2
安装PHP7.0
yum install -y PHP70w
- 安装PHP扩展
yum install -y PHP70w-MysqL.x86_64 PHP70w-gd.x86_64 PHP70w-ldap.x86_64 PHP70w-mbstring.x86_64 PHP70w-mcrypt.x86_64
- 安装PHP FPM
yum install -y PHP70w-fpm
- 3. 修改配置文件
3.1修改Nginx配置文件
Nginx配置文件位置:(/etc/Nginx/conf.d/default.conf)
vim /etc/Nginx/conf.d/default.conf
- 修改 root目录,可自定义:
root /forest/NginxDir/html;
- 配置PHP解析,修改 下面代码中黑色加粗部分:
location ~.PHP$ { root /forest/NginxDir/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.PHP; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
- 5
- 6
- 7
3.2 修改PHP-fpm配置文件
PHP-fpm配置文件位置:(/etc/PHP-fpm.d/www.conf)
修改user =Nginx group=Nginx
- 2
4.放入测试文件
cd /forest/NginxDir/html echo 'hello eric' >index.PHP
- 配置PHP解析,修改 下面代码中黑色加粗部分:
- 修改 root目录,可自定义:
- 3. 修改配置文件
- 安装PHP FPM
- Nginx启动
- 下载并安装Nginx
- 登录,并修改密码:
- 重启服务:
- 更改MysqL用户权限:
- 安装MysqL