centos7 安裝LNMP(php7)之 nginx php-fpm yum安裝以及設定檔修改

來源:互聯網
上載者:User

標籤:網上   為什麼   comm   var   efault   odi   rip   location   index   

1.由於我也不知道為什麼,在網上找了很多資料,nginx要和php-fpm結合,所以在使用nginx配置之前要安裝php-fpm

2.yum install php70w-fpm,service php-fpm start

使用yum install php-fpm會報錯

Error: php70w-common conflicts with php-common-5.4.16-42.el7.x86_64
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest

 

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

4.yum install nginx

 service nginx start

5.

# find / -name nginx.conf

/etc/nginx/nginx.conf

在nginx.conf中最後一行看到

 include /etc/nginx/conf.d/*.conf;

所以找到/etc/nginx/conf.d/default.conf;

 

在location下面加上同級

location ~ \.php$ {
root /var/www/html; #指定php的根目錄
fastcgi_pass 127.0.0.1:9000;#php-fpm的預設連接埠是9000
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

6.nginx -t如果沒有報錯,報錯去修改錯誤

7./usr/sbin/nginx -s reload 重啟nginx服務

然後在/var/www/html建立index.php

<?php

phpinfo();

可以看到

 

centos7 安裝LNMP(php7)之 nginx php-fpm yum安裝以及設定檔修改

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.