PHP经验分享

Centos7 PHP7 + Nginx

2016-12-09  本文已影响64人  茶艺瑶

之前那篇Centos Mysql + PHP + Nginx 最最终版,有人请教不会安装PHP7。那现在就来安装PHP7吧

先更新系统

yum -y update

安装nginx
创建文件

vim /etc/yum.repos.d/nginx.repo

文件内容,这配置是安装最新的稳定版1.8

[nginx]
name=nginx 
repobaseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1

然后

yum -y install nginx

检查是否安装成功

nginx -t
systemctl start nginx
systemctl enable nginx

访问你的ip

安装Mysql5.7
下载mysql的repo源

wget http://repo.mysql.com//mysql57-community-release-el7-7.noarch.rpm

安装mysql-community-release-el7-7.noarch.rpm包

sudo rpm -Uvh mysql57-community-release-el7-7.noarch.rpm

安装msyql

sudo yum install mysql-server

重启mysql

service mysqld restart

查看临时密码

sudo grep 'temporary password' /var/log/mysqld.log

修改密码

ALTER USER 'root'@'localhost' IDENTIFIED BY 'YourNewPass4!';

安装php7
webtatic方式

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
yum install php70w php70w-opcache php70w-fpm

nginx配置
因为我们这次没有配置在 php.ini 上修改过什么东西。所以php的代理为127.0.0.1:9000;
root 是网站地址

server{
    listen 80;
    listen [::]:80 default_server;  
    server_name _; 
    root /usr/share/nginx/html; 
    index index.php index.html index.htm; 

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }


    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

}

如果显示空白可能是

chmod -R 777 storage
上一篇下一篇

猜你喜欢

热点阅读