Centos7安装nginx+php-fpm

安装nginx

yum install yum-priorities -y   //源优先级

wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm

yum install nginx

安装php-fpm

yum install php56w-fpm

systemctl start php-fpm.service #启动php-fpm

systemctl enable php-fpm.service #设置开机启动

 

修改nginx配置文件

vi /etc/nginx/conf.d/default.conf,将文件原内容删除,将下面内容粘贴进去

 

server{

    listen      80;

    server_name localhost;

    index index.php index.html index.htm;

    root  /usr/share/nginx/html/juce-project/code; #项目路径

 

        location / {

#               root   /var/wwwjuce-project/code;

#               index  index.php index.html index.htm;  

                try_files $uri $uri/ /index.php?$query_string;

        }

        location ~ \.php {

#               root           /var/www;

                fastcgi_pass   127.0.0.1:9000;

                fastcgi_index  index.php;

                fastcgi_split_path_info ^(.+\.php)(.*)$;

                fastcgi_param PATH_INFO $fastcgi_path_info;

#               fastcgi_param  SCRIPT_FILENAME  /var/www/juce-project/code$fastcgi_script_name;

                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

                include        fastcgi_params;

        }

}

你可能感兴趣的:(Centos7安装nginx+php-fpm)