LINUX系统下安装NGINX

createh52周前 (06-04)技术教程6

1、第一步:获取nginx的安装包

wget http://nginx.org/download/nginx-1.7.8.tar.gz

2、解压安装包
tar -xvf nginx-1.7.8.tar.gz

3、执行./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.


解决之法:
yum -y install pcre-devel

4、执行./configure --prefix=/usr/local/nginx命令报如下错误


报错:
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using
--without-http_gzip_module

option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.

解决之法:
yum -y install pcre-devel openssl openssl-devel

5、执行如下命令:
./configure --prefix=/usr/local/nginx

6、执行如下命令:
make

7、执行如下命令:
make install

8、启动nginx

启动代码格式:nginx安装目录地址 -c nginx配置文件地址

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

9、访问nginx

curl nginx所在后台的IP地址:端口(默认80)

eg:

表示nginx安装成功

10、强制停止nginx

pkill -9 nginx

11、更改nginx的端口

修改配置文件路径:
/usr/local/nginx/conf/nginx.conf

修改为你需要的端口:

重启nginx生效

12、同一linux后台安装多个nginx服务

1)重复步骤5

./configure --prefix=/usr/local/nginx2

ps:prefix必须指定新的nginx安装目录

2)执行:make && make install

3)修改配置文件如下3个地方

(1)赋予root权限,在nginx.conf开头增加如下内容:

(2)修改访问端口

(3)修改访问路径

4)启动nginx

/usr/local/nginx2/sbin/nginx -c /usr/local/nginx2/conf/nginx.conf

相关文章

CentOS Nginx安装及配置

安装在 CentOS 上,可直接使用 yum 来安装 Nginxyum install nginx -y扩展: 卸载用 yum remove nginx启动安装完成后,使用 nginx 命令启动 Ng...

离线状态下安装 Nginx 各个模块?这篇攻略让你轻松搞定

你是不是也在为离线状态下安装 Nginx 各个模块而发愁?在互联网大厂后端开发工作中,我们常常会遇到一些特殊的网络环境,比如公司内部的离线服务器,或是处于隔离状态的测试环境。当需要在这些离线环境中安装...

后端开发必看!没网也能在 Linux 服务器上安装 Nginx 的神操作

在互联网大厂后端开发的日常工作里,不少人都遇到过 “紧急时刻”—— 需要在没有网络的 Linux 服务器上安装 Nginx 服务。望着空白的网络连接状态,一时间不知道从何下手?别着急!今天就手把手教你...

nginx如何安装使用

nginx是什么?Nginx,简称为"engine x",是一个高性能的HTTP和反向代理web服务器,同时也Nginx,简称为"engine x",是一个高性能的HT...

一步步教你使用 docker 快速安装实用的 nginx 服务器

nginx 是一款高性能的 web 服务器,支持反向代理、负载均衡、静态资源管理,非常实用。使用 docker 安装 nginx 非常简便,不仅可以快速启动服务,因为容器特性,有良好的隔离性,还方便管...

windows下将nginx做成服务

注意:本例子拿Nginx作为演示,其余的windows程序也可以通过此方式做成服务windows下安装Nginx后,只能通过双击进行来启动,通过任务管理器来停止进程,如果要通过命令行启动Nginx,可...