我们已经装好了nginx,现在我们开始装mysql和php
我们同样使用yum来安装。
先安装MySQL软件(客户端、服务器端、依赖库)
yum install -y mysql mysql-server mysql-devel
然后设置自启动,报错

正确的安装方法以及错误原因参考这里
好了,到这里我们就安装好mysql了,下面我们开始安装php。
详细安装参考我的另一篇文章:Centos 6/ 7下通过yum安装php7环境
也可以参考另外一篇文章:yum安装新版php7.0 后来更新了,也可以安装7.2了
总结一下,首先是更新yum源,根据自己的CentOS版本来选择
CentOS/RHEL 7.x:
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
如果是centos6,那么执行以下代码:
CentOS/RHEL 6.x:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
然后就可以yum安装PHP了
yum install php70w-common
要安装其他拓展的话上面文章里有,这里我已经安装好了laravel5.5所需的拓展了
//使用命令查看拓展 php -m



然后,我们配置一下nginx
vim /etc/nginx/nginx.conf
#这一段是最原始的配置,我们注释掉 # server { # listen 80 default_server; # listen [::]:80 default_server; # server_name _; # root /usr/share/nginx/html; # # # Load configuration files for the default server block. # include /etc/nginx/default.d/*.conf; # # location / { # } # # error_page 404 /404.html; # location = /40x.html { # } # # error_page 500 502 503 504 /50x.html; # location = /50x.html { # } # } #写入我们新的配置
server {
listen 80;# 监听端口
server_name localhost;# 站点域名
#charset koi8-r;
#access_log logs/host.access.log main;
root /home/wwwroot/blog/public/;# 站点根目录
location / {
index index.html index.htm index.php l.php;# 默认导航页
autoindex off;
try_files $uri $uri/ /index.php?$query_string;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ .php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ .php(.*)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /.ht {
# deny all;
#}
}
然后重启nginx
service nginx restart
访问一下,可以了!(这里我提前在站点目录里写了一个php文件,没有写的可以写一个)

好的,至此环境就搭好了,下一篇我们准备安装larvael了,不太会写,有什么不对的地方还请大家留言指出,共同学习!