Home>Article>Backend Development> How to install php7.0 in linux environment
Installation method of php7.0 in Linux environment: first download php and decompress it for installation; then configure the environment variable "export PATH=/usr/local/php/bin:$PATH"; finally start php-fpm .
The operating environment of this article: CentOS 6.6 system, php7.0.2 version, DELL G3 computer
How to use php7.0 in Linux environment Installation?
Linux environment PHP7.0 installation
Comparison between PHP7 and HHVM
The performance of PHP7 in real scenarios is indeed comparable to that of HHVM Quite, even surpassing HHVM in some scenarios.
The operation and maintenance of HHVM is complicated and it is a multi-threaded model. This means that if a thread causes a crash, the entire service will hang up, and it will not automatically restart itself.
In addition, it uses JIT, which means that it needs to be warmed up after restarting. Without preheating, the performance will be worse. Moreover, the multi-threaded model is difficult to debug, which is very unsuitable for web services that pursue stability.
For version numbers before Nginx and PHP7.0, please refer to this article: Linux environment Nginx installation and debugging and PHP installation
PHP7.0 The official version has been announced around November 2015. The current version number is PHP7.0.2. I first started with the first beta version of php7 in August 2015, and now the official version has been released.
linux version number: 64-bit CentOS 6.6
Nginx version number: nginx1.8.0
php version number: php-7.0.2
Download
# wget http://php.net/get/php-7.0.2.tar.gz/from/a/mirror
It is recommended to read the installation help file INSTALL before installation
Unzip the installation
# tar zxvf php-7.0.2.tar.gz # cd php-7.0.2
First check the installation help
# ./configure --help # ./configure --prefix=/usr/local/php \ --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-xmlrpc \ --with-xsl \ --with-zlib \ --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-xml \ --enable-zip
If the configuration is wrong, you need to install the necessary modules, directly yum to install the dependent libraries together
# yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel mysql pcre-devel
Note: When installing php7beta3, there are several configurations that you just need to yum. This is no longer the case with php-7.0.2.
# yum -y install curl-devel # yum -y install libxslt-devel
Compile and install
# make && make install
Configuration file
# cp php.ini-development /usr/local/php/lib/php.ini # cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf # cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf # cp -R ./sapi/fpm/php-fpm /etc/init.d/php-fpm
Configuring environment variables
/etc/profile export PATH=/usr/local/php/bin:$PATH
It should be noted that the www.conf configuration file in php7 configures the port number and other information of phpfpm. If you change the default 9000 The port number needs to be changed here, and then the nginx configuration
Start
# /etc/init.d/php-fpm
Recommended study: "PHP Video Tutorial"
The above is the detailed content of How to install php7.0 in linux environment. For more information, please follow other related articles on the PHP Chinese website!