×
新网 > 虚机资讯 > 正文

Linux系统下Nginx服务器部署

Nginx安装步骤: 一、相关组件         (1)    Nginx本身 下载地址:http://nginx.org/en/download.html;提供的安装包是Nginx-1.9.7版本。 (2)   Rewrite模块的正则表达式依赖库pcre 下载地址:http://www.pcre.org;提供的安装包是pcre-8.38版本。   二、安装步骤       

Nginx安装步骤:

一、相关组件

(1) Nginx本身

下载地址:http://nginx.org/en/download.html;提供的安装包是Nginx-1.9.7版本。

(2) Rewrite模块的正则表达式依赖库pcre

下载地址:http://www.pcre.org;提供的安装包是pcre-8.38版本。

timg (63).jpg

 

二、安装步骤

(1) 安装pcre

tar -zxvf pcre-8.38.tar.gz

cd pcre-8.38

./configure

make

make install

默认安装到/usr/local/lib下即可;安装完成后可以#ls -l /usr/local/lib/libpcre.so

(2) 安装nginx

tar –zxvf nginx-1.9.7.tar.gz

cd nginx-1.9.7

./configure

make

make install

 

三、nginx配置

配置文件默认在/usr/local/nginx目录下,主要的配置文件为conf目录下的nginx.conf。

启动程序文件在/usr/sbin/nginx中。

日志在/var/log/nginx中,分别是access.log和error.log。

默认的虚拟主机的目录设置在了/usr/share/nginx/html中。

常见配置如下:

(1) 侦听80端口 (nginx默认监听80端口)

listen 80;

(2) 服务器名称

Server_name localhost;

(3) 默认主页目录在nginx安装目录的html子目录。

root html;

index index.html index.html;

 

四、管理nginx

(1) 启动

/usr/local/nginx/sbin/nginx (/usr/nginx/sbin/nginx -t 查看配置信息是否正确)

(2) 停止

/usr/local/nginx/sbin/nginx -s stop

(3) 重启

/usr/local/nginx/sbin/nginx-s reload

(4) 查看状态

netstat -autlp| grep nginx

(5) 检查部署正确性

访问http://localhost/,查看是否正常启动。

 

五、常见问题

(1) 缺少pcre库:./configure: error: the HTTP rewrite module requires the PCRE library.

解决方法:安装pcre。

(2) 缺少openssl:./configure: error: the HTTP cache module requires md5 functions from OpenSSL library.

解决方法:安装openssl-devel。

(3) 缺少gcc-c++和libtool:The program \'libtool\' is currently not installed. You can install it by typing:sudo apt-get install libtool

解决方法:安装libtool和gcc-c++。

(4) 缺少zlib:./configure: error: the HTTP gzip module requires the zlib library.

解决方法:安装zlib。

  • 相关专题

免责声明:本文内容由互联网用户自发贡献自行上传,本网站不拥有所有权,也不承认相关法律责任。如果您发现本社区中有涉嫌抄袭的内容,请发送邮件至:operations@xinnet.com进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。

免费咨询获取折扣

Loading