中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

CentOS7.5中編譯安裝nginx-1.12.2

發布時間:2020-07-15 17:31:22 來源:網絡 閱讀:15143 作者:茁壯的小草 欄目:建站服務器


1 說明

本文檔以吉林考試項目為例,采用編譯方式來安裝部署nginx

2 目錄規劃

nginx版本

nginx源碼包存放錄

nginx安裝目錄

nginx存放代碼目錄

nginx日志目錄

nginx-1.12.2

nginx-1.12.2

/usr/local/nginx

/home/yunwei/nginx-data

/home/yunwei/nginx-logs

3 下載nginx源碼包

創建nginx源碼包存放目錄

mkdir /usr/local/src/nginx

下載nginx源碼包到指定目錄

wget http://nginx.org/download/nginx-1.12.2.tar.gz -P /usr/local/src/nginx/

解壓nginx源碼包

tar xf /usr/local/src/nginx/nginx-1.12.2.tar.gz  -C /usr/local/src/nginx/

4 編譯安裝nginx

安裝依賴包

yum -y install pcre-devel openssl-devel

創建nginx用戶

useradd -s /sbin/nologin -M nginx

創建nginx安裝目錄

mkdir /usr/local/nginx

cd /usr/local/src/nginx/nginx-1.12.2/

./configure --prefix=/usr/local/nginx/ --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module

make && make install

ln -s /usr/local/nginx/sbin/nginx /sbin/nginx

5 創建存放代碼和日志目錄

mkdir /home/yunwei/nginx-data/jl_exam/jl_exam_poral/ROOT -p

mkdir /home/yunwei/nginx-data/jl_exam/jl_exam_manage_view/ROOT/ -p

mkdir /home/yunwei/nginx-logs/jl_exam/ -p

chmod 755 /home/yunwei/

chown -R nginx.nginx /home/yunwei/nginx-*

6 編輯配置文件

備份配置文件

cp /usr/local/nginx/conf/nginx.conf{,.ori}

創建虛擬主機配置文件存放目錄

mkdir /usr/local/nginx/conf/extra/jl_exam

6.1 編輯nginx.conf主配置文件

cat >/usr/local/nginx/conf/nginx.conf <<EOF

worker_processes  1;

worker_rlimit_nofile 2048;

events {

    worker_connections  4096;

}

http {

    include       mime.types;

    default_type  application/octet-stream;

    sendfile        on;

    tcp_nopush on;

    keepalive_timeout  65;

    fastcgi_intercept_errors on;

    send_timeout 15s;

server_tokens off;

client_max_body_size 50m;    #客戶端可上傳的最大報文(附件)大小為50MB,默認為1MB

    gzip on;

    gzip_min_length 1k;

    gzip_buffers 4 16k;

    gzip_http_version 1.1;

    gzip_comp_level 2;

    gzip_types text/css text/xml application/javascripts;

gzip_vary on;

client_max_body_size 50m;                                                                      

client_header_timeout 120s;                                                                     

client_body_timeout 120s;                                                                       

client_body_buffer_size 256k;

    log_format  main  '\$remote_addr - \$remote_user [\$time_local] "\$request" '

                      '\$status \$body_bytes_sent "\$http_referer" '

                      '"\$http_user_agent" "\$http_x_forwarded_for"';

    include extra/jl_exam/jl_exam_poral.conf;

    include extra/jl_exam/jl_exam_manage_view.conf;

}

EOF

6.2 virtual server配置

vim /usr/local/nginx/conf/extra/jl_exam/jl_exam_manage_view.conf

server {                                                                                     

        listen       8081;                                                                       

        server_name  10.0.0.14;

        access_log  /home/yunwei/nginx-logs/jl_exam/jl_exam_manage_view_access.log main;

        error_log  /home/yunwei/nginx-logs/jl_exam/jl_exam_manage_view_error.log;           

        location / {                                                                              

            root   /home/yunwei/nginx-data/jl_exam/jl_exam_manage_view/ROOT;                                                           

        }                                                                                        

        error_page   500 502 503 504  /50x.html;                                                 

        location = /50x.html {                                                                   

            root   html;                                                                          

        }                                                                                        

}

vim /usr/local/nginx/conf/extra/jl_exam/jl_exam_poral.conf

server {

       listen       80;

       server_name  10.0.0.14;

           access_log  /home/yunwei/nginx-logs/jl_exam/jl_exam_poral_access.log main;

       error_log  /home/yunwei/nginx-logs/jl_exam/jl_exam_poral_error.log;

       location / {

           root   /home/yunwei/nginx-data/jl_exam/jl_exam_poral/ROOT;

           index  index.html index.htm;

       }  

       error_page   500 502 503 504  /50x.html;

       location = /50x.html {

           root   html;

       }  

}

7 啟動nginx服務

將代碼放入相應的站點目錄里

nginx    #啟動nginx

echo "/usr/local/nginx/sbin/nginx" >>/etc/rc.local    #添加到開機自啟動

8 日志切割配置

利用系統自帶的logrotate進行切割nginx日志文件

創建nginx_jl_exam文件

cat >/etc/logrotate.d/nginx_jl_exam <<EOF

/home/yunwei/nginx-logs/jl_exam/*.log{

daily

rotate 10

create

dateext

notifempty

postrotate

        [ -f /usr/local/nginx/logs/nginx.pid ] && kill -USR1 \`cat /usr/local/nginx/logs/nginx.pid\`

endscript

}

EOF

強制執行一次,切割日志,以后每天會定時切割日志

logrotate -f /etc/logrotate.d/nginx_jl_exam


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

海阳市| 迁西县| 富源县| 阳泉市| 汾西县| 德格县| 宜黄县| 密云县| 抚州市| 同仁县| 霍林郭勒市| 西华县| 西乌珠穆沁旗| 疏附县| 兰西县| 龙川县| 大竹县| 宝鸡市| 托里县| 三穗县| 修文县| 东至县| 文成县| 延寿县| 湟源县| 会理县| 西丰县| 天祝| 怀来县| 甘谷县| 晋江市| 满洲里市| 皋兰县| 绥宁县| 迭部县| 肇东市| 石首市| 仪陇县| 卓资县| 奉化市| 邹平县|