centos7 安装 nginx

环境依赖

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

下载压缩包

wget https://nginx.org/download/nginx-1.14.0.tar.gz

解压

tar zxvf nginx-1.14.0.tar.gz

configure

./configuare

编译和编译安装

make && make install

服务启动

./nginx

查看是否启动

  • 查进程 ps aux | grep nginx
  • 输入地址看效果

平滑启动

./nginx -s reload

nginx的配置文件 /usr/local/nginx/config/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;

    #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       80;
        server_name  localhost;
        location / {
            root   /home;
            index  index.html index.htm;
        }
    }

    include  vhost/*.conf; # 以后将server可以写在这个目录里
    
 }
# api.conf
server {
        listen       80;
        server_name  localhost;
        location / {
            root   /home;
            index  index.html index.htm;
        }
    }

 

原文链接: https://www.cnblogs.com/lishanglin/p/12555905.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍;

也有高质量的技术群,里面有嵌入式、搜广推等BAT大佬

    centos7 安装 nginx

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/337243

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年3月1日 下午11:03
下一篇 2023年3月1日 下午11:04

相关推荐