首页 > 系统服务 > 详细

Linux nginx安装步骤 centos7

时间:2019-08-27 17:58:18      阅读:118      评论:0      收藏:0      [点我收藏+]

1.安装依赖:

yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel

2.创建一个文件夹
cd /usr/local
mkdir nginx
cd nginx

3.下载解压tar包
wget http://nginx.org/download/nginx-1.13.7.tar.gz
tar -xvf nginx-1.13.7.tar.g

4.编译
cd /usr/local/nginx/nginx-1.13.7

./configure

make

make install

5.配置nginx.conf(这里简单配置 修改了监听端口 跨域)

#user  nobody;
worker_processes  2;

#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;

    #log_format  main  ‘$remote_addr - $remote_user [$time_local] "$request" ‘
    #                  ‘$status $body_bytes_sent "$http_referer" ‘
    #                  ‘"$http_user_agent" "$http_x_forwarded_for"‘;

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
	listen       3389 default_server;
        listen       [::]:3389 default_server;
        server_name  _;
        root         /usr/local/source;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
        }
	location ^~ /res/ {
                add_header Access-Control-Allow-Origin ‘*‘;
                add_header Access-Control-Allow-Methods ‘GET, POST, OPTIONS‘;
                add_header Access-Control-Allow-Headers ‘DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization‘;
            root   /usr/local/source/;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }

}

  6.启动(注意看清文件夹)

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

./nginx 启动

./nginx -s stop 关闭

./nginx -s reload 重启

./nginx -t 检查配置

Linux nginx安装步骤 centos7

原文:https://www.cnblogs.com/AmbitiousMice/p/11419806.html

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