一、环境
centos 7.4.1708
mysql 5.7
nginx 1.14
php 7.0
二、准备
1.关闭防火墙
systemctl stop firewalld
2.关闭selinux
vi /etc/selinux/config
setenforce 0 && getenforce 0
三、安装服务
1.安装mysql
1)下载mysql repo源
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
2)安装mysql-community-release-el7-5.noarch.rpm包
rpm -ivh mysql-community-release-el7-5.noarch.rpm
3)刷新yum源 安装mysql-server
yum repolist
yum install -y mysql-server
4)启动
systemctl start mysql
5)登录修改密码
mysql -u root -p
mysql> set password=password('123456');
或者:
mysql > update mysql.user set authentication_string='123456' where user='root';
2.安装nginx
1)下载nginx包
wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
2)安装nginx-release-centos-7-0.el7.ngx.noarch.rpm
rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm
3)安装nginx
yum install -y nginx
4)启动nginx
systemctl start nginx
5)测试访问
curl 127.0.0.1
3.安装php
1)安装 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
3)安装php扩展
yum install -y php70w-mysql.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64
4)安装php-fpm
yum install -y php70w-fpm
5)启动fpm
php-fpm
四、配置
1. 修改nginx配置文件加载php代码
vi /etc/nginx/conf.d/default.conf
2)修改/etc/php-fpm.d/www.conf
vi /etc/php-fpm.d/www.conf
3)重新启动php-fpm
killall php-fpm
php-fpm
4)重新加载nginx
nginx -s reload
5)测试php代码
vi /usr/share/nginx/html/index.php
浏览器访问http://192.168.1.71/index.php