PHP version 5.6.31, Nginx version:nginx/1.10.2
1. Download:
wget http://cn2.php.net/distributions/php-5.6.31.tar.gz
2. Installation Components
Yum install-y gcc gcc-c++ make zlib zlib-devel pcre pcre-devel libjpeg libjpeg-devel libpng libpng-devel freetype Freetyp E-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel Curl Curl-devel E2fsprogs e2fsprogs-devel OpenSSL openssl-devel openldap openldap-devel openldap-clients openldap-servers Php-mcrypt libmcrypt libmcrypt-devel
3, solve the problem of 64-bit system, compile error: Configure:error:Cannot find LDAP Libraries In/usr/lib
cp-frp/usr/lib64/libldap*/usr/lib/
4, Installation Liviconv
Version 1.15
wget https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15. tar.gz. /configure--prefix=/usr/localmakemake Install
Version 1.13
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1-zxvf libiconv-1.13.1. TAR.GZCD Libiconv -1.13.1. /configure--prefix=/usr/localmakemake Install
Choose one of two versions
Find/-name libiconv.so.2-s/usr/local/lib/libiconv.so.2/usr/lib/libiconv.so.2ldconfig
5. Compiling
Compile configuration instructions:
#Specify the PHP installation directory--prefix=/usr/local/PHP#Specify php.ini location--with-config-file-path=/usr/local/php/etc#MySQL installation directory, support for MySQL--with-MySQL#mysqli Extension technology can not only invoke MySQL's stored procedures, handle MySQL transactions, but also make access to the database work more stable. --with-mysqli=/usr/local/mysql/bin/Mysql_config#The integrated APACHE,APXS function is to use the LoadModule directive in MOD_SO to load the specified module to Apache, which requires Apache to open the so module--with-apxs2=/usr/local/apache/bin/Apxs#The option Directive--with-iconv-dir is used to specify the path of Iconv in the system when PHP is compiled, otherwise the default path is scanned. --with-iconv-dir=/usr/Local--without-Iconv Close Iconv function, conversion between character sets--with-freetype-dir opens support for the FreeType font library--with-jpeg-dir opens support for JPEG images--with-png-dir opens support for PNG images--with-zlib-dir opens support for the Zlib library for HTTP compression transmission--with-libxml-dir open support for LIBXML2 library--with-Curl Opens the Curl Browsing tool support--with-Curlwrappers using the Curl tool to open the URL stream--with-mcrypt mcrypt algorithm extension--with-mhash mhash algorithm extension--with-GD Open the support of GD library--with-support for OpenSSL OpenSSL, encrypted when transmitting HTTPS--WITH-XMLRPC Open xml-RPC's C language--with-bz2 opening support for bz2 files--with-ttf Open freetype1.*of support, can not add--with-XSL opens XSLT file support, expands the LibXML2 library, requires LIBXSLT software--with-GetText Opens the GNU gettext Support, the code library uses the--with-Pear Open the support for Pear command, PHP extension with--with-mime-magic=/usr/share/file/magic.mime Magic Head File location--disable-Rpath to close additional runtime files--disable-Debug off Debugging Mode--enable-Bcmath Open picture resizing, use this module for Zabbix monitoring--enable-shmop--enable-Sysvsem This allows your PHP system to handle the relevant IPC functions. --enable-inline-Optimization Optimizing Threads--enable-Mbregex--ENABLE-FPM hit php-.the FPM patch only has this parameter, and the CGI-style installation of the startup program--enable-mbstring Multi-byte, string support--enable-gd-native-TTF supports TrueType string function libraries--enable-pcntl FreeTDS need to use, may be linked to MSSQL to use--enable-sockets Open Sockets support--enable-zip-open support for zip--enable-FTP Open FTP support--enable-Calendar to open the Calendars extension feature--enable-metadata support for EXIF images--enable-magic-quotes support for Magic quotes#The following are the parameters for CGI mode installation--enable-FastCGI support FastCGI way to start PHP--enable-force-cgi-redirect redirect mode to start PHP--with-ncurses supports ncurses screen drawing and dynamic library based on text terminal's interactive function of graphics--with-GMP should be supportive of a specification--enable-dbase establishes a DBA as a shared module--with-pcre-dir=/usr/local/bin/pcre-Config Perl installation location of the regular library case--disable-Dmalloc--with-GDBM DBA's gdbm support--enable-Sigchild--enable-Sysvshm--enable-zend-multibyte Multi-byte support for Zend--enable-WDDX--enable-soap
Problems:
1. Configure:error:Cannot Find LDAP librariesinch/usr/Lib solution: CP-frp/usr/lib64/libldap*/usr/lib/possible cause is the installation of a 64-bit system, under the LIB64 has this file, may not be in the Lib folder, so force replication once. 2, Configure:error:Cannot find ldap.h, found to be dependent on the OpenLDAP package, solves the problem through Yum: Workaround: Yum install-Y OpenLDAP Install openldap-devel3. Warning:unrecognized options:--enable-discard-path,--enable-safe-mode,--with-curlwrappers,--enable-fastcgi,-- enable-force-cgi-Redirect Workaround: Indicates that the parameter was discarded4. PEAR Package Php_archive notInstalled:generated Phar would require PHP's Phar Extension be enabled.PHP needs to rely on the pear package for compilation, the current problem is wrong"PEAR Package php_archive not installed", the problem has been clearly reported. So the compilation uses the parameters--without-pear will pear shield off after the installation, and then install, and because Phar belongs to a library of pear, so do not shut down Phar, but also reported this error, and need to use--disable-Phar Compile parameters :/configure--without-pear--disable-pharmakemake Install install Pearwget HTTP after the installation is completed successfully:pear.php.net/go-Pear.phar/usr/local/bin/php go-Pear.phar5. Bugs#72663:create An unexpected Object and Don ' t Invoke __wakeup () in deserialization [ext/standard/tests/strings/bug7266 3_3.PHPT] (warn:xfail section but test passes)Direct make install5. ext/xmlrpc/libxmlrpc/.libs/encodings.o:in function ' Convert':/usr/local/php/ext/xmlrpc/libxmlrpc/encodings.c:73:undefined reference to ' Libiconv_open'/usr/local/php/ext/xmlrpc/libxmlrpc/encodings.c:81:undefined reference to ' Libiconv'/usr/local/php/ext/xmlrpc/libxmlrpc/encodings.c:101:undefined reference to ' Libiconv_close'Collect2:ld returned 1Exit Statusmake:[sapi/cli/php] Error 1/usr/local/php/sapi/cli/php:error whileLoading shared Libraries:libiconv.so.2:cannot Open Shared object file:no such fileordirectorymake[1]: * * * [Install-pear-installer] Error 127#Obviously, I can't find the libiconv.so.2 library file Meke install .Make: * * * [install-pear] Error 2#seemingly this error in centos6.x above every compile will error! The workaround is as follows:1. Add a line to the/etc/ld.so.conf/usr/local/Lib,2. Then run/sbin/Ldconfig So it's OK, it's going to find the library file. Bug#52202 (Curlopt_private gets clobbered) [EXT/CURL/TESTS/BUG52202.PHPT]
6.
Make zend_extra_libs='-liconv'
Make Test
Make install
7. Create a proprietary user and group for PHP Www-data
Groupadd www--G www-data www-data-s/sbin/nologin
8, Configuration php-fpm (PHP comes with)
# Modify the default configuration of the PHP-FPM and enable PHP-FPM to run as a www-data User:cd/usr/local/php/etccp php-fpm.conf.default php- Fpm.confvim php-fpm.conf# found and modified to the following line:pid =run/php-=www-= www- Data# Locate and modify the following line listen = 127.0.0.1:9000
9. Start PHP-FPM
/usr/local/php/sbin/php-fpm
10, add php-fpm for system service
Detects if the/usr/local/php/var/run/php-fpm.pid exists:
If it does not exist: remove the semicolon in front of ";p id = run/php-fpm.pid" in/usr/local/php/etc/php-fpm.conf and restart PHP-FPM automatically generate Php-fpm.pid
How to restart the PHP-FPM (of course rebooting the system is also possible):
# View php-fpm Current process Ps-ef | grep php-fpm# end php-fpm All processes to kill-9 process ID# start php-fpm/usr/ local/php/sbin/php-fpm
New PHP-FPM File
vim/etc/init.d/php-fpm
Add content as follows
#!/bin/sh#Comments to support Chkconfig on CentOS#chkconfig:2345-Notoginseng#Set-e PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/Bindesc="php-fpm Daemon"NAME=php-Fpmdaemon=/usr/local/php/sbin/$NAME configfile=/usr/local/php/etc/php-Fpm.confpidfile=/usr/local/php/var/run/$NAME. Pidscriptname=/etc/init.d/$NAME#Gracefully Exit If the package has been removed.Test-x $DAEMON | |exit 0 D_start () {$DAEMON-Y $CONFIGFILE | | Echo-n"already running"} d_stop () {Kill-quit ' Cat $PIDFILE ' | | Echo-n"Not running"} d_reload () {Kill-hup ' Cat $PIDFILE ' | | Echo-n"can ' t reload"} case" $" inchstart) echo-N"starting $DESC is success"D_start Echo"." ;; Stop) Echo-N"stopping $DESC is success"D_stop Echo"." ;; Reload) echo-N"Reloading $DESC Configuration ..."D_reload Echo"Reloaded." ;; Restart) echo-N"restarting $DESC is success"D_stop Sleep1D_start Echo"." ;; *) echo"Usage: $SCRIPTNAME {start|stop|restart|force-reload}">&2Exit3 ;; Esac
Modify its permissions and boot up
# Modify Permissions chmod 755/etc/init.d/php-fpm# boot up chkconfig php-fpmon# View boot-up services chkconfig--list
11. Start
# Start service php-fpm start# stop service php-fpm stop# Restart service php-fpm Reload
12. Installing Nginx
Yum Install Nginx-y
13. Nginx Configuration
Server {Listen80; server_name www.baidu.com;root/www/web/pc; Index index.php; Location/ { #root/www/web/pc; #index index.php;} error_page500 502 503 504/50x.html; Location= /50x.html {root/usr/share/nginx/html; } Location~\.php$ {fastcgi_pass127.0.0.1:9000; Fastcgi_index index.php; Fastcgi_param script_filename $document _root$fastcgi_script_name; Include Fastcgi_params; } Location~ /\.ht {deny all; }}
14. Start Nginx
# Check Syntax /usr/sbin/nginx-t# launch /usr/sbin/nginx# reboot/ Usr/sbin/nginx-s Reload
15. Web Directory Permissions Configuration
# View php-fpm, Nginx user PS aux| grep nginxps aux|grep php-fpm#php-fpm user cannot be the owner of the web directory, least privilege principle Web rwx r--rX Root VUser cache rwx rwx rwx root root
centos6.8 server configuration compile and install PHP, configure Nginx