centos7 安装 PHP7

yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

yum --disablerepo="*" --enablerepo="remi-safe" list php[7-9][0-9].x86_64

yum-config-manager --enable remi-php74

yum install php php-mysqlnd php-fpm


vi  /etc/php-fpm.d/www.conf
…
; RPM: apache user chosen to provide access to the same directories as httpd
user = nginx
; RPM: Keep a group allowed to write in log dir.
group = nginx
…


listen = /var/run/php-fpm/php-fpm.sock;


listen.owner = nginx
listen.group = nginx
listen.mode = 0660
systemctl start php-fpm
systemctl enable php-fpm
vi /etc/nginx/conf.d/default.conf
server {
    listen       80;
    server_name  server_domain_or_IP;

    root   /usr/share/nginx/html;
    index index.php index.html index.htm;

    location / {
        try_files $uri $uri/ =404;
    }
    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;

    location = /50x.html {
        root /usr/share/nginx/html;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

参考:https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-centos-7

发表评论

电子邮件地址不会被公开。 必填项已用*标注

Scroll to Top