Centos6.4 编译安装 nginx php
一. 準(zhǔn)備依賴庫
安裝make:
yum -y install gcc automake autoconf libtool make安裝g++:
yum install gcc gcc-c++二. 編譯安裝pcre
pcre 是一個正則表達(dá)式的庫,編譯nginx需要依賴該庫實現(xiàn)url rewrite
下載源碼
cd /usr/local/src wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.33.tar.bz2 tar jxvf pcre-8.33.tar.bz2編譯安裝
cd pcre-8.33 ./configure make make install三. 編譯安裝zlib庫
zlib 是gzip實現(xiàn)
下載源碼
cd /usr/local/src wget http://zlib.net/zlib-1.2.8.tar.gz tar -zxvf zlib-1.2.8.tar.gz編譯安裝
cd zlib-1.2.8./configure make make install
四. 安裝openssl
檢查是否安裝了ssl
# rpm -qa|grep openssl openssl-devel-1.0.1e-16.el6_5.14.x86_64 openssl-1.0.1e-16.el6_5.14.x86_64如果沒有安裝
下載源碼
cd /usr/local/src wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz tar -zxvf openssl-1.0.1c.tar.gz編譯安裝
./configure make make install五. 編譯安裝nginx
cd /usr/local/src wget http://nginx.org/download/nginx-1.2.8.tar.gz tar -zxvf nginx-1.2.8.tar.gz cd nginx-1.2.8? ./configure --sbin-path=/usr/local/nginx/nginx \
? --conf-path=/usr/local/nginx/nginx.conf \
? --pid-path=/usr/local/nginx/nginx.pid \
? --with-http_ssl_module \
? --with-pcre=/usr/local/src/pcre-8.33 \
? --with-zlib=/usr/local/src/zlib-1.2.8 \
? --with-openssl=/usr/local/src/openssl-1.0.1c
? make
? make install
安裝成功完畢后驗證是否安裝成功
/usr/local/nginx/nginx netstat -alptn|grep 80六. 編譯安裝php
新版本的php中已經(jīng)集成了php-fpm?
1. 準(zhǔn)備工作
yum -y install libmcrypt-devel mhash-devel libxslt-devel\libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel\zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel\ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel\krb5 krb5-devel libidn libidn-devel openssl openssl-devel2. 源碼編譯安裝libmcrypt
wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gz tar -zxvf libmcrypt-2.5.7.tar.gz cd libmcrypt-2.5.7 ./configure make make install3. 下載源碼
wget http://cn2.php.net/distributions/php-5.4.7.tar.gz tar zvxf php-5.4.7.tar.gz4. 編譯安裝cd php-5.4.7
./configure --prefix=/usr/local/php \--enable-fpm \
--enable-mbstring \
--enable-sockets \
--enable-sysvsem \
--enable-sysvshm \
--enable-pcntl \
--enable-mbregex \
--enable-zip \
--enable-inline-optimization \
--disable-pdo \
--disable-debug \
--disable-rpath \
--with-mcrypt \
--with-zlib \
--with-bz2 \
--with-mhash \
--with-curl \
--with-mysql \
--with-gd \
--with-pcre-regex \
--with-libdir=lib64
如果報如下錯誤
configure: error: Don't know how to define struct flock on this system, set --enable-opcache=no修改 /etc/ld.so.conf 文件
vi /etc/ld.so.conf.d/local.conf #添加2行/usr/local/lib64 //64系統(tǒng)
/usr/local/src/libmcrypt-2.5.7/lib/.libs
#執(zhí)行以下命令
chmod gu+x /etc/ld.so.conf.d/local.conf #執(zhí)行以下命令使生效
ldconfig?-v
再次執(zhí)行命令
成功后編譯安裝
七. 配置啟動
1. 配置php-fpm
cd /usr/local/php cp /etc/php-fpm.conf.default /etc/php-fpm.conf vi /etc/php-fpm.conf修改
user = llong
group = llong
2. 修改nginx 支持 php-fpm
打開 nginx.conf?
其中server段增加如下配置,注意標(biāo)紅內(nèi)容配置,否則會出現(xiàn)No input file specified.錯誤
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }3. 測試是否配置成功
在/usr/local/nginx/html下創(chuàng)建index.php文件,輸入如下內(nèi)容
<? echo phpinfo(); ?>啟動php-fpm和nginx
/usr/local/php/sbin/php-fpm (手動打補丁的啟動方式/usr/local/php/sbin/php-fpm start)/usr/local/nginx/nginx?
?
總結(jié)
以上是生活随笔為你收集整理的Centos6.4 编译安装 nginx php的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。