lnmp环境中,php算是最难安装的一个了,之前各种鼓捣搞了好多次,查阅了无数资料才终于有点经验了,记录下来。
一、安装依赖项
php的依赖项相当多,大部分都是运行环境需要的库环境。有的直接yum
就能安装,有的就需要手动编译安装了。反正一个原则:能用yum安装的尽量用yum。
yum install gcc bison bison-devel zlib-devel libmcrypt-devel mcrypt mhash-devel \
openssl-devel libxml2-devel libcurl-devel bzip2-devel readline-devel libedit-devel \
sqlite-devel jemalloc jemalloc-devel -y
yum install libpng-devel libjpeg-devel libxslt libxslt-devel \
libmcrypt-devel mhash mcrypt -y
手动安装libiconv
:
wget https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz
tar -zxvf libiconv-1.15.tar.gz
cd libiconv-1.15
./configure --prefix=/usr/lib/libiconv
make && make install
cd ..
二、下载安装php
直接在官网下载源码包:
wget http://cn2.php.net/distributions/php-5.6.33.tar.gz
tar -zxvf php-5.6.33.tar.gz
cd php-5.6.33
编译安装的流程和大多数软件一样,只是php的编译选项相当多:
./configure --prefix=/usr/local/php-5.6.33 \
--with-config-file-path=/etc/php \
--enable-fpm \
--with-fpm-user=www \
--with-fpm-group=www \
--disable-debug \
--with-curl \
--with-iconv-dir=/usr/lib/libiconv \
--with-pcre-regex \
--with-zlib \
--enable-bcmath \
--enable-ftp \
--enable-sockets \
--enable-mbstring \
--enable-mbregex \
--with-gd \
--with-jpeg-dir \
--enable-soap \
--with-mcrypt \
--with-xsl \
--enable-zip \
--with-openssl \
--enable-opcache=no \
--with-mysql=/usr/local/mysql \
--disable-fileinfo \
--with-openssl
make && make install
ln -s /usr/local/php-5.6.33/ /usr/local/php
三、配置
在编译的当前目录,不要切换目录执行以下命令:
cp php.ini-production /usr/local/php/lib/php.ini
# php-fpm的配置文件
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
# php-fpm服务的配置文件
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
使用 service php-fpm start
启动php-fpm服务
[ma@ma maqianos.coding.me]$ ps aux | grep php-fpm | grep -v "grep"
root 1114 0.0 0.2 217104 5640 ? Ss Jan13 2:58 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
www 9026 0.0 0.8 241764 17032 ? S Jan22 1:07 php-fpm: pool www
www 23088 0.0 1.1 247872 22900 ? S Jan24 0:30 php-fpm: pool www
www 23091 0.0 1.0 247004 21976 ? S Jan24 0:30 php-fpm: pool www
此处评论已关闭