Nginx安装

首先,下载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之前可能还有一个错:

 

configure: error: You need a C++ compiler for C++ support

执行命令:

yum install -y gcc gcc-c++

然后重复安装动作即可。

 

配置好pcre后我们就可以安装nginx了。

1.下载Nginx http://nginx.org/download/

(现在最新版本1.9.9)

可以根据自己选择下载,我下的是 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端口,

如果显示:

[

Welcome to nginx!

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

转载于:https://my.oschina.net/gmupload/blog/270107

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值