一、安装前准备
# yum -yinstall gcc gcc-c++ glibcautomake autoconf libtool make
# yum -y install libmcrypt-devel mhash-devel libxslt-devellibjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-develzlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-develncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-develkrb5 krb5-devel libidn libidn-devel openssl openssl-devel
二、PHP-fpm安装
# wgethttp://mirrors.sohu.com/php/php-5.5.36.tar.bz2
# tar jxf PHP-5.5.36.tar.bz2
# cd PHP-5.5.36
# ./configure --prefix=/usr/local/PHP \
--enable-fpm--with-mcrypt--enable-mbstring--disable-pdo \
--with-curl--disable-debug--disable-rpath--enable-inline-optimization \
--with-bz2--with-zlib--enable-sockets--enable-sysvsem --enable-sysvshm \
--enable-pcntl --enable-mbregex--with-mhash --enable-zip --with-pcre-regex \
--with-MysqL --with-MysqLi--with-gd --with-jpeg-dir
# make && make install
# useradd www -M
# cd /usr/local/PHP/
# cp etc/PHP-fpm.default etc/PHP-fpm.conf
# vi etc/PHP-fpm.conf
修改
user = www
group = www
三、编译安装Nginx
@H_404_112@
# yuminstall -y gcc gcc-c++ automake autoconf libtool make
1、安装插件安装包
首先需要安装pcre库,然后再安装Nginx:
#安装pcre支持rewrite库,也可以安装源码,注*安装源码时,指定pcre路径为解压源码的路径,而不是编译后的路径,否则会报错
(make[1]:***[/usr/local/pcre/Makefile]Error127错误)
#yum-yinstallpcre-develpcrezlibzlib-developensslopenssl-devel
或
源码安装PCRE(pcre支持rewrite库)
# cd /usr/local/src ;wgetftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.37.tar.bz2;tar jxf pcre-8.37.tar.bz2 ;cdpcre-8.37 &&./configure --prefix=/usr/local/pcre &&make && make install
源码安装zlib库(zlib支持gzip压缩)
# cd /usr/local/src;wgethttp://zlib.net/zlib-1.2.8.tar.gz;tar zxf zlib-1.2.8.tar.gz ;cd zlib-1.2.8 &&./configure --prefix=/usr/local/zlib && make && make install
安装ssl(某些vps默认没装ssl)
;wgethttp://www.openssl.org/source/openssl-1.0.2d.tar.gz;tar zxf openssl-1.0.2d.tar.gz
2、安装Nginx
# cd /usr/local/src ;wget -chttp://nginx.org/download/nginx-1.8.1.tar.gz;tar -zxf Nginx-1.8.1.tar.gz ;cd Nginx-1.8.1
sed -i -e 's/1.8.1/g' -e 's/Nginx\//WS/g' -e's/"Nginx"/"WS"/g' src/core/Nginx.h
预编译Nginx
# useradd www;./configure--prefix=/usr/local/Nginx \
--user=www\
--group=www \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-pcre=/usr/local/src/pcre-8.37 \
--with-zlib=/usr/local/src/zlib-1.2.8 \
--with-openssl=/usr/local/src/openssl-1.0.2d
注意:
--with-pcre=/usr/local/src/pcre-8.37 指的是pcre-8.37 的源码路径。
--with-zlib=/usr/local/src/zlib-1.2.8 指的是zlib-1.2.8 的源码路径。
#make && make install
自此Nginx安装完毕
#cd/usr/local/Nginx/
#cpconf/Nginx.confconf/Nginx.conf.bak
#viconf/Nginx.conf
其中server段增加如下配置,注意标红内容配置,否则会出现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;
}
在/usr/local/Nginx/html下创建info.PHP件,输入如下内容:
<?PHP
echo PHPinfo();
?>
六、启动服务
七、浏览器访问