在 CetnOS 6 (64位) 操作系統上部署Nginx and PHP5服務器。這個過程通過 yum 命令進行RPM包安裝。
可以參考 PHP 官方文檔。
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpmrpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
添加 nginx 的 YUM 庫配置文件 /etc/yum.repos.d/nginx.repo,
[nginx]name=nginx repobaseurl=http://nginx.org/packages/centos/$releasever/$basearch/gpgcheck=0enabled=1
root 用戶執行:
# yum install nginx
root 用戶執行:
# yum install php-fpm
將會安裝好 php-fpm 以及 php 本身在內的其他依賴。
配置 /etc/php.ini,設置 cgi.fix_pathinfo=0
啟動 php-fpm 并放置后臺運行
php-fpm -D
停掉 php-fpm 的方法
root@acx-xiwang:/etc# ps -ef | grep php-fpmroot 31591 1 0 14:09 ? 00:00:00 php-fpm: master process (/etc/php-fpm.conf)apache 31592 31591 0 14:09 ? 00:00:00 php-fpm: pool wwwapache 31593 31591 0 14:09 ? 00:00:00 php-fpm: pool wwwapache 31594 31591 0 14:09 ? 00:00:00 php-fpm: pool wwwapache 31595 31591 0 14:09 ? 00:00:00 php-fpm: pool wwwapache 31596 31591 0 14:09 ? 00:00:00 php-fpm: pool wwwroot 31914 31878 0 14:32 pts/1 00:00:00 grep --color php-fpmroot@acx-xiwang:/etc# kill -s SIGINT 31591
或者通過 service 命令執行
service php-fpm stopservice php-fpm start
直接分享我的配置 /etc/nginx/nginx.conf:
user xiwang;events {}http { include /etc/nginx/mime.types; server { root /home/xiwang/opt/www; location / { index index.html index.htm index.php; } error_page 404 /404.html; location ~* /.php$ { fastcgi_index index.php; fastcgi_pass 127.0.0.1:9000; #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }}
啟動 Nginx 服務器
$ nginx
或者通過 service 命令執行:
service nginx stopservice nginx start
如果運行時修改了配置文件,可以通過 nginx -s reload 來使配置文件生效。
文章: 英文原版
檢查 php 文件是否擁有寫權限,它的父目錄都有執行權限 ?
chmod a+x /home/xiwang/opt #<-- container folder should be granted execute permissionchmod a+x /home/xiwang/opt/www #<-- container folder should be granted execute permissionchmod a+w /home/xiwang/opt/www/*.php #<-- .php file should be granted write permission
PHP編程 鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。
新聞熱點
疑難解答
圖片精選