Linux 利用yum源安装php5.6+nginx
前言
- CentOS 7
- nginx1.12.2
- php5.6
- nginx已經安裝完成,且document root 目錄為/usr/share/nginx/html。
步驟
1,添加php5.6源
shell> yum install epel-release shell> rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm2,查看php5.6源
shell> yum info php56w Name : php56w Arch : x86_64 Version : 5.6.40 Release : 1.w7 Size : 9.3 M Repo : installed From repo : webtatic Summary : PHP scripting language for creating dynamic web sites URL : http://www.php.net/ License : PHP and Zend and BSD Description : PHP is an HTML-embedded scripting language. PHP attempts to make it: easy for developers to write dynamically generated web pages. PHP also: offers built-in database integration for several commercial and: non-commercial database management systems, so writing a: database-enabled webpage with PHP is fairly simple. The most common: use of PHP coding is probably as a replacement for CGI scripts.:: The php56w package contains the module (often referred to as mod_php): which adds support for the PHP language to Apache HTTP Server.3,安裝php5.6
shell> yum install php56w php56w-fpm4,查看php版本
shell> php -v PHP 5.6.40 (cli) (built: Jan 12 2019 13:11:15) Copyright (c) 1997-2016 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies5,接下來配置/etc/php-fpm.d/www.conf,將user和group改為nginx。
shell> vi /etc/php-fpm.d/www.conf user = nginx group = nginx6,啟動php-fpm服務
shell> systemctl start php-fpm7,檢查php-fpm服務
ps -ef | grep php-fpm netstat -tlnp | grep 90008,修改nginx配置,使nginx能夠將php腳本的處理轉給php-fpm模塊。
shell> vi /etc/nginx/conf.d/default.conf --------------默認是注釋掉的,取消注釋即可。如果沒有,則添加。注意將/script改為$document_root---------------location ~ \.php$ {root /usr/share/nginx/html;fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;include fastcgi_params;}root的值需要修改為/usr/share/nginx/html。
fastcgi_param的值需要修改為$document_root$fastcgi_script_name;。
9,nginx重載配置
shell> nginx -s reload實際情況中,如重載nginx配置與此處給出的方式不同,自動替換成其它方式即可。
10,編輯一個測試的php程序。
shell> vi /usr/share/nginx/html/index.php ----------/usr/share/nginx/html是document_root目錄--------- <?phpphpinfo(); ?>11,輸入index.php頁面的輸出結果
http://localhost/index.php12,設置session目錄訪問權限
cd /var/lib/php chown -R nginx:nginx *務必保證php-fpm的啟動賬戶(本文設置的啟動賬戶為nginx)對存放session的目錄具有讀寫權限,否則將不能正確使用session。
其它
查看可以安裝的php插件:yum list php70w*
啟動php-fpm:systemctl start php-fpm 或 /usr/sbin/php-fpm
停止php-fpm:systemctl stop php-fpm
重啟php-fpm:systemctl restart php-fpm
php-fpm配置文件:/etc/php-fpm.conf /etc/php-fpm.d/*.conf
參考
https://webtatic.com/packages/php56/
總結
以上是生活随笔為你收集整理的Linux 利用yum源安装php5.6+nginx的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 常用浏览器网页及文档长图截图方法如何使用
- 下一篇: CASS如何绘制断面图和地形图如何用电脑