Linux系统下Nginx服务器部署

Nginx安装步骤:

创新互联专业为企业提供泊头网站建设、泊头做网站、泊头网站设计、泊头网站制作等企业网站建设、网页设计与制作、泊头企业网站模板建站服务,10多年泊头做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

一、相关组件

(1) Nginx本身

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

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

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

二、安装步骤

(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。

当前名称:Linux系统下Nginx服务器部署
本文URL:https://www.cdcxhl.com/article14/cphjge.html

成都网站建设公司_创新互联,为您提供品牌网站建设微信小程序外贸建站App开发品牌网站制作响应式网站

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

网站优化排名