How to upgrade nginx server from php5.5.7 to php7?
This article will introduce to you how to upgrade the nginx server from php5.5.7 to php7? Methods. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.
① The server nginx, php, and mysql are all installed, so I want to upgrade php7 directly.
②Follow the article: https://typecodes .com/web/centos7compilephp7.html?utm_source=tuicool&utm_medium=referral During the operation, something different appeared in the middle.
③Problem solving reference: http://blog.chinaunix.net/uid-25266990-id-2915395.html
Separating line------------ -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- ------------
I will repost step 2 below for my own use.
1 Create a php user and user group, and download the php7 source code from github
First create a user named php without login permissions and a user group named php, and then go to GitHub Download the php7 source code package.
#######新建php用户和php组 [root@typecodes ~]# groupadd -r php && useradd -r -g php -s /bin/false -d /usr/local/php7 -M php ######从GitHub下载php7安装包 [root@typecodes ~]# wget -c --no-check-certificate -O php7-src-master.zip https://github.com/php/php-src/archive/master.zip ######开始解压php7包 [root@typecodes ~]# unzip -q php7-src-master.zip && cd php-src-master #####安装编译php7时需要的依赖包 [root@typecodes php-src-master]# yum -y install libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel
2 Configuration of PHP7 compilation parameters (ps: I will post the slashes below, you can copy them directly)
After the preparations are completed, start to formally configure the installation details of php7 . Note that when operating, be sure to remove the comment text added after the backslash "\" below! ! !
######开始生成配置文件 [root@typecodes php-src-master]# ./buildconf buildconf: checking installation... buildconf: autoconf version 2.69 (ok) rebuilding aclocal.m4 rebuilding configure rebuilding main/php_config.h.in ######开始配置 [root@typecodes php-src-master]# ./configure \ --prefix=/usr/local/php7 \ [PHP7安装的根目录] --exec-prefix=/usr/local/php7 \ --bindir=/usr/local/php7/bin \ --sbindir=/usr/local/php7/sbin \ --includedir=/usr/local/php7/include \ --libdir=/usr/local/php7/lib/php \ --mandir=/usr/local/php7/php/man \ --with-config-file-path=/usr/local/php7/etc \ [PHP7的配置目录] --with-mysql-sock=/var/run/mysql/mysql.sock \ [PHP7的Unix socket通信文件] --with-mcrypt=/usr/include \ --with-mhash \ --with-openssl \ --with-mysql=shared,mysqlnd \ [PHP7依赖mysql库] --with-mysqli=shared,mysqlnd \ [PHP7依赖mysql库] --with-pdo-mysql=shared,mysqlnd \ [PHP7依赖mysql库] --with-gd \ --with-iconv \ --with-zlib \ --enable-zip \ --enable-inline-optimization \ --disable-debug \ --disable-rpath \ --enable-shared \ --enable-xml \ --enable-bcmath \ --enable-shmop \ --enable-sysvsem \ --enable-mbregex \ --enable-mbstring \ --enable-ftp \ --enable-gd-native-ttf \ --enable-pcntl \ --enable-sockets \ --with-xmlrpc \ --enable-soap \ --without-pear \ --with-gettext \ --enable-session \ [允许php会话session] --with-curl \ [允许curl扩展] --with-jpeg-dir \ --with-freetype-dir \ --enable-opcache \ [使用opcache缓存] --enable-fpm \ --enable-fastcgi \ --with-fpm-user=nginx \ [php-fpm的用户] --with-fpm-group=nginx \ [php-fpm的用户组] --without-gdbm \ --disable-fileinfo
./configure --prefix=/usr/local/php7 --exec-prefix=/usr/local/php7 --bindir=/usr/local/php7/bin --sbindir=/usr/local/php7/sbin --includedir=/usr/local/php7/include --libdir=/usr/local/php7/lib/php --mandir=/usr/local/php7/php/man --with-config-file-path=/usr/local/php7/etc --with-mysql-sock=/var/run/mysql/mysql.sock --with-mcrypt=/usr/include --with-mhash --with-openssl --with-mysql=shared,mysqlnd --with-mysqli=shared,mysqlnd --with-pdo-mysql=shared,mysqlnd --with-gd --with-iconv --with-zlib --enable-zip --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --enable-opcache --enable-fpm --enable-fastcgi --with-fpm-user=nginx --with-fpm-group=nginx --without-gdbm --disable-fileinfo
3 Start compiling and installing PHP7
Compared with compiling and installing MySQL, which consumes a lot of CPU and memory, compiling and installing PHP7 is much easier, and the whole process takes about an hour.
[root@typecodes php-src-master]# make clean && make && make install
Seeing the picture below means that PHP7 has been compiled and installed! (ps: An error occurred during compilation. Undefined reference to `libiconv_open cannot compile PHP;
For details of the solution, see the link above: Edit the Makefile at about line 77:
EXTRA_LIBS = .. ... -lcrypt
Add -liconv at the end, for example:
EXTRA_LIBS = ..... -lcrypt -liconv
and then run make. )
4 Optional step: execute the make test command to test
This is an optional step, execute the make test command. An interesting thing is: During the test, a TCP connection will be established with an IP address 72.52.91.14, which corresponds to the official PHP website http://www.php.net.
5 Check the PHP7 installation directory after successful compilation
Since you need to communicate with MySQL, you need to specifically check the lib extension library directory after PHP7 is installed (/usr/local/php7/lib/ php/extensions/no-debug-non-zts-20141001/). You need to ensure that at least two dynamic library files mysqli.so and pdo_mysql.so exist, as shown in the figure below.
6 Start setting up the PHP7 configuration files php.ini, php-fpm.conf, www.conf and php-fpm scripts
You can copy the compiled configuration file to the PHP7 configuration directory (/usr/local/php7/etc/), it is recommended to use the three PHP7 configuration files and the php-fpm service control script compiled in the article "Configuration of php.ini, php-fpm and www.conf in PHP7".
#######方法一:直接使用编译后未经优化处理的配置 [root@typecodes php-src-master]# cp php.ini-production /usr/local/php7/etc/php.ini [root@typecodes php-src-master]# cp /root/php-src-master/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm [root@typecodes php-src-master]# cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf [root@typecodes php-src-master]# cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf #######方法二:使用https://typecodes.com/web/php7configure.html文中的配置 [root@typecodes php-src-master]# mv ~/php.ini /usr/local/php7/etc/php.ini && mv ~/php-fpm /etc/init.d/php-fpm [root@typecodes php-src-master]# mv ~/php-fpm.conf /usr/local/php7/etc/php-fpm.conf && mv ~/www.conf /usr/local/php7/etc/php-fpm.d/www.conf
7 Add the environment variable of php
Add the bin directory generated by php compilation to the environment variable of the current Linux system
[root@typecodes ~]# echo -e '\nexport PATH=/usr/local/php7/bin:/usr/local/php7/sbin:$PATH\n' >> /etc/profile && source /etc/profile
8 Set the PHP log directory and php- fpm process file (php-fpm.sock) directory
Among them, set the user and user group of the php-fpm process directory to nginx, and create a php session session directory.
#######设置PHP日志目录和php-fpm的运行进程ID文件(php-fpm.sock)目录 [root@typecodes ~]# mkdir -p /var/log/php-fpm/ && mkdir -p /var/run/php-fpm && cd /var/run/ && chown -R nginx:nginx php-fpm #######修改session的目录配置 [root@typecodes etc]# mkdir -p /var/lib/php/session [root@typecodes etc]# chown -R nginx:nginx /var/lib/php
9 Set up PHP startup and test whether the configuration file is correct
######配置开机自启动,增加到主机sysV服务 [root@typecodes php-src-master]# chmod +x /etc/init.d/php-fpm [root@typecodes php-src-master]# chkconfig --add php-fpm [root@typecodes php-src-master]# chkconfig php-fpm on ######测试PHP的配置文件是否正确合法 [root@typecodes sbin]# php-fpm -t [03-May-2015 17:50:04] NOTICE: configuration file /usr/local/php7/etc/php-fpm.conf test is successful
10 Start the php service
After completing the above operations, you can officially use the php service. The command to start the php process service is as follows:
[root@typecodes sbin]# service php-fpm start Starting php-fpm done
Then you can check whether it is successful through the command ps -aux|grep php (the number of php-fpm processes and the process user nginx in the picture are both determined by pm in www.conf. The values of start_servers and user are determined respectively):
11 View PHP7 version information
Finally, you can view the current PHP version information through the command php -v. You can see in the figure that the current PHP7 version information is also used The Zend OPcache cache is disabled because the zend_extension=opcache.so configuration is added to the php.ini file.
configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
The following error occurs when compiling and installing PHP
./configure :
configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
Solution:
yum install libxslt-devel* - y
Recommended learning: php video tutorial
The above is the detailed content of How to upgrade nginx server from php5.5.7 to php7?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



To resolve the plugin not showing installed issue in PHP 7.0: Check the plugin configuration and enable the plugin. Restart PHP to apply configuration changes. Check the plugin file permissions to make sure they are correct. Install missing dependencies to ensure the plugin functions properly. If all other steps fail, rebuild PHP. Other possible causes include incompatible plugin versions, loading the wrong version, or PHP configuration issues.

In php5, we can use the fsockopen() function to detect the TCP port. This function can be used to open a network connection and perform some network communication. But in php7, the fsockopen() function may encounter some problems, such as being unable to open the port, unable to connect to the server, etc. In order to solve this problem, we can use the socket_create() function and socket_connect() function to detect the TCP port.

How to install the mongo extension in php7.0: 1. Create the mongodb user group and user; 2. Download the mongodb source code package and place the source code package in the "/usr/local/src/" directory; 3. Enter "src/" directory; 4. Unzip the source code package; 5. Create the mongodb file directory; 6. Copy the files to the "mongodb/" directory; 7. Create the mongodb configuration file and modify the configuration.

How to install and deploy php7.0: 1. Go to the PHP official website to download the installation version corresponding to the local system; 2. Extract the downloaded zip file to the specified directory; 3. Open the command line window and go to the "E:\php7" directory Just run the "php -v" command.

Common solutions for PHP server environments include ensuring that the correct PHP version is installed and that relevant files have been copied to the module directory. Disable SELinux temporarily or permanently. Check and configure PHP.ini to ensure that necessary extensions have been added and set up correctly. Start or restart the PHP-FPM service. Check the DNS settings for resolution issues.

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

Causes and solutions for errors when using PECL to install extensions in Docker environment When using Docker environment, we often encounter some headaches...

Compared with PHP7, PHP8 has some advantages and improvements in terms of performance, new features and syntax improvements, type system, error handling and extensions. However, choosing which version to use depends on your specific needs and project circumstances. Detailed introduction: 1. Performance improvement, PHP8 introduces the Just-in-Time (JIT) compiler, which can improve the execution speed of the code; 2. New features and syntax improvements, PHP8 supports the declaration of named parameters and optional parameters, making functions Calling is more flexible; anonymous classes, type declarations of properties, etc. are introduced.
