Linux下LNMP环境搭建(PHP-5.4.37的源码安装)
lnmp环境搭建第二步:php的安装
1.下载:
cd /usr/local/src
wget http://cn2.php.net/distributions/php-5.4.37.tar.bz2
tar jxvf php-5.4.37.tar.bz2
useradd -s /sbin/nologin -M php-fpm
cd php-5.4.37
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --disable-ipv6 --with-curl
过程中遇到的错误:
yum install -y libxml2-devel openssl-devel bzip2-devel libpng-devel libjpeg-devel freetype-devel curl-devel
因为centos6.x 默认的yum源没有libmcrypt-devel 这个包,只能借助第三方yum源。
rpm -ivh "http://www.lishiming.net/data/attachment/forum/month_1211/epel-release-6-7.noarch.rpm"
yum install -y libmcrypt-devel
make && make install
cp php.ini-production /usr/local/php/etc/php.ini
拷贝启动脚本cp /usr/local/src/php-5.4.37/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
mv /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
chmod 755 /etc/init.d/php-fpm
chkconfig --add php-fpm
chkconfig php-fpm on
service php-fpm start
稳定的epel源
1、 首先卸载以前装的epel 以免影响rpm -e epel-release
2、 下载阿里提供的epelwget -P /etc/yum.repos.d/ http://mirrors.aliyun.com/repo/epel-6.repo
3、yum clean all
4、yum makecache
全部改成阿里云的源 由于服务器为阿里云,速度还是不错的
1、rm -rf /etc/yum.repos.d/*
(执行此操作的时候记得事先装好wget 不然 你就得挂载光盘用rpm装wget了。)
2、wget -P /etc/yum.repos.d/ http://mirrors.aliyun.com/repo/epel-6.repo http://mirrors.aliyun.com/repo/Centos-6.repo
这个时候,执行 yum repolist的结果如下yum repolist
- base: mirrors.aliyun.com
- epel: mirrors.ustc.edu.cn
- extras: mirrors.aliyun.com
- updates: mirrors.pubyun.com