First, compile and install php5.6.30
Installation Environment:
# cat/etc/redhat-release CentOS Release 6.8 (Final)
#/application/nginx/sbin/nginx-vnginx version:nginx/1.6.3
Download php5.6.30 installation package
wget http://cn2.php.net/distributions/php-5.6.30.tar.bz2
Extract
TAR-XJF php-5.6.30.tar.bz2
Install the required dependency packages
# Rpm-qa Zlib-devel libxm12-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel freetype-devel libpng-devel Libpng-devel gd-devel libcurl-devel libxslt-devel# yum install zlib-devel libxm12-devel libjpeg-devel Libjpeg-turbo-devel libiconv-devel freetype-devel libpng-devel libpng-devel gd-devel libcurl-devel libxslt-devel-y
Installing the Libiconv Library
Wget tar zxf libiconv-1.14.tar.gz cd libiconv-1.14./configure--prefix=/usr/local/libiconvmakemake install
Start installing PHP
[Root@darius php-5.6.30]#./configure--prefix=/application/php5.6.30--with-mysql=mysqlnd--with-mysqli=mysqlnd-- With-pdo-mysql=mysqlnd--with-iconv-dir=/usr/local/libiconv--with-freetype-dir--with-jpeg-dir--with-png-dir-- With-zlib--with-libxml-dir=/usr--enable-xml--disable-rpath--enable-bcmath--enable-shmop --enable-sysvsem-- Enable-inline-optimization--with-curl--enable-mbregex--enable-fpm --enable-mbstring--with-mcrypt--WITH-GD- -enable-gd-native-ttf--with-openssl--with-mhash --enable-pcntl--enable-sockets--with-xmlrpc--enable-zip-- Enable-soap--enable-short-tags --enable-static--with-xsl--with-fpm-user=nginx--with-fpm-group=nginx-- Enable-ftp--without-pear --disable-phar #因为本机没有pear包, so choose temporarily skip (--without-pear--disable-phar), After the installation of PHP and then replace the Go-pear
Make compilation
[Root@darius php-5.6.30]# make ..... Build complete. Don ' t forget to run ' make test '. [Root@darius php-5.6.30]# make Test
The result of make test reported some problems, I ignored, continue to install the
Execute make Install
[Root@darius php-5.6.30]# make installinstalling shared extensions:/application/php5.6.30/lib/php/extensions/ no-debug-non-zts-20131226/installing php cli binary:/application/php5.6.30/bin/installing php CLI man page:/ application/php5.6.30/php/man/man1/installing php fpm binary:/application/php5.6.30/sbin/installing php fpm Config :/application/php5.6.30/etc/installing php FPM man page:/application/php5.6.30/php/man/man8/installing php F PM Status page:/application/php5.6.30/php/php/fpm/installing php CGI binary:/application/php5.6.30/bin/installi ng PHP CGI man page:/application/php5.6.30/php/man/man1/installing build Environment:/application/php5.6.30/lib /php/build/installing header files:/application/php5.6.30/include/php/installing helper Programs:/applic Ation/php5.6.30/bin/program:phpize program:php-configinstalling man pages:/application/php5.6.30/php/man /man1/page:phpize.1 page:php-config.1installing PDO headers:/application/php5.6.30/include/php/ext/pdo/
Second, configure PHP
CP Php.ini-production/usr/local/php/etc/php.ini #复制php配置文件到安装目录rm-rf/etc/php.ini #删除系统自带配置文件ln-S/usr/local/php/ Etc/php.ini/etc/php.ini #添加软链接到/etc Directory cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf # Copy template file for PHP-FPM profile ln-s/usr/local/php/etc/php-fpm.conf/etc/php-fpm.conf #添加软连接到/etc Directory
Modify Php-fpm.conf
PID = Run/php-fpm.pid #取消前面的分号
Modify Php-ini.conf
Found: disable_functions=
Modified to:
Disable_functions = Passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_ Alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server, Escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space, POSIX_CTERMID,POSIX_GET_LAST_ERROR,POSIX_GETCWD, Posix_getegid,posix_geteuid,posix_getgid, Posix_getgrgid,posix_ Getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, Posix_getppid,posix_getpwnam, Posix_getpwuid, Posix_getrlimit, Posix_getsid,posix_getuid,posix_isatty, Posix_kill,posix_mkfifo,posix_setegid, Posix_seteuid,posix_setgid, Posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname, Posix_uname
#列出PHP可以禁用的函数, if some programs need to use this function, you can delete, cancel disable.
Found:;d Ate.timezone =
Modified to:
Date.timezone = PRC #设置时区
Found: expose_php = On
Modified to:
expose_php = Off #禁止显示php版本的信息
Found: Short_open_tag = Off
Modified to:
Short_open_tag = on #支持php短标签
Note: The Short_open_tag must be turned on. You can use the segment label for PHP after you open it: (). At the same time, only open this can use <?= to replace < Echo. Some open source systems will use short tags, if not open will be an error.
Find Opcache.enable=0
Revision changed to
Opcache.enable=1 #php支持opcode缓存
Found in:; Opcache.enable_cli=1 #php支持opcode缓存
Modified to:
Opcache.enable_cli=0
On the last line add:
Zend_extension=opcache.so #开启opcode缓存功能
: Wq #保存退出
Configure nginx.conf
Location ~ \.php$ { root Html/bbs; #你网页根目录 fastcgi_pass 127.0.0.1:9000; Fastcgi_index index.php; Fastcgi_param script_filename $document _root$fastcgi_script_name; Include Fastcgi_params;}
To create a test file:
[Root@darius bbs]# cat index.php <?php phpinfo ();? >[root@darius bbs]# cat index.html Bbs.html[root@darius bbs]# pwd /application/nginx/html/bbs
Start php-fpm, restart Nginx, and test the results
/application/php/sbin/php-fpm-c/application/php/etc/php.ini-y/application/php/etc/php-fpm.conf
/application/nginx/sbin/nginx-s Reload