首页 > 技术文章 > Archlinux安装php-fpm + nginx

mc-r 2019-09-26 09:42 原文

1. 安装php、php-fpm、nginx.

# pacman -S nginx php php-fpm

2. 编辑配置文件

php.ini与php-fpm.conf基本配置就可以用。如php.ini需开启模块。如mysql.so,去掉前面;。

# vim /etc/php/php.ini

*******************************************************
;extension = gmp
extension = mysql.so

nginx配置

# vim /etc/nginx/nginx.conf
****************************************************************
user http;                         //设置访问用户
worker_processes  1;

events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    server {
        listen       80;
        server_name  localhost;
        root   /srv/http/wordpress;  //设置根目录

        location / {
            #root   /usr/share/nginx/html;
            index  index.html index.php index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/share/nginx/html;
        }

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

    }

}

3. 开启nginx与php

# systemctl start nginx
# systemctl start php-fpm

 

推荐阅读