Operation and maintenance: Linux calls dual version PHP

Source: Internet
Author: User
Tags fpm zend

1. Current system Status

[[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. Download the Unpacking Package

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

3. Install the environment package to ensure the GCC and g++ environment of the server
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. Pre-compile, check the environment
./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. Compiling the installation

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

6. Configure the relevant PHP files (/USR/LOCAL/PHP7 is the installation directory, different from the original PHP version)

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. Setting up the php.ini file

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

Open php config file find cgi.fix_pathinfo configuration item, this item is commented by default and the value is 1, according to the official document, here in order to prevent nginx to send the request to the backend PHP-FPM module when the file does not exist, so as to avoid the malicious script injection of XXX, So this should remove the comment and set it to 0.

8. View the startup process management user

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. Start the PHP-FPM service

/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. Set Nginx call 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. Reload Nginx Service

nginx -s reloadnginx:这个便捷命令是/usr/local/nginx/sbin/nginx 的别名,命令如下:建议写入环境变量文件。alias nginx=/usr/local/nginx/sbin/nginx  

Operation and maintenance: Linux calls dual version PHP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.