主機環境 redhat6.5 64位php
實驗環境 服務端 ip172.25.29.1 phphtml
安裝包 php-5.6.20.tar.bz2mysql
re2c-0.13.5-1.el6.x86_64.rpmnginx
libmcrypt-2.5.8-9.el6.x86_64.rpmsql
libmcrypt-devel-2.5.8-9.el6.x86_64.rpm數據庫
Discuz_X3.2_SC_UTF8.zipvim
1. 安裝php api
1.解壓curl
[root@server1 mnt# tar jxf php-5.6.20.tar.bz2 #解壓socket
[root@server1 php-5.6.20]# rpm -vih libmcrypt-* #安裝libmcrypt庫
[root@server1 php-5.6.20]# yum installre2c-0.13.5-1.el6.x86_64.rpm –y #安裝re2c
2.軟件配置
[root@server1 php-5.6.20]# ./configure --prefix=/usr/local/lnmp/php--with-config-file-path=/usr/local/lnmp/php/etc --with-openssl --with-snmp--with-gd --with-zlib --with-curl --with-libxml-dir --with-png-dir--with-jpeg-dir --with-freetype-dir --with-gettext --without-pear --with-gmp--enable-inline-optimization --enable-soap --enable-ftp --enable-sockets--enable-mbstring --with-mysqli --with-mysql --with-pdo-mysql --enable-fpm--with-fpm-user=nginx --with-fpm-group=nginx --with-mcrypt --with-mhash
若是出現以下錯誤
[root@server1 php-5.6.20]# yum install libxml2-devel -y
從新配置
[root@server1 php-5.6.20]# ./configure--prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc--with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir--with-png-dir --with-jpeg-dir --with-freetype-dir --with-gettext--without-pear --with-gmp --enable-inline-optimization --enable-soap--enable-ftp --enable-sockets --enable-mbstring --with-mysqli --with-mysql--with-pdo-mysql --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx--with-mcrypt --with-mhash
若是出現以下錯誤
[root@server1 php-5.6.20]# yum provides */easy.h
[root@server1 php-5.6.20]# yum install -ylibcurl-devel-7.19.7-37.el6_4.x86_64
從新配置
[root@server1 php-5.6.20]# ./configure--prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc--with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir--with-png-dir --with-jpeg-dir --with-freetype-dir --with-gettext--without-pear --with-gmp --enable-inline-optimization --enable-soap--enable-ftp --enable-sockets --enable-mbstring --with-mysqli --with-mysql--with-pdo-mysql --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx--with-mcrypt --with-mhash
若是出現以下錯誤
[root@server1 php-5.6.20]# yum provides */jpeglib.h
[root@server1 php-5.6.20]# yum install -ylibjpeg-turbo-devel-1.2.1-1.el6.x86_64
從新配置
[root@server1 php-5.6.20]# ./configure--prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc--with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir--with-png-dir --with-jpeg-dir --with-freetype-dir --with-gettext--without-pear --with-gmp --enable-inline-optimization --enable-soap--enable-ftp --enable-sockets --enable-mbstring --with-mysqli --with-mysql--with-pdo-mysql --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx--with-mcrypt --with-mhash
若是出現以下錯誤
[root@server1 php-5.6.20]# yum provides */png.h
[root@server1 php-5.6.20]# yum install -ylibpng-devel-1.2.49-1.el6_2.x86_64
從新配置
[root@server1 php-5.6.20]# ./configure--prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc--with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir--with-png-dir --with-jpeg-dir --with-freetype-dir --with-gettext--without-pear --with-gmp --enable-inline-optimization --enable-soap--enable-ftp --enable-sockets --enable-mbstring --with-mysqli --with-mysql--with-pdo-mysql --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx--with-mcrypt --with-mhash
若是出現以下錯誤
[root@server1 php-5.6.20]# yum install -y freetype-devel
從新配置
[root@server1 php-5.6.20]# ./configure--prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc--with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir--with-png-dir --with-jpeg-dir --with-freetype-dir --with-gettext--without-pear --with-gmp --enable-inline-optimization --enable-soap--enable-ftp --enable-sockets --enable-mbstring --with-mysqli --with-mysql--with-pdo-mysql --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx--with-mcrypt --with-mhash
若是出現以下錯誤
[root@server1 php-5.6.20]# yum provides */gmp.h
[root@server1 php-5.6.20]# yum install -y gmp-devel-4.3.1-7.el6_2.2.x86_64
從新配置
[root@server1 php-5.6.20]# ./configure--prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc --with-openssl--with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir --with-png-dir--with-jpeg-dir --with-freetype-dir --with-gettext --without-pear --with-gmp--enable-inline-optimization --enable-soap --enable-ftp --enable-sockets--enable-mbstring --with-mysqli --with-mysql --with-pdo-mysql --enable-fpm--with-fpm-user=nginx --with-fpm-group=nginx --with-mcrypt --with-mhash
若是出現以下錯誤
[root@server1 php-5.6.20]# yum install -y net-snmp-devel
從新配置
[root@server1 php-5.6.20]# ./configure--prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc--with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir--with-png-dir --with-jpeg-dir --with-freetype-dir --with-gettext--without-pear --with-gmp --enable-inline-optimization --enable-soap--enable-ftp --enable-sockets --enable-mbstring --with-mysqli --with-mysql--with-pdo-mysql --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx--with-mcrypt --with-mhash
3.編譯、連接、安裝
[root@server1 php-5.6.20]# make #編譯
[root@server1 php-5.6.20]# make install #安裝
2.php的簡單配置
[root@server1 php-5.6.20]# cd /usr/local/lnmp/php/etc/
[root@server1 etc]# ls
php-fpm.conf.default
[root@server1 etc]# cp php-fpm.conf.default php-fpm.conf #備份php的文件
[root@server1 etc]# ls
php-fpm.conf php-fpm.conf.default
[root@server1 etc]# cp /mnt/php-5.6.20/php.ini-production php.ini #php的配置文件
[root@server1 etc]# ls
php-fpm.conf php-fpm.conf.default php.ini
若是要鏈接數據庫,就作如下修改
[root@server1 etc]# vim php.ini
925 date.timezone = Asia/Shanghai #修改時區
1001 pdo_mysql.default_socket=/usr/local/lnmp/mysql/data/mysql.sock #指定鏈接數據庫的sock文件的路徑
1150 mysql.default_socket = /usr/local/lnmp/mysql/data/mysql.sock #同上
1209 mysqli.default_socket =/usr/local/lnmp/mysql/data/mysql.sock #同上
[root@server1 etc]# vim php-fpm.conf
25 pid = run/php-fpm.pid #將pid的標記去掉
[root@server1 etc]# cd /mnt/php-5.6.20/sapi/fpm/
[root@server1 fpm]# cp init.d.php-fpm /etc/init.d/php-fpm #添加啓動命令
[root@server1 fpm]# chmod +x /etc/init.d/php-fpm #添加可執行權限
[root@server1 fpm]# ll /etc/init.d/php-fpm
-rwxr-xr-x 1 root root 2359 Sep 18 00:18 /etc/init.d/php-fpm
[root@server1 fpm]# /etc/init.d/php-fpm start #開啓php服務
Starting php-fpm done
[root@server1 fpm]# cd /usr/local/lnmp/nginx/conf/
[root@server1 conf]# vim nginx.conf
51 root html;
52 index index.php index.html index.htm; #在nginx裏添加默認訪問目錄爲php優先
50 location / {
53 }
75 location ~ \.php$ {
76 root html;
77 fastcgi_pass 127.0.0.1:9000;
78 fastcgi_index index.php;
79 fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
80 include fastcgi.conf; #設置成已存在的文件
81 }
[root@server1 conf]# nginx –t #檢測
[root@server1 conf]# nginx #開啓
[root@server1 conf]# cd ..
[root@server1 nginx]# cd html
[root@server1 html]# vim index.php #寫一個簡單的測試文件
<?php
phpinfo()
?>
[root@server1 html]# /etc/init.d/httpd start #開啓httpd
Starting httpd: [ OK ]
3.測試 172.25.29.1