编译安装Nginx和pcre
编译安装ngnix和pcre
(一)首先要安装pcre ,他作用是让ngnix支持rewrite功能
yum -y install make zlib zlib-devel gcc-c++ libtool
mkdir -p /home/oldboy/tools
cd /home/oldboy/tools
wget http://sourceforge.jp/frs/g_redir.php?m=jaist&f=%2Fpcre%2Fpcre%2F8.30%2Fpcre-8.30.tar.gz
tar zxf pcre-8.30.tar.gz
cd pcre-8.30/
./configure
make&&make install
cd ../
(二)安装nginx
cd /home/oldboy/tools
wget http://nginx.org/download/nginx-1.2.3.tar.gz
useradd nginx -s /sbin/nologin -M
tar zxf nginx-1.2.3.tar.gz
cd nginx-1.2.3
./configure --user=nginx --group=nginx --prefix=/application/nginx-1.2.3 --with-http_stub_status_module --with-http_ssl_module (如果有报错就yum -y install openssl*)
make && make install
ln -s /application/nginx-1.2.3 /application/nginx
application/nginx/sbin/nginx -t 检查语法如果有报错就执行
[root@testvpn nginx-1.2.3]# find / -name libpcre.so*
/lib64/libpcre.so.0.0.1
/lib64/libpcre.so.0
/usr/local/lib/libpcre.so.1
/usr/local/lib/libpcre.so
/usr/local/lib/libpcre.so.1.0.0
/home/oldboy/tools/pcre-8.30/.libs/libpcre.so.1
/home/oldboy/tools/pcre-8.30/.libs/libpcre.so
/home/oldboy/tools/pcre-8.30/.libs/libpcre.so.1.0.0
[root@testvpn nginx-1.2.3]# vi /etc/ld.so.conf
include ld.so.conf.d/*.conf
/usr/local/lib ##加入find搜索出的路径
[root@testvpn nginx-1.2.3]# ldconfig ##再运行一次这个命令即可
[root@testvpn nginx-1.2.3]#/application/nginx/sbin/nginx #启动nginx
##以下三条都是检查命令
netstat -lnt 看是否有80端口
ps -ef| grep nginx ###默认是一个master和一个work进程
lsof -i :80 反查80是否是nginx而不是apache
如果装好访问wget htttp://ip方式,或者url 访问没出现welcome nginx,关闭防火墙和selinux
##查看确认html就是nginx的网页目录
[root@testvpn html]# grep html /application/nginx/conf/nginx.conf
root html; ##这个就是放网页的目录
index index.html index.htm;
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
# root html;
# root html;
# index index.html index.htm;
# root html;
# index index.html index.htm; 目录/appalication/nginx/html就是网站目录
Nginx 的详细介绍:请点这里
Nginx 的下载地址:请点这里
相关阅读: