美文网首页
ContOS7安装Nginx

ContOS7安装Nginx

作者: MaJiT | 来源:发表于2020-08-17 12:04 被阅读0次

1.安装gcc gcc-c++

yum install -y gcc gcc-c++

2. 安装PCRE库

//下载pcre
wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.33/pcre-8.33.tar.gz
//解压
 tar -zxvf pcre-8.33.tar.gz
//进目录
cd pcre-8.33
//编译
./configure
//安装
make && make install
//查看版本
pcre-config --version

3.安装zlib库

//下载
wget http://zlib.net/zlib-1.2.11.tar.gz
//解压
tar -zxvf zlib-1.2.11.tar.gz
//进目录
cd zlib-1.2.11
//编译
./configure
//安装
make && make install

4.安装SSL库

//下载
 wget https://www.openssl.org/source/old/1.0.1/openssl-1.0.1j.tar.gz
//解压
 tar -zxvf openssl-1.0.1j.tar.gz
//进目录
cd openssl-1.0.1j
//编译
# ./config
//安装
 make && make install

5.安装nginx

//下载
wget http://nginx.org/download/nginx-1.8.0.tar.gz
//解压
tar -zxvf nginx-1.8.0.tar.gz
//进目录
cd nginx-1.8.0 
//编译
./configure
//安装
make && make install

6.常用命令

安装成功后在usr/local下出现nginx的目录,操作时切换到sbin目录下操作

//启动命令
./nginx
//关闭
./nginx -s stop
//强制关闭nginx服务
pkill nginx
//重新加载
nginx -s reload

7.配置介绍

nginx 配置文件时conf/nginx.conf。nginx的配置文件三部分组成

1)全局块:配置服务器整体运行的配置指令
比如 worker_processes 1;处理并发数的配置

(2)events 块:影响 Nginx 服务器与用户的网络连接
比如 worker_connections 1024; 支持的最大连接数为 1024

(3)http 块: 还包含两部分:http 全局块 server 块

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;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }

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

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }

相关文章

网友评论

      本文标题:ContOS7安装Nginx

      本文链接:https://www.haomeiwen.com/subject/lusndktx.html