Home  >  Article  >  Backend Development  >  The installation and use journey of PHP7 on the development machine

The installation and use journey of PHP7 on the development machine

藏色散人
藏色散人forward
2020-04-17 13:39:292062browse

Download 7:

$ cd
$ mkdir php7test
$ cd php7test
$ wget http://cn2.php.net/get/php-7.0.7.tar.gz/from/this/mirror
$ tar -zxvf php-7.0.7.tar.gz
$ cd php-7.0.7

Install some dependencies:

$ yum -y install libjpeg libpng freetype libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel curl-devel libxslt-devel lib2 lib2-devel

Configure configure

$ ./configure --prefix=/data/php7 --with-config-file-path=/data/php7/etc --with-config-file-scan-dir=/data/php7/etc/php.d --with-mcrypt=/usr/include --enable-mysqlnd --with-mysqli --with-pdo-mysql --enable-fpm --with-fpm-user=xxxxxxxxxx --with-fpm-group=xxxxxxxxxx --with-gd --with-iconv --enable-xml --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --with-zlib --enable-bcmath --enable-sockets

Then:

$ make
$ make install

After the default installation, you will find There is no php.ini file under /data/php7/etc. Where can I get this? It is available in the source code installation package of php7.

Enter the directory of the source code installation package

$ cd 
$ cd php7test/php-7.0.7
$ ls

You can see that there are two php.ini-xxx files

$ cp php.ini* /data/php7/etc/
$ cp php.ini-production /data/php7/etc/php.ini

Enable php-fpm

Configure the config file first

$ cd /data/php7/etc
$ cp php-fpm.conf.default php-fpm.conf
$ cp php-fpm.d/www.conf.default php-fpm.d/www.conf

When ./configure before compilation, we have already determined some configurations, such as the user and user group running fpm, so the default configuration should not be There will be path problems and permission problems.

Get the service loading of php-fpm

We hope to use the operations of service php-fpm start|stop|restart to restart the service, but it is not as complicated as nginx. PHP is compiled well After that, we were provided with a php-fpm program, which did not require me to write and share it anymore. This file is placed in the PHP compiled source code directory:

$ cd 
$ cd php7test/php-7.0.7/sapi/fpm
$ cp init.d.php-fpm /etc/init.d/php-fpm
$ chmod +x /etc/init.d/php-fpm
$ chkconfig --add php-fpm
$ chkconfig php-fpm on

Through the above operation, we can use service php-fpm start to enable php-fpm. Use ps -ef | grep php-fpm to check the process.

Or start php7 by using /data/php7/sbin/php-fpm.

Finish & Success

Recommended tutorial: "PHP7"

The above is the detailed content of The installation and use journey of PHP7 on the development machine. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete