第十六节Linux安装nginx

目录

1.在/usr/local/目录下安装nginx

2.将nginx压缩包上传到服务器

3.解压nginx

4.安装g++、gcc、openssl-devel、pcre-devel和zlib-devel

5.在/usr/local/nginx-1.17.9/目录下执行安装命令

6.执行(和路径无关直接执行):make  

7.最后执行:make install

8.启动nginx

9.查看是否启动成功

10.nginx访问地址

11.如需要修改nginx配置文件

12.nginx配置环境变量

13.nginx.conf配置文件


1.在/usr/local/目录下安装nginx

cd /usr/local/

2.将nginx压缩包上传到服务器

rz

3.解压nginx

tar  -xvf  nginx-1.17.9.tar.gz

4.安装g++、gcc、openssl-devel、pcre-devel和zlib-devel

安装nginx前,我们首先要确保系统安装了g++、gcc、openssl-devel、pcre-devel和zlib-devel软件

安装g++:

yum install gcc-c++

安装pcre-devel:

yum -y install zlib zlib-devel pcre pcre-devel

安装openssl-devel:

yum -y install openssl openssl-devel

5.在/usr/local/nginx-1.17.9/目录下执行安装命令

执行安装命令(带https):

./configure --prefix=/usr/local/nginx --with-http_ssl_module

如果需要使用https安装时需要加上https认证模块:--with-http_ssl_module

带https安装:

./configure --with-http_ssl_module

不带https安装:

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

6.执行(和路径无关直接执行):make  

Make是最常用的构建工具,只要某个文件有变化,就要重新构建的,都可以用Make构建

make

7.最后执行:make install

make install安装已经编译好的程序

make install

8.启动nginx

如果启动不成功 需要配置nginx环境变量 参考:目录12

cd /usr/local/nginx/sbin

启动nginx命令:

./nginx

9.查看是否启动成功

ps -ef|grep nginx

10.nginx访问地址

http://ip:端口

11.如需要修改nginx配置文件

修改 /usr/local/nginx/conf下的配置文件

cd /usr/local/nginx/conf
vi conf

12.nginx配置环境变量

vi /etc/profile

如下内容添加到profile文件最后一行

export PATH=$PATH:/usr/local/nginx/sbin

将配置文件生效命令:

source /etc/profile

13.nginx.conf配置文件

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;

     server {
        listen 8012;
        server_name  82.156.176.157;

	client_max_body_size 300m;


        location /zwzw {
            proxy_pass http://82.156.176.157:8080;
        }
        location /mapobj-api-ftzw { 
            proxy_pass http://82.156.176.157:9999;
        }
	 
	
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

akglobe

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值