环境
PHP安装前准备 先将需要的软件包如下位置放置。另外需要有WWW用户 参照nginx
满足以上条件后执行安装脚本
PHP安装脚本:
#!/bin/bash
#install PHP
#author Nod
#进入软件包目录
cd /server/tools/
#解压
tar xf php-5.5.32.tar.gz
#安装对应的依赖包
yum install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel -y
#安装lib
cd /server/tools
tar zxf libiconv-1.14.tar.gz
cd libiconv-1.14
#编译环境
./configure --prefix=/usr/local/libiconv
make && make install
yum -y install libmcrypt-devel mhash mcrypt
#开始安装php
cd /server/tools/
tar xf php-5.5.32.tar.gz
ln -s /application/mysql/lib/libmysqlclient.so.18 /usr/lib64/
cd /server/tools/php-5.5.32
touch /server/tools/php-5.5.32/ext/phar/phar.phar
#编译环境
./configure \
--prefix=/application/php-5.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 && make install #配置文件处理
ln -s /application/php-5.5.32/ /application/php
cp /server/tools/php-5.5.32/php.ini-production /application/php/lib/php.ini
cp /application/php/etc/php-fpm.conf.default /application/php/etc/php-fpm.conf #启动服务
/application/php/sbin/php-fpm
安装完成后 PHP默认占用的端口为9000
[root@web02 scripts]# netstat -lntup | grep php
tcp 0 0 127.0.0.1: 0.0.0.0:* LISTEN 1500/php-fpm