營運日常:Linux調用雙版本PHP

來源:互聯網
上載者:User

標籤:tst   3.1   並且   軟體   use   copyright   rpc   cat   ref   

1.當前系統狀態

[[email protected] ~]# php -vPHP 5.6.31 (cli) (built: Nov 24 2017 12:37:03)Copyright (c) 1997-2016 The PHP GroupZend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies    with Zend Guard Loader v3.3, Copyright (c) 1998-2014, by Zend Technologies[[email protected] ~]# uname -r3.10.0-693.5.2.el7.x86_64

2.下載解壓軟體包

wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2tar -xf php-7.1.6.tar.bz2cd php-7.1.6

3.安裝環境包,保證伺服器的gcc和g++環境
yum -y install libxml2 libxml2-devel openssl openssl-devel curl curl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel pcre pcre-devel libxslt libxslt-devel bzip2 bzip2-devel

4.先行編譯,檢查環境
./configure --prefix=/usr/local/php7 --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-zip

5.編譯安裝

ln -s /usr/local/lib/libiconv.so.2 /usr/lib64/make ZEND_EXTRA_LIBS=‘-liconv‘make install

6.配置相關php檔案(/usr/local/php7是安裝目錄,區別原來的PHP版本)

cp php.ini-development /usr/local/php7/lib/php.inicp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.confcp sapi/fpm/php-fpm /usr/local/bin/php7-fpm

7.設定php.ini檔案

vim /usr/local/php7/lib/php.inicgi.fix_pathinfo=0

開啟php設定檔找到cgi.fix_pathinfo配置項,這一項預設被注釋並且值為1,根據官方文檔的說明,這裡為了當檔案不存在時,阻止Nginx將請求發送到後端的PHP-FPM模組,從而避免惡意指令碼注入的×××,所以此項應該去掉注釋並設定為0

8.查看啟動進程系統管理使用者

cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.confvim /usr/local/php7/etc/php-fpm.d/www.conf; Unix user/group of processes; Note: The user is mandatory. If the group is not set, the default user‘s group;       will be used.user = nobodygroup = nobody

9.啟動php-fpm服務

/usr/local/bin/php7-fpm[[email protected] ~]# netstat -tunlp |grep 9000tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN      23384/php-fpm: mast

10.設定nginx調用PHP7

vim /usr/local/nginx/conf/vhost/linuxview.conflocation ~ \.php$ {   #不能有下面這句 try_files ,不然報錯500   # try_files $uri /index.php =404;   # fastcgi_split_path_info ^(.+\.php)(/.+)$;   # root      html;   #這句注意 後面是127.0.0.1,不然調用不了   fastcgi_pass  127.0.0.1:9000;   #fastcgi_pass  unix:/tmp/php-cgi.sock;   fastcgi_index index.php;   include fastcgi_params;   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;   }

11.重載入nginx服務

nginx -s reloadnginx:這個便捷命令是/usr/local/nginx/sbin/nginx 的別名,命令如下:建議寫入環境變數檔案。alias nginx=/usr/local/nginx/sbin/nginx  

營運日常:Linux調用雙版本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.