centos6下nginx配置php可用

來源:互聯網
上載者:User

標籤:查看   script   logs   ble   oca   rem   安裝   pid   重啟   

先查看下所有服務的狀態,看看php-fpm有沒有正在運行

[[email protected] html]# service --status-all

php-fpm (pid  3568) 正在運行...

如果php-fpm已停,就開啟此服務:service php-fpm start

如果php-fpm已死或沒有,就先卸載當前的php和httpd,然後再重新安裝php

# yum remove httpd* php* 

重新安裝php

預設情況下,CentOS的官方資源是沒有php-fpm的, 但我們可以從Remi的RPM資源中獲得,它依賴於EPEL資源。我們可以這樣增加兩個資產庫:

# yum install yum-priorities -y  

# rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-7.noarch.rpm  

# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm  

安裝php

[[email protected] html]# yum --enablerepo=remi install php php-fpm  

安裝完成之後再看看服務狀態應該就有了,service --status-all,啟動php-fpm服務

最後就是修改nginx.conf設定檔了

[[email protected] html]# vi /var/nginx/conf/nginx.conf

location ~ \.php$ {root html;fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME /var/nginx/html$fastcgi_script_name;include fastcgi_params;}

找到這段代碼,原先是注釋掉的,開啟它,然後把紅色部分修改成項目web根目錄(原先是/scripts)

重啟nginx就可以了,測試ok

[[email protected] html]# /var/nginx/sbin/nginx -s reload

centos6下nginx配置php可用

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.