首先,下载PRCE
地址:http手动下载地址:http://sourceforge.net/projects/pcre/files/pcre/选择下载最新版本
我下载的是pcre-8.35.tar.gz
一般情况下,我的软件都放在/opt/soft下
1,解压:
# cd /opt/soft
# tar -zxvf pcre-8.35.tar.gz
# cd pcre-8.35
2.配置
# mkdir /usr/local/pcre-8.35
# ./configure --prefix=/usr/local/pcre-8.35
3.编译
# make
当你看到make[1]: Leaving directory `/opt/soft/pcre-8.35'
说明编译完成
4.安装
# make install
当你看到
make[3]: Leaving directory `/opt/soft/pcre-8.35'
make[2]: Leaving directory `/opt/soft/pcre-8.35'
make[1]: Leaving directory `/opt/soft/pcre-8.35'
说明安装完成
接下来,安装nginx之前还有一个步骤:
# yum -y install pcre-devel
这个是为了解决:
【
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
】这个错误。
如果你不执行以上命令,直接去安装nginx,就可能有这个错误。
注意:安装pcre之前可能还有一个错:
执行命令:
# yum install -y gcc gcc-c++
然后重复安装动作即可。
配置好pcre后我们就可以安装nginx了。
1.下载Nginx http://dl.oschina.net/soft/nginx
可以根据自己选择下载,我下的是 nginx-1.4.5.tar.gz
同样的我的也是放在/opt/soft下
3.解压
# cd /opt/soft
# tar -zxvf nginx-1.4.5-1392172829533.tar.gz
# cd nginx-1.4.5
4.配置
# mkdir /usr/local/nginx
# ./configure --prefix=/usr/local/nginx --with-http_stub_status_module
5.编译
# make
[make[1]: Leaving directory `/opt/soft/nginx-1.4.5'
make -f objs/Makefile manpage
make[1]: Entering directory `/opt/soft/nginx-1.4.5'
sed -e "s|%%PREFIX%%|/usr/local/nginx/|" \
-e "s|%%PID_PATH%%|/usr/local/nginx//logs/nginx.pid|" \
-e "s|%%CONF_PATH%%|/usr/local/nginx//conf/nginx.conf|" \
-e "s|%%ERROR_LOG_PATH%%|/usr/local/nginx//logs/error.log|" \
< man/nginx.8 > objs/nginx.8
make[1]: Leaving directory `/opt/soft/nginx-1.4.5']
当你看到这些的时候代表编译完成。
6.安装
# make install
[test -d '/usr/local/nginx//logs' || mkdir -p '/usr/local/nginx//logs'
test -d '/usr/local/nginx//logs' || mkdir -p '/usr/local/nginx//logs'
test -d '/usr/local/nginx//html' || cp -R html '/usr/local/nginx/'
test -d '/usr/local/nginx//logs' || mkdir -p '/usr/local/nginx//logs'
make[1]: Leaving directory `/opt/soft/nginx-1.4.5'
]
当你看到这些表示安装完成
7.测试
#cd /usr/local/nginx/sbin
#./nginx -t
如果显示:
nginx: the configuration file /usr/local/nginx//conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx//conf/nginx.conf test is successful
则表示OK哒
8.启动nginx
# ./nginx
在浏览器中输入你的服务器ip地址,因为nginx默认为80端口,
如果显示:
[
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.
Thank you for using nginx.
]
则表示nginx已经成功安装了。
ps:关于nginx的一些操作,特性,大家可以去看其他文章。这里不做细表。
借鉴文章:http://my.oschina.net/u/1047537/blog/131330