文章转载自 http://limaoyuan.iteye.com/blog/904352
http://www.cnblogs.com/zhuhongbao/archive/2013/06/04/3118061.html
1)下载nginx
默认会下载到当前目录下面,也就是pwd目录
2)解压
-
tar zxvf nginx-0.8.54.tar.gz
进入nginx目录 cd nginx-0.8.54
3)
configure这一步可能会出现,找不到pcre的error
那么如果可以连网建议用yum命令去安装依赖包。
-
yum -y install gcc pcre-devel openssl openssl-devel
如果没有网络,可到CentOS 5.5 DVD下找如下包,按顺序安装
-
rpm -ivh pcre-devel-6.6-2.el5_1.7.i386.rpm
-
rpm -ivh openssl-0.9.8e-12.el5_4.6.i386.rpm
-
rpm -ivh e2fsprogs-devel-1.39-23.el5.i386.rpm
-
rpm -ivh keyutils-libs-devel-1.2-1.el5.i386.rpm
-
rpm -ivh libsepol-devel-1.15.2-3.el5.i386.rpm
-
rpm -ivh libselinux-devel-1.33.4-5.5.el5.i386.rpm
-
rpm -ivh krb5-devel-1.6.1-36.el5_4.1.i386.rpm
-
rpm -ivh zlib-devel-1.2.3-3.i386.rpm
-
rpm -ivh openssl-devel-0.9.8e-12.el5_4.6.i386.rpm
安装好后再执行 ./configure
最后会看到类似下面信息,表示编译成功
-
Configuration summary
-
+ using system PCRE library
-
+ OpenSSL library is not used
-
+ md5: using system crypto library
-
+ sha1 library is not used
-
+ using system zlib library
4)
5)
默认会安装到
目录下面
6) 启动
-
/usr/local/nginx/sbin/nginx
查看是否启动成功
-
[root@maomao sbin]# ps aux | grep nginx
-
root 10391 0.0 0.0 4008 456 ? Ss 10:48 0:00 nginx: [b][color=red]master[/color][/b] process ./nginx
-
nobody 10392 0.0 0.0 4164 796 ? S 10:48 0:00 nginx: worker process
启动成功,master是主进程,关闭的时候kill这个进程,其他子进程会自动关掉
打开浏览器 即可看到nginx的默认欢迎页
Welcome to nginx!
nginx默认是用80端口,我们可以在nginx安装目录下的conf/nginx.conf文件中更改。
-
vim /usr/local/nginx/conf/nginx.conf
找到以下片段进行更改,然后重启
-
server {
-
listen 80;
-
server_name localhost;
-
location / {
-
root html;
-
index index.html index.htm;
-
}
-
}
更改好后,重启nginx。
-
kill -HUP `cat /usr/local/nginx/logs/nginx.pid`
HUP信号是平滑重启
停止nginx
-
kill `cat /usr/local/nginx/logs/nginx.pid`
这时再访问页面,将无法打开。
阅读(1410) | 评论(0) | 转发(0) |