Install dependent packages First
Yum Install
Pcre pcre-devel zlib zlib-devel OpenSSL openssl-devel gd gd-devel libjpeg libjpeg-devel libpng libpng-devel freetype freet Ype-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel lua-devel
autoconf libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel Curl Curl-devel Libidn libidn-devel libtool libtool-libs libevent-devel libevent openldap openldap-devel nss_ldap openldap-clients openl Dap-servers Libtool-ltdl libtool-ltdl-devel Bison libgcrypt php-mcrypt libmcrypt libmcrypt-devel cmake gcc gcc-c++ ncurse S-devel perl-data-dumper libicu-devel libquadmath-devel python-devel bzip2-devel
I don't make a distinction; these are the dependent packages that need to be installed to build the LNPM environment, all installed.
Download PHP, I go to the official website to download the http://www.php.net/downloads.php
Download the latest stable version of the tar.gz format
Then use the Xftp tool to remotely link Linux, and put the download package in the Linux/usr/local/directory
1 Decompression:
[[Email protected]
[Email protected]]# tar-zxvf php-7.1.12.tar.gz
2 Compiling:
./configure--prefix=/usr/local/php--with-config-file-path=/usr/local/php/etc--with-mcrypt=/usr/include-- With-mysql=/usr/local/mysql--with-mysqli=/usr/local/mysql/bin/mysql_config--with-pdo-mysql=/usr/local/mysql-- WITH-GD--with-iconv--with-zlib--enable-xml--enable-bcmath--enable-shmop--enable-sysvsem-- Enable-inline-optimization--enable-mbregex--enable-fpm--enable-mbstring--enable-ftp--enable-gd-native-ttf-- With-openssl--enable-pcntl--enable-sockets--with-xmlrpc--enable-zip--enable-soap--without-pear--with-gettext-- Enable-session--with-curl--with-jpeg-dir--with-freetype-dir--enable-opcache--with-png-dir--with-libxml-dir-- With-mcrypt--with-mhash
Compile error error content, read the wrong content to solve, some error is not found to rely on the package to see if the dependent package is all installed; there are still some MySQL installed to install MySQL first
After all compilation is complete, execute:
Make && make install
3. Configure Startup:
The directory/usr/local/php will appear after the make installation is complete;
Execute the following sentence
[Email protected] local]# ll/usr/local/php/etc/
Can see the directory under the configuration file, generally I will transfer the configuration file to the non-root user's home directory of other users
For example, I create a ADV user, under the ADV user to create a directory to save the PHP configuration file;
[Email protected] home]# cd/home/adv/
[Email protected] adv]# mkdir PHPFPM
[Email protected] adv]# CD phpfpm/
[Email protected] phpfpm]# mkdir conf
At this point we already have such a directory/home/adv/phpfpm/conf
Next put the configuration file CP into the/home/adv/phpfpm/conf directory
1. First put the php.ini file CP into the/home/adv/phpfpm/conf directory
php.ini file in the php-7.1.12 file you just unzipped.
[Email protected]/]# Cp/usr/local/php-7.1.12/php.ini-production/home/adv/phpfpm/conf/php.ini
[Email protected]/]# cp/usr/local/php/etc/php-fpm.conf.default/home/adv/phpfpm/conf/php-fpm.conf
P/usr/local/php/etc/php-fpm.d/www.conf.default/home/adv/phpfpm/conf/backend.conf
Now we can see that there are three files in the/home/adv/phpfpm/conf/directory
2 Modifying the configuration file:
Modify the Php-fpm.conf file
[Email protected]/]# vim php-fpm.conf
There are other configurations that need to be modified according to individual needs
3. Edit the startup php file, because we have transferred the configuration file to the ADV user, so we need to specify the configuration file to start PHP
startup script: [[email protected] phpfpm]# vim/home/adv/phpfpm/phpfpm.sh
#!/bin/Bashcurrdir= ' DirName" $"' BASEDIR= ' CD"$CURRDIR"; pwd ' NAME="PHP-FPM"CMD=/usr/local/php/sbin/php-FPMif[" $"="- D" ]; Then shift Executedir=$1'/'ShiftElseExecutedir= $BASEDIR'/'fiif[!-D"$EXECUTEDIR" ]; Then Echo"ERROR: $EXECUTEDIR is not a dir"Exitfiif[!-D"$EXECUTEDIR"/conf]; Then Echo"error:could not find $EXECUTEDIR/conf/"Exitfiif[!-D"$EXECUTEDIR"/logs]; Then mkdir"$EXECUTEDIR"/Logsficd"$EXECUTEDIR"Pid_file="$EXECUTEDIR"/logs/php-Fpm.pidcheck_pid () {RETVAL=1 if[ -f $PID _file]; Then PID=' cat $PID _file ' ls/proc/$PID &>/dev/NULL if[$?-eq0 ]; Then RETVAL=0fi fi}check_running () {PID=0RETVAL=0Check_pidif[$RETVAL-eq0 ]; Then Echo"$CMD is running as $PID, we 'll do nothing"Exit Fi}start () {check_running"$CMD"-Y"$EXECUTEDIR/conf/php-fpm.conf"-C"$EXECUTEDIR/conf/php.ini"-P ' pwd '}stop () {Kill-sigquit ' cat $PID _file '}status () {check_pidif[$RETVAL-eq0 ]; Then Echo"PHP-FPM is running as $PID ..." ElseEcho"PHP-FPM is not running"fi}reload () {check_pidif[$RETVAL-eq0 ]; Then kill-SIGUSR2 ' cat $PID _file 'ElseEcho"PHP-FPM is not running"Fi}reopen () {check_pidif[$RETVAL-eq0 ]; Then kill-SIGUSR1 ' cat $PID _file 'ElseEcho"PHP-FPM is not running"fi} RETVAL=0 Case " $" inchstart) Start; stop) stop;; restart) stop start;; status) status; reload) reload;; reopen) reopen;; *) echo"Usage: $ {Start|stop|restart|status|reload|reopen}"RETVAL=1esacexit $RETVAL
You can use it after you've written it, start the test.
[Email protected] phpfpm]# bash phpfpm.sh
Usage:phpfpm.sh {Start|stop|restart|status|reload|reopen}
[Email protected] phpfpm]#
You can see that phpfpm.sh {Start|stop|restart|status|reload|reopen} starts with these executables
Start:
[[email protected] phpfpm]# Bash phpfpm.sh start
Execute the following command to see if the start is successful, whether there is a process
[Email protected] phpfpm]# Ps-ef | grep php
You can see the red box indicates that the instructions were started successfully;
Since the configuration is placed in the ADV user, the start or the proposal with ADV this user to start;
Linux-centos7 Installing PHP