查看Nginx跟MySQL是否已经启动! -E扩展的正则表达式

[root@web01 ~]# netstat -tunlp | grep -E "nginx|mysql"
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      1476/mysqld         
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      1585/nginx   

安装PHP所需要的lib库以及加密扩展库

[root@web01 ~]# yum install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel -y
[root@web01 ~]# yum install freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel -y
[root@web01 ~]# cd /home/oldboy/tools
[root@web01 tools]# wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
[root@web01 tools]# tar zxf libiconv-1.14.tar.gz
[root@web01 tools]# cd libiconv-1.14
[root@web01 libiconv-1.14]# ./configure --prefix=/usr/local/libiconv
[root@web01 libiconv-1.14]# make
[root@web01 libiconv-1.14]# make install
[root@web01 libiconv-1.14]# wget -O /etc/yum.repos.d/epel.repo http://mirrirs.aliyun.com/repo/epel-6.repo
[root@web01 libiconv-1.14]# yum install -y libmcrypt-devel
[root@web01 libiconv-1.14]# yum install -y mhash
[root@web01 libiconv-1.14]# yum install -y mcrypt

下载PHP软件包,并配置PHP软件
特别注意!
(1)每个配置中的 “\”反斜线表示换行,后面不能有空白!
(2)最后一行没有反斜线!
(3)--prefix=/application/php5.5.32 是指定PHP安装的路径
(4)--with-mysql=/application/mysql/ 是指定MySQL的安装路径。若没有安装MySQL可以用--with-mysql=mysqlnd替代!
(5)--with-fpm-user 跟--with-fpm-group是PHP-FPM的进程管理的组和用户,尽量跟Nginx用户和组一致!
(6)--enable-fpm 是启动PFP-FPM服务,以FastCGIF方式运行PHP服务。

cd /home/oldboy/tools/
wget http://mirrors.sohu.com/php/php-5.5.32.tar.gz
tar zxf php-5.5.32.tar.gz
cd /home/oldboy/tools/php-5.5.32

./configure \
--prefix=/application/php5.5.32 \
--with-mysql=/application/mysql/ \
--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-soap \
--enable-short-tags \
--enable-static \
--with-xsl \
--with-fpm-user=www \
--with-fpm-group=www \
--enable-ftp \
--enable-opcache=no

在make之前,要先做这两步!

[root@web01 tools]# ln -s /application/mysql/lib/libmysqlclient.so.18 /usr/lib64/
[root@web01 tools]# cd php-5.5.32
[root@web01 php-5.5.32]# touch ext/phar/phar.phar
[root@web01 php-5.5.32]# make

结果出现这样,表示编译成功了!

Generating phar.php
Generating phar.phar
PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.
directorytreeiterator.inc
clicommand.inc
directorygraphiterator.inc
pharcommand.inc
invertedregexiterator.inc
phar.inc

Build complete.
Don't forget to run 'make test'.

[root@web01 php-5.5.32]# echo $?
0

[root@web01 php-5.5.32]# make install

make install 成功结束后,最后两行内容如下:

ln -s -f phar.phar /application/php5.5.32/bin/phar
Installing PDO headers:          /application/php5.5.32/include/php/ext/pdo/
[root@web01 php-5.5.32]# ln -s /application/php5.5.32/ /application/php
[root@web01 php-5.5.32]# ls /application/php
bin  etc  include  lib  php  sbin  var
[root@web01 php-5.5.32]# cp php.ini-production /application/php/lib/php.ini
[root@web01 php-5.5.32]# ls -l /application/php/lib/php.ini 
-rw-r--r-- 1 root root 69266 Mar 10 11:45 /application/php/lib/php.ini
[root@web01 php-5.5.32]# cd /application/php/etc/
[root@web01 etc]# ls
pear.conf  php-fpm.conf.default
[root@web01 etc]# cp php-fpm.conf.default php-fpm.conf
[root@web01 etc]# /application/php/sbin/php-fpm 
[root@web01 etc]# lsof -i :9000
COMMAND  PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
php-fpm 4347 root    7u  IPv4 117912      0t0  TCP localhost:cslistener (LISTEN)
php-fpm 4348  www    0u  IPv4 117912      0t0  TCP localhost:cslistener (LISTEN)
php-fpm 4349  www    0u  IPv4 117912      0t0  TCP localhost:cslistener (LISTEN)
[root@web01 etc]# ps -ef | grep php-fpm
root       4347      1  0 11:50 ?        00:00:00 php-fpm: master process (/application/php5.5.32/etc/php-fpm.conf)
www        4348   4347  0 11:50 ?        00:00:00 php-fpm: pool www            
www        4349   4347  0 11:50 ?        00:00:00 php-fpm: pool www            
root       4352   1555  0 11:50 pts/1    00:00:00 grep php-fpm