首页 > 系统服务 > 详细

linux 安装与启动nginx

时间:2015-11-16 22:50:35      阅读:439      评论:0      收藏:0      [点我收藏+]

linux系统为Centos 64位 

一、去http://nginx.org/download/上下载相应的版本下载nginx-1.8.0.tar.gz(注:还有更高版本的)。

二、解压 tar -zxvf nginx-1.8.0.tar.gz

三、进入nginx-1.8.0/文件夹,设置一下配置信息 ./configure --prefix=/usr/local/nginx(安装后的文件存放路径)。

四、配置的时候可能会出现类似这样的信息

./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. 

安装pcre-devel解决问题
yum -y install pcre-devel

安装完成后再执行./configure --prefix=/usr/local/nginx

执行完后还有可能会出现这样的问题:

checking for PCRE JIT support ... not found
checking for system md library ... not found
checking for system md5 library ... not found
checking for OpenSSL md5 crypto library ... not found
checking for sha1 in system md library ... not found
checking for OpenSSL sha1 crypto library ... not found
checking for zlib library ... found

解决办法:

yum -y install openssl openssl-devel

 

五、make && make install

出现类似这样的就表示安装成功了

cp conf/nginx.conf ‘/usr/local/nginx/conf/nginx.conf.default‘
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 `/root/setup/nginx/nginx-1.8.0‘

 

安装完后/usr/local/nginx 后出现几个文件夹conf、html、logs、sbin

 

启动nginx:

./usr/nginx/sbin/nginx

 

查看端口:

netstat -antp

Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 19031/nginx
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 2771/vsftpd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 906/sshd
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2263/mysqld

 

 

nginx的80端口启动了。

访问安装nginx的服务器地址,出现如下图,说明成功了。技术分享

 

linux 安装与启动nginx

原文:http://www.cnblogs.com/hjy9420/p/4970170.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!