nginx +php 编译

原创 2015年11月18日 16:46:48


【1】      编译PHP

初始环境:

为了省事把所需要的库文件全都安装上,可以使用rpm包安装,也可以用yum命令安装,

 

yum -y install gcc gcc-c++ autoconf libjpeglibjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-develzlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncursesncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidnlibidn-devel openssl openssl-devel openldap openldap-devel nss_ldapopenldap-clients openldap-servers

 

#nginx所需要的库文件件

 

yum -y install pcre-devel zlib-devel

 

#PHP依赖的库文件

yum -y install gd-devel libjpeg-devel libpng-develfreetype-devel libxml2-devel curl-devel

 

cp -frp/usr/lib64/libldap* /usr/lib/(有就执行 没有就跳过)

安装库文件

tar zxvf libiconv-1.14.tar.gz 

cd libiconv-1.14 

./configure --prefix=/usr/local

make && make install

 

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

 

tar zxvf mhash-0.9.9.9.tar.gz  

cd mhash-0.9.9.9/  

./configure 

make && make install

 

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

 

 

tar -zxvf mcrypt-2.6.8.tar.gz  

cd mcrypt-2.6.8/ 

/sbin/ldconfig 

./configure 

make && make install

 

mkdir -p /usr/local/php5.4 

 

tar zxvf php-5.4.13.tar.gz 

 

cd php-5.4.13

 

为避免编译出现错误需要加入如下几句

export LIBS="-lm -ltermcap -lresolv"
export DYLD_LIBRARY_PATH="
/usr/local/mysql5.5/lib/:/lib/:/usr/lib/:/usr/local/lib:/lib64/:/usr/lib64/:/usr/local/lib64"
export LD_LIBRARY_PATH="/
usr/local/mysql5.5/lib/:/lib/:/usr/lib/:/usr/local/lib:/lib64/:/usr/lib64/:/usr/local/lib64"

 

 

./configure --prefix=/usr/local/php5.4 \ 

--with-config-file-path=/etc \ 

--with-iconv-dir=/usr/local/ --with-freetype-dir\ 

--with-mysql=/usr/local/mysql5.5 \ 

--with-mysqli=/usr/local/mysql5.5/bin/mysql_config\ 

--with-jpeg-dir --with-png-dir --with-zlib \ 

--with-mhash --enable-sockets --enable-ftp \ 

--with-libxml-dir --enable-xml --disable-rpath \ 

--enable-bcmath \ 

--enable-shmop --enable-sysvsem \ 

--enable-inline-optimization --with-curl \ 

--with-curlwrappers \ 

--enable-mbregex \ 

--enable-mbstring --with-mcrypt --with-gd \ 

--enable-gd-native-ttf --with-openssl --with-mhash\ 

--enable-pcntl --enable-sockets --with-ldap--with-ldap-sasl \ 

--enable-fpm \ 

--with-xmlrpc --enable-zip --enable-soap \ 

--without-pear  

./configure --prefix=/usr/local/php5.4--with-config-file-path=/etc --with-iconv-dir=/usr/local/ --with-freetype-dir--with-mysql=/usr/local/mysql5.5--with-mysqli=/usr/local/mysql5.5/bin/mysql_config --with-jpeg-dir--with-png-dir --with-zlib --with-mhash --enable-sockets --enable-ftp--with-libxml-dir --enable-xml --disable-rpath --enable-bcmath --enable-shmop--enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers--enable-mbregex --enable-mbstring --with-mcrypt --with-gd--enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl--enable-sockets --with-ldap --with-ldap-sasl --enable-fpm --with-xmlrpc--enable-zip --enable-soap --without-pear

 

make ZEND_EXTRA_LIBS='-liconv' //不能直接用make

make install

 

cp php.ini-production /etc/php.ini

 

php-fpm 作为服务运行

 

cp php-5.4.13/sapi/fpm/init.d.php-fpm  /etc/init.d/php-fpm

cd /usr/local/php5.4/etc

mv php-fpm.conf.default  php-fpm.conf

chmod 755 /etc/init.d/php-fpm

chkconfig --add php-fpm

chkconfig --level 345 php-fpm on

服务方式启动php-fpm

service php-fpm start

若出现

Starting php-fpm /usr/local/php5.4/sbin/php-fpm: errorwhile loading shared libraries: libmysqlclient.so.18: cannot open shared objectfile: No such file or directory

 Failed

echo"/usr/local/mysql/lib" >>/etc/ld.so.conf
ldconfig

 

2编译Nginx

useradd www

安装pcre

tar zxvf pcre-8.32.tar.gz

cd pcre-8.32/

./configure --prefix=/usr/local/pcre

make && make install

安装nginx

tar zxvf nginx-1.0.15.tar.gz

cd nginx-1.0.15/

./configure --user=www --group=www--prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module--with-http_gzip_static_module --with-ipv6

make && make install

 

相关文章推荐

php + nginx 编译安装

linux下编译 nginx+php7 以及遇到的问题
  • demored
  • demored
  • 2017年01月06日 13:34
  • 622

ubuntu编译安装PHP5.4.0+Nginx(FPM/FastCGI)

PHP5.4.0发布了,添加了很多新特性,于是今天在ubuntu下编译安装了PHP5.4+Nginx1.0.13+Memcache,让PHP 以fastcgi模式运行。MySQL就不装了用以前的5....

php7+nginx编译后的

  • 2017年04月03日 15:30
  • 52.86MB
  • 下载

CentOS6.3下编译安装配置nginx1.2.3+php5.3.16+mysql5.5.27+memcached1.4.5

Nginx ("engine x") 是一个高性能的 HTTP 和反向代理服务器,也是一个 IMAP/POP3/SMTP 代理服务器。 Nginx 是由 Igor Sysoev 为俄罗斯访问量第二的 ...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:nginx +php 编译
举报原因:
原因补充:

(最多只允许输入30个字)