{"id":717,"date":"2017-08-14T19:19:07","date_gmt":"2017-08-14T11:19:07","guid":{"rendered":"http:\/\/www.haku.studio\/?p=717"},"modified":"2017-08-14T19:19:07","modified_gmt":"2017-08-14T11:19:07","slug":"centos7%e4%b8%8bphp%e7%9a%84%e5%8d%b8%e8%bd%bd%e4%b8%8e%e5%ae%89%e8%a3%85nginx","status":"publish","type":"post","link":"https:\/\/bloo.heing.fun\/?p=717","title":{"rendered":"Centos7\u4e0bPHP\u7684\u5378\u8f7d\u4e0e\u5b89\u88c5nginx"},"content":{"rendered":"<p>\u6765\u6e90\uff1a<a href=\"http:\/\/www.cnblogs.com\/zdz8207\/p\/php-centos-uninstall-install.html\">http:\/\/www.cnblogs.com\/zdz8207\/p\/php-centos-uninstall-install.html<\/a><\/p>\n<p>Centos7\u4e0bPHP\u7684\u5378\u8f7d\u4e0e\u5b89\u88c5nginx<\/p>\n<p>CentOS\u4e0aPHP\u5b8c\u5168\u5378\u8f7d\uff0c\u60f3\u628aPHP\u5378\u8f7d\u5e72\u51c0\uff0c\u76f4\u63a5\u7528yum\u7684remove\u547d\u4ee4\u662f\u4e0d\u884c\u7684\uff0c\u9700\u8981\u67e5\u770b\u6709\u591a\u5c11rpm\u5305\uff0c\u7136\u540e\u6309\u7167\u4f9d\u8d56\u987a\u5e8f\u9010\u4e00\u5378\u8f7d\u3002<br \/>\n1.\u9996\u5148\u67e5\u770b\u673a\u5668\u4e0a\u5b89\u88c5\u7684\u6240\u6709php\u76f8\u5173\u7684rpm\u5305<br \/>\n[root@localhost nginx]# rpm -qa | grep php<br \/>\nphp-cli-5.3.3-22.el6.x86_64<br \/>\nphp-pdo-5.3.3-22.el6.x86_64<br \/>\nphp-gd-5.3.3-22.el6.x86_64<br \/>\nphp-fpm-5.3.3-22.el6.x86_64<br \/>\nphp-common-5.3.3-22.el6.x86_64<br \/>\nphp-5.3.3-22.el6.x86_64<br \/>\nphp-xml-5.3.3-22.el6.x86_64<br \/>\nphp-pear-1.9.4-4.el6.noarch<\/p>\n<p>2.\u6309\u4f9d\u8d56\u987a\u5e8f\u8fdb\u884c\u5220\u9664<br \/>\nrpm -e php-fpm-5.3.3-22.el6.x86_64<br \/>\nrpm-e php-pdo-5.3.3-22.el6.x86_64<br \/>\nrpm -e php-pear-1.9.4-4.el6.noarch<br \/>\nrpm-e php-cli-5.3.3-22.el6.x86_64<br \/>\nrpm -e php-5.3.3-22.el6.x86_64<br \/>\nrpm-e php-xml-5.3.3-22.el6.x86_64<br \/>\nrpm -e php-gd-5.3.3-22.el6.x86_64<br \/>\nrpm-e php-common-5.3.3-22.el6.x86_64<\/p>\n<p>==========================<br \/>\ncentos7\u5b89\u88c5nginx\u548cphp<\/p>\n<p>nginx\u5b89\u88c5\uff0c\u53c2\u8003\u7f51\u5740:<a href=\"https:\/\/www.digitalocean.com\/community\/tutorials\/how-to-install-linux-nginx-mysql-php-lemp-stack-on-centos-7\" target=\"_blank\" rel=\"noopener\">https:\/\/www.digitalocean.com\/community\/tutorials\/how-to-install-linux-nginx-mysql-php-lemp-stack-on-centos-7<\/a><\/p>\n<p>rpm -Uvh http:\/\/nginx.org\/packages\/centos\/7\/noarch\/RPMS\/nginx-release-centos-7-0.el7.ngx.noarch.rpm<\/p>\n<p>yum install nginx<\/p>\n<p>\u5b89\u88c5PHP\u548cphp-fpm<br \/>\nyum install &#8211;enablerepo=remi &#8211;enablerepo=remi-php56 php php-fpm<\/p>\n<p>\u56e0\u4e3a\u6211\u7684php\u5b89\u88c5\u7684\u662f5.6\u7684\uff0c\u6240\u4ee5\u7684\u6307\u5b9a\u8fd9\u4e2a\u6e90\u91cc\u9762\u5b89\u88c5php-fpm\uff0c\u4e0d\u7136\u4e00\u76f4\u62a5\u9519<\/p>\n<p>\u4fee\u6539php\u914d\u7f6e\u6587\u4ef6<br \/>\nvi \/etc\/php.ini<br \/>\n\u4fee\u6539\u62100(\u8fd9\u4e2a\u914d\u7f6e\u503c\u8bf4\u662f\u4e0d\u5b89\u5168\u7684\u8bbe\u7f6e,\u53c2\u8003\u7f51\u5740:<a href=\"http:\/\/www.laruence.com\/2010\/05\/20\/1495.html\" target=\"_blank\" rel=\"noopener\">http:\/\/www.laruence.com\/2010\/05\/20\/1495.html<\/a>)<\/p>\n<p>cgi.fix_pathinfo=0<br \/>\n\u4fee\u6539\u914d\u7f6e\u6587\u4ef6<\/p>\n<p>vim \/etc\/nginx\/conf.d\/default.conf<\/p>\n<p>server {<br \/>\nlisten 80;<br \/>\nserver_name www.scchary.com;<br \/>\nroot \/home\/samba1\/public_html;<br \/>\n#charset koi8-r;<br \/>\n#access_log \/var\/log\/nginx\/log\/host.access.log main;<\/p>\n<p>location \/ {<br \/>\n#root \/usr\/share\/nginx\/html;<br \/>\n#root \/home\/samba1\/public_html;<br \/>\nindex index.php index.html index.htm;<br \/>\n}<\/p>\n<p>#error_page 404 \/404.html;<\/p>\n<p># redirect server error pages to the static page \/50x.html<br \/>\n#<br \/>\nerror_page 500 502 503 504 \/50x.html;<br \/>\nlocation = \/50x.html {<br \/>\nroot \/usr\/share\/nginx\/html;<br \/>\n}<\/p>\n<p># proxy the PHP scripts to Apache listening on 127.0.0.1:80<br \/>\n#<br \/>\n#location ~ \\.php$ {<br \/>\n# proxy_pass http:\/\/127.0.0.1;<br \/>\n#}<\/p>\n<p># pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000<br \/>\n#<br \/>\nlocation ~ \\.php$ {<br \/>\n#root \/home\/samba1\/public_html;<br \/>\nfastcgi_pass 127.0.0.1:9000;<br \/>\nfastcgi_index index.php;<br \/>\nfastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;<br \/>\ninclude fastcgi_params;<br \/>\n}<\/p>\n<p># deny access to .htaccess files, if Apache&#8217;s document root<br \/>\n# concurs with nginx&#8217;s one<br \/>\n#<br \/>\n#location ~ \/\\.ht {<br \/>\n# deny all;<br \/>\n#}<br \/>\n}<br \/>\n\u4fee\u6539\u4e0a\u9762\u914d\u7f6e\u6587\u4ef6\u7684\u65f6\u5019\uff0c\u8fd0\u884cphp\u6587\u4ef6\u7684\u65f6\u5019\uff0c\u8001\u662f\u663e\u793a\u6ca1\u6709\u627e\u5230\uff0c\u540e\u6765\u5728\u8fd9\u91cc\u627e\u5230\u4e86\u7b54\u6848\uff0c\u53c2\u8003\u7f51\u5740<a href=\"http:\/\/www.nginx.cn\/562.html\" target=\"_blank\" rel=\"noopener\">http:\/\/www.nginx.cn\/562.html<\/a><\/p>\n<p>server {<br \/>\nlisten [::]:80;<br \/>\nserver_name example.com www.example.com;<br \/>\naccess_log \/var\/www\/logs\/example.com.access.log;<\/p>\n<p>location \/ {<br \/>\nroot \/var\/www\/example.com;<br \/>\nindex index.html index.htm index.pl;<br \/>\n}<\/p>\n<p>location \/images {<br \/>\nautoindex on;<br \/>\n}<\/p>\n<p>location ~ \\.php$ {<br \/>\nfastcgi_pass 127.0.0.1:9000;<br \/>\nfastcgi_index index.php;<br \/>\nfastcgi_param SCRIPT_FILENAME \/var\/www\/example.com$fastcgi_script_name;<br \/>\ninclude fastcgi_params;<br \/>\n}<br \/>\n}<br \/>\n\u8fd9\u4e2a\u914d\u7f6e\u4e2d\u6709\u5f88\u591a\u4e0d\u5408\u7406\u7684\u5730\u65b9\uff0c\u5176\u4e2d\u4e00\u4e2a\u660e\u663e\u7684\u95ee\u9898\u5c31\u662froot\u6307\u4ee4\u88ab\u653e\u5230\u4e86location \/ \u5757\u3002\u5982\u679croot\u6307\u4ee4\u88ab\u5b9a\u4e49\u5728location\u5757\u4e2d\u90a3\u4e48\u8be5root\u6307\u4ee4\u53ea\u80fd\u5bf9\u5176\u6240\u5728\u7684location\u751f\u6548\u3002\u5176\u5b83locaiont\u4e2d\u6ca1\u6709root\u6307\u4ee4\uff0c\u50cflocation \/images\u5757\u4e0d\u4f1a\u5339\u914d\u4efb\u4f55\u8bf7\u6c42\uff0c\u9700\u8981\u5728\u6bcf\u4e2a\u8bf7\u6c42\u4e2d\u91cd\u590d\u914d\u7f6eroot\u6307\u4ee4\u6765\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u3002\u56e0\u6b64\u6211\u4eec\u9700\u8981\u628aroot\u6307\u4ee4\u653e\u5728server\u5757\uff0c\u8fd9\u6837\u5404\u4e2alocation\u5c31\u4f1a\u7ee7\u627f\u7236server\u5757\u5b9a\u4e49\u7684$document_root\uff0c\u5982\u679c\u67d0\u4e2alocation\u9700\u8981\u5b9a\u4e49\u4e00\u4e2a\u4e0d\u540c\u7684$document_root\uff0c\u5219\u53ef\u4ee5\u5728location\u5355\u72ec\u5b9a\u4e49\u4e00\u4e2aroot\u6307\u4ee4\u3002<\/p>\n<p>\u53e6\u4e00\u4e2a\u95ee\u9898\u5c31\u662ffastCGI\u53c2\u6570SCRIPT_FILENAME \u662f\u5199\u6b7b\u7684\u3002\u5982\u679c\u4fee\u6539\u4e86root\u6307\u4ee4\u7684\u503c\u6216\u8005\u79fb\u52a8\u6587\u4ef6\u5230\u522b\u7684\u76ee\u5f55\uff0cphp-fpm\u4f1a\u8fd4\u56de\u201cNo input file specified\u201d\u9519\u8bef\uff0c\u56e0\u4e3aSCRIPT_FILENAME\u5728\u914d\u7f6e\u4e2d\u662f\u5199\u6b7b\u7684\u5e76\u6ca1\u6709\u968f\u7740$doucument_root\u53d8\u5316\u800c\u53d8\u5316\uff0c\u6211\u4eec\u53ef\u4ee5\u4fee\u6539SCRIPT_FILENAME\u914d\u7f6e\u5982\u4e0b\uff1a<\/p>\n<p>fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;<\/p>\n<p>\u6240\u4ee5\u6211\u4eec\u4e0d\u80fd\u5fd8\u8bb0\u5728server\u5757\u4e2d\u914d\u7f6eroot\u6307\u4ee4\uff0c\u4e0d\u7136$document_root\u7684\u503c\u4e3a\u7a7a\uff0c\u53ea\u4f1a\u4f20$fastcgi_script_name\u5230php-fpm\uff0c\u8fd9\u6837\u5c31\u4f1a\u5bfc\u81f4\u201cNo input file specified\u201d\u9519\u8bef\u3002<\/p>\n<p>\u6700\u540e\u5728\u6d4b\u8bd5php\u6587\u4ef6\u91cc\u9762\u8f93\u51faphpinfo\u7684\u65f6\u5019\uff0c\u51fa\u73b0\u4e86\u4e00\u4e2a\u672a\u5b9a\u4e49\u65f6\u533a\u7684\u9519\u8bef\uff0c\u4fee\u6539\u4e86\u914d\u7f6e\u6587\u4ef6\u8fd8\u662f\u62a5\u9519\uff0c\u6700\u540e\u91cd\u542f\u4e86\u4e0bphp-fpm\u5c31\u597d\u4e86<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6765\u6e90\uff1ahttp:\/\/www.cnblogs.com\/zdz8207\/p\/php-centos-uninstal [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-717","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/bloo.heing.fun\/index.php?rest_route=\/wp\/v2\/posts\/717","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bloo.heing.fun\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bloo.heing.fun\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bloo.heing.fun\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bloo.heing.fun\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=717"}],"version-history":[{"count":1,"href":"https:\/\/bloo.heing.fun\/index.php?rest_route=\/wp\/v2\/posts\/717\/revisions"}],"predecessor-version":[{"id":718,"href":"https:\/\/bloo.heing.fun\/index.php?rest_route=\/wp\/v2\/posts\/717\/revisions\/718"}],"wp:attachment":[{"href":"https:\/\/bloo.heing.fun\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=717"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bloo.heing.fun\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=717"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bloo.heing.fun\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=717"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}