[转载] Nginx在Linux下的安装

nginx依赖以下一些软件库,在安装之前请确保安装了这些软件库,它们包括:gcc,openssl,zlib,pcre(可通过rpm -q命令查询是否已安装),其中前三个库可通过系统盘进行安装,这里仅简单说说pcre的安装:

下载pcre至/home目录下,这里选择的版本是pcre-8.10,下载完后执行以下操作

[plain]  view plain  copy
  1. 1.[root@localhost home]# tar zxvf pcre-8.10.tar.gz   //解压缩  
  2. 2.[root@localhost home]# cd pcre-8.10                //切换到该目录下  
  3. 3.[root@localhost pcre-8.10]#./configure            //配置  
  4. 4.[root@localhost pcre-8.10]#make    
  5. 5.[root@localhost pcre-8.10]#make install           //安装  


安装nginx

从nginx的官方网站下载稳定版本,这里下载的版本号是nginx-1.0.2。在默认情况下,经过编译安装的Nginx包含了大部分可用模块,可以通过“./configure  --help”选项设置各个模块的使用情况,例如对不需要的http_ssi模块,可通过“--without-http_ssi_module”参数关闭此模块;如果需要“http_perl”模块,则可以通过“--with-http_perl_module”参数安装此模块。执行以下操作进行安装

[plain]  view plain  copy
  1. 1.[root@localhost home]# tar zxvf nginx-1.0.2.tar.gz    
  2. 2.[root@localhost home]#cd nginx-1.0.2    
  3. 3.[root@localhostnginx-1.0.2]#./configure --with- > http_stub_status_module --prefix=/usr/local/nginx    
  4. 4.[root@localhost nginx-1.0.2]#make    
  5. 5.[root@localhost nginx-1.0.2]#make install  

配置时使用"with-http_stub_status_module"参数来启用 Nginx 的 NginxStatus 功能,以监控 Nginx 的当前状态。

安装完成后执行以下操作验证安装是否成功:

[plain]  view plain  copy
  1. cd  /usr/local/nginx/sbin  
  2. ./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
至此,nginx的安装已成功完成。

启动nginx 
cd /usr/local/nginx/sbin
./nginx //启动nginx
在浏览器中输入:http://localhost验证nginx是否成功启动

停止nginx 
pkill -9 nginx

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值