ubuntu裏安裝php,並配置nginx請求php-fpm

安裝php

apt-get install php

 

 

 

 

安裝完成後需要把php的配置加入到nginx.conf裏

首先我們需要把php-fpm的監聽端口查出來寫到nginx.conf裏:

打開php-fpm.conf配置文件查看listen

 

打開nginx.conf配置文件:

需要把nginx的用戶改爲 user:www-data

我的這個是;/run/php/php7.0-fpm.sock      ;應該寫:

        location ~ \.php$ {

                fastcgi_pass unix:/run/php/php7.0-fpm.sock;

                fastcgi_index index.php;

                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

                include fastcgi_params;

        }

有的端口號爲:127.0.0.1:9000:

  location ~ \.php$ {

                fastcgi_pass 127.0.0.1:9000;

                fastcgi_index index.php;

                fastcgi_param APPLICATION_ENV production;

                include fastcgi_params;

        }

修改完成後:重啓nginx和php-fpm重新查看網址就OK

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章