Unlike lamp, the N in Lnmp refers to Nginx (a Web services software similar to Apache) and all the others. At present, this kind of environment application is also very many. Nginx Design is designed to provide a fast and efficient multi-concurrent web services software. In the static page of the processing of Nginx does win Apache, however, in the dynamic page processing Nginx is no more than Apache has much advantage. However, there are still many enthusiasts to nginx more enthusiastic, with Nginx technology matures, it in the field of Web services software is becoming more and more high.
LNMP architecture, MySQL installation method and lamp in the same way as MySQL installation, first install MySQL and then install PHP.
PHP Compiling the installation
Here to first declare, for Nginx PHP installation and for Apache PHP installation is different, because Nginx PHP is fastcgi in the way of combining nginx, can be understood as Nginx proxy php fastcgi, and Apache is calling PHP as its own module.
(1) Download PHP source package
[Email protected] mysql]# CD/USR/LOCAL/SRC
[email protected] src]# wget http://cn2.php.net/distributions/php-5.4.45.tar.bz2
(2) Unzip the source package, create an account
[Email protected] src]# tar jxf php-5.4.45.tar.bz2
[Email protected] src]# useradd-s/sbin/nologin php-fpm
This account is used to run the PHP-FPM service, and in the LNMP Environment, PHP serves as a service.
(3) Before installing PHP, please install the installation package that it depends on in advance:
Yum install-y bzip2-devel curl-devel db4-devel libjpeg-devel libpng-devel libxpm-devel gmp-devel libc-client-devel Openldap-devel unixodbc-devel postgresql-devel sqlite-devel aspell-devel net-snmp-devel libxslt-devel libxml2-devel Pcre-devel mysql-devel unixodbc-devel postgresql-devel pspell-devel net-snmp-devel
Error: configure:error:mcrypt.h not found. Please reinstall Libmcrypt.
Copy Code The code is as follows:
#wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
#tar ZXF libmcrypt-2.5.7.tar.gz
#cd libmcrypt-2.5.7
#./configure
#make
#make Install
(4) Configuring compilation options
[Email protected] libmcrypt-2.5.7]# CD/USR/LOCAL/SRC
[Email protected] src]# CD php-5.4.45
[email protected] php-5.4.45]# ./configure--prefix=/usr/local/php--with-config-file-path=/usr/local/php/etc--enable-fpm--with-fpm-user= PHP-FPM--with-fpm-group=php-fpm--with-mysql=/usr/local/mysql--with-mysql-sock=/tmp/mysql.sock--with-libxml-dir --WITH-GD--with-jpeg-dir--with-png-dir--with-freetype-dir--with-iconv-dir--with-zlib-dir--with-mcrypt-- Enable-soap--enable-gd-native-ttf--enable-ftp--enable-mbstring--enable-exif--disable-ipv6--with-pear-- With-curl--with-openssl
If an error is encountered during compilation, this address is found to resolve http://blog.sina.com.cn/s/blog_167f23bf50102xdki.html
(5) Compiling PHP
[[email protected] php-5.4.45]# make
If you encounter an error in this step, please refer to the following:
1) Generating phar.php
Generating Phar.phar
PEAR Package php_archive not installed:generated Phar would require PHP ' s Phar Extension be enabled.
Pharcommand.inc
Directorygraphiterator.inc
Clicommand.inc
Invertedregexiterator.inc
Directorytreeiterator.inc
Phar.inc
Build complete.
Don ' t forget to run ' make test '.
PHP compile time relies on PEAR package, current Bug "PEAR package php_archive not installed:generated Phar will require PHP ' s Phar Extension be enabled. "The problem has been clearly reported.
As a result, the compiler uses the parameter--without-pear to shield the pear from being installed and install it, and because Phar belongs to a library of pear, the Phar is not shut down and the error is reported.
You also need to use--disable-phar compilation parameters.
Workaround:
./configure--without-pear--disable-phar
Make
Make install
2) /usr/bin/ld:cannot Find-lltdlcollect2:ld returned 1 exit statusmake: * * * [SAPI/FPM/PHP-FPM] Error 1
Workaround:
Yum Install-y libtool-ltdl-devel
(6) Installing PHP
First, check the previous PHP installation directory file
[Email protected] php-5.4.45]# ls/usr/local/php/
Bin etc include Lib Php sbin var
Delete First, then install new PHP
[Email protected] php-5.4.45]# rm-rf/usr/local/php/
[[email protected] php-5.4.45]# make install
each of these steps, if not fully executed correctly, then the next step is not possible, do you remember the method to determine whether the correct execution? Use echo $? See if the result is "0", if not, it is not executed correctly.
(7) Repair configuration file
[email protected] php-5.4.45]# CP Php.ini-production/usr/local/php/etc/php.ini
[email protected] php-5.4.45]# CP sapi/fpm/init.d.php-fpm/etc/init.d/php-fpm (copy startup execution script)
[Email protected] php-5.4.45]# chmod 755/etc/init.d/php-fpm
Grant Execution permission
[Email protected] php-5.4.45]# chkconfig--add php-fpm
Add to the list of system services.
[Email protected] php-5.4.45]# chkconfig php-fpm on
Boot up
[[Email protected] php-5.4.45]# service PHP-FPM start
Restarting the PHP-FPM service
starting PHP-FPM [06-apr-2017 03:18:37] ERROR : Failed to open configuration file '/usr/local/php/etc/php-fpm.conf ': No such file or directory (2)
[06-apr-2017 03:18:37] error:failed to load configuration file '/usr/local/php/etc/php-fpm.conf '
[06-apr-2017 03:18:37] ERROR:FPM initialization failed
Failed
The above error is that the configuration file does not exist and cannot be started
solution requires copying a boot file
[Email protected] php-5.4.45]# cd/usr/local/php/etc/
[[email protected] etc]# ls
pear.conf Php-fpm.conf.default php.ini
[[Email protected] etc]# mv Php-fpm.conf.default php-fpm.conf (rename)
[[email protected] etc]#/usr/local/php/sbin/php-fpm-t (check file for errors)
[06-apr-2017 03:24:53] Notice:configuration file/usr/local/php/etc/php-fpm.conf Test is successful
[[Email protected] php-5.4.45]# service PHP-FPM start
Restart the PHP-FPM service again
starting PHP-FPM [06-apr-2017 03:31:22] ERROR : Unable to bind listening socket for address ' 127.0.0.1:9000 ': Address already on use (98)
[06-apr-2017 03:31:22] ERROR:FPM initialization failed
Failed
Workaround:
#netstat-lntup | grep 9000
#killall PHP-FPM
# service PHP-FPM Start
Starting PHP-FPM done started successfully
[[Email protected] etc]# PS aux |grep php-fpm
Check to see if the process is started
[Email protected] etc]# NETSTAT-LNP
Viewing the Listening port
Root 21454 0.0 0.1 26712 2972? Ss 18:52 0:00 php-fpm:master process (/usr/local/php/etc/php-fpm.conf)
PHP-FPM 21455 0.0 0.1 26712 2656? S 18:52 0:00 Php-fpm:pool www
PHP-FPM 21456 0.0 0.1 26712 2656? S 18:52 0:00 Php-fpm:pool www
Root 21458 0.0 0.0 5980 740 pts/0 r+ 18:52 0:00 grep php-fpm
The above notes have been installed in PHP, the following information for reference
[Email protected] php-5.4.45]# vim/usr/local/php/etc/php-fpm.conf
Write the following to the file:
[global]pid =/usr/local/php/var/run/php-fpm.piderror_log =/usr/local/php/var/log/php-fpm.log[www]listen =/tmp/ Php-fcgi.sockuser = Php-fpmgroup = PHP-FPMPM = Dynamicpm.max_children = 50pm.start_servers = 20pm.min_spare_servers = 5pm. Max_spare_servers = 35pm.max_requests = 500rlimit_files = 1024
After you save the configuration file, verify that the configuration is correct by:
/usr/local/php/sbin/php-fpm-t
If a word like "test is successful" appears, the configuration is successful.
(8) Start PHP-FPM
The first thing to do is to copy a startup script to/etc/init.d/.
[Email protected] php-5.4.45]# CP/USR/LOCAL/SRC/PHP-5.4.45/SAPI/FPM/INIT.D.PHP-FPM/ETC/INIT.D/PHP-FPM
Give it a change permission of 755
[Email protected] php-5.4.45]# chmod 755/etc/init.d/php-fpm
Restarting the PHP-FPM service
[[Email protected] php-5.4.45]# service PHP-FPM start
If you want it to boot, execute:
[Email protected] php-5.4.45]# chkconfig php-fpm on
Detect whether to start:
[[Email protected] php-5.4.45]# PS aux |grep php-fpm
Root 5901 0.0 0.1 26888 3144? Ss 23:32 0:00 php-fpm:master process (/usr/local/php/etc/php-fpm.conf)
PHP-FPM 5902 0.0 0.1 26888 2660? S 23:32 0:00 Php-fpm:pool www
PHP-FPM 5903 0.0 0.1 26888 2660? S 23:32 0:00 Php-fpm:pool www
PHP-FPM 5904 0.0 0.1 26888 2660? S 23:32 0:00 Php-fpm:pool www
PHP-FPM 5905 0.0 0.1 26888 2660? S 23:32 0:00 Php-fpm:pool www
PHP-FPM 5906 0.0 0.1 26888 2660? S 23:32 0:00 Php-fpm:pool www
PHP-FPM 5907 0.0 0.1 26888 2664? S 23:32 0:00 Php-fpm:pool www
PHP-FPM 5908 0.0 0.1 26888 2664? S 23:32 0:00 Php-fpm:pool www
PHP-FPM 5909 0.0 0.1 26888 2664? S 23:32 0:00 Php-fpm:pool www
PHP-FPM 5910 0.0 0.1 26888 2664? S 23:32 0:00 Php-fpm:pool www
PHP-FPM 5911 0.0 0.1 26888 2664? S 23:32 0:00 Php-fpm:pool www
PHP-FPM 5912 0.0 0.1 26888 2664? S 23:32 0:00 Php-fpm:pool www
PHP-FPM 5913 0.0 0.1 26888 2664? S 23:32 0:00 Php-fpm:pool www
PHP-FPM 5914 0.0 0.1 26888 2664? S 23:32 0:00 Php-fpm:pool www
PHP-FPM 5915 0.0 0.1 26888 2664? S 23:32 0:00 Php-fpm:pool www
PHP-FPM 5916 0.0 0.1 26888 2664? S 23:32 0:00 Php-fpm:pool www
PHP-FPM 5917 0.0 0.1 26888 2664? S 23:32 0:00 Php-fpm:pool www
PHP-FPM 5918 0.0 0.1 26888 2664? S 23:32 0:00 Php-fpm:pool www
PHP-FPM 5919 0.0 0.1 26888 2664? S 23:32 0:00 Php-fpm:pool www
PHP-FPM 5920 0.0 0.1 26888 2664? S 23:32 0:00 Php-fpm:pool www
PHP-FPM 5921 0.0 0.1 26888 2664? S 23:32 0:00 Php-fpm:pool www
Root 5924 0.0 0.0 5984 752 pts/0 s+ 23:36 0:00 grep php-fpm
This article from "12350027" blog, declined reprint!
PHP Compilation Installation