[Fedora开发环境搭建]搭建LNMP开发环境

左手 posted @ 2012年11月04日 17:15 in Linux with tags linux fedora17 php 编译php lnmp , 1354 阅读

Fedora17上能找到的PHP最低版本为5.4.x。因公司项目开发较早,仅能在上5.3.x上面正常运行,所以php采用编译方式安装,nginx、mysql使用源来安装。

1.安装nginx、mysql并设置自动启

sudo yum install nginx mysql mysql-server
 
sudo systemctl enable nginx.service
sudo systemctl start nginx.service
 
sudo systemctl enable mysqld.service
sudo systemctl start mysqld.service

2.安装基础库

yum install \
autoconf \
xmllib2-devel \
curl-devel \
libjpeg-devel \
libpng-devel \
freetype-devel \
mysql-devel \
gcc \
gcc-c++ \
zlib \
zlib-devel \
make \
autoconf \
automake \
libxml2-devel

 

3.下载源代码包

cd /usr/local/src
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
wget http://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
wget http://nchc.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz
wget http://nchc.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz
wget http://nchc.dl.sourceforge.net/project/pcre/pcre/8.30/pcre-8.30.tar.gz
wget http://pecl.php.net/get/APC-3.1.9.tgz
wget http://cn.php.net/distributions/php-5.3.17.tar.gz

 

4.编译

tar zxvf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local
make
make install
 
cd ../
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure
make
make install
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
make
make install
cd ../../
 
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make
make install
cd ../

#建立软链接
ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
#如果是64位系统加上这一句
ln -s /usr/lib64/mysql /usr/lib
 
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make
make install
cd ../
 
tar zxvf pcre-8.30.tar.gz
cd pcre-8.30
./configure
make && make install
cd ../
 
编译php
tar zvxf php-5.3.17.tar.gz
cd php-5.3.17
配置参数
./configure \
--prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--with-config-file-scan-dir=/usr/local/php/etc/conf.d \
--with-mysql=/usr \
--with-iconv-dir=/usr/local \
--with-freetype-dir \
--with-jpeg-dir \
--with-zlib \
--with-libxml-dir=/usr \
--enable-xml \
--disable-rpath \
--enable-discard-path \
--enable-safe-mode \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--with-curlwrappers \
--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-zip \
--enable-soap \
--with-pdo-mysql=/usr \
--with-mysql-sock=/var/lib/mysql/mysql.sock

#编译
make ZEND_EXTRA_LIBS='-liconv'
make install
#复制配置文件
cp php.ini-production /usr/local/php/etc/php.ini

#配置php-fpm
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm #因为php5.3开始自带fpm,使用自带的管理脚本
chmod +x /etc/init.d/php-fpm
chkconfig php-fpm on #设置开机自启动
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
#修改 php-fpm.conf
sudo vim /usr/local/php/etc/php-fpm.conf
修改  ;pid = run/php-fpm.pid 为  pid = run/php-fpm.pid (去掉前面的分号)
 
添加apc扩展
cd /usr/local/src
tar -zxvf APC-3.1.9.tgz
cd APC-3.1.9
/usr/local/php/bin/phpize
./configure --enable-apc --enable-apc-mmap --with-php-config=/usr/local/php/bin/php-config
make
make install

添加apc扩展
sudo mkdir /usr/local/php/etc/conf.d
sudo vim /usr/local/php/etc/conf.d/apc.ini
添加以内容
extension = "apc.so"
apc.enabled = 1
apc.cache_by_default = on
apc.shm_segments = 1
apc.shm_size = 32M
apc.ttl = 3600
apc.user_ttl = 3600
apc.num_files_hint = 0
apc.write_lock = On
 

 

 

参考链接:http://solf.me/compile-nginx-php-mysql-on-centos-lnmp/

 


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter