日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux下nginx部署以及配置详解

發(fā)布時間:2025/4/16 linux 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux下nginx部署以及配置详解 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

1、下載源碼包解壓編譯

啟動多個,請看:在linux系統(tǒng)下安裝兩個nginx以及啟動

查看nginx包路徑:http://nginx.org/download/,兩種下載方式:

1、在官網(wǎng)下載使用Xftp上傳到linux上(不推薦使用)

2、(推薦)在版本上選好,直接命令下載,如下:(下載nginx-1.16.1.tar.gz版本)建議到home目錄執(zhí)行該命令,方便找到

wget http://nginx.org/download/nginx-1.16.1.tar.gz

已安裝好

3、解壓

tar xvf nginx-1.16.1.tar.gz -C /usr/local/src/

?4、安裝相應(yīng)的開發(fā)工具

yum groupinstall "Development tools" yum -y install gcc wget gcc-c++ automake autoconf libtool libxml2-devel libxslt-devel perl-devel perl-ExtUtils-Embed pcre-devel openssl-devel

5、進(jìn)入nginx目錄進(jìn)行編譯安裝

1、進(jìn)入目錄 cd /usr/local/src/nginx-1.16.1 2、執(zhí)行以下命令,直接粘貼即可
./configure \ --prefix=/usr/local/nginx \ --sbin-path=/usr/sbin/nginx \ --conf-path=/etc/nginx/nginx.conf \ --error-log-path=/var/log/nginx/error.log \ --http-log-path=/var/log/nginx/access.log \ --pid-path=/var/run/nginx.pid \ --lock-path=/var/run/nginx.lock \ --http-client-body-temp-path=/var/tmp/nginx/client \ --http-proxy-temp-path=/var/tmp/nginx/proxy \ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi \ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \ --http-scgi-temp-path=/var/tmp/nginx/scgi \ --user=nginx \ --group=nginx \ --with-pcre \ --with-http_v2_module \ --with-http_ssl_module \ --with-http_realip_module \ --with-http_addition_module \ --with-http_sub_module \ --with-http_dav_module \ --with-http_flv_module \ --with-http_mp4_module \ --with-http_gunzip_module \ --with-http_gzip_static_module \ --with-http_random_index_module \ --with-http_secure_link_module \ --with-http_stub_status_module \ --with-http_auth_request_module \ --with-mail \ --with-mail_ssl_module \ --with-file-aio \ --with-ipv6 \ --with-http_v2_module \ --with-threads \ --with-stream \ --with-stream_ssl_module View Code


3、完成編譯安裝
make && make install

mkdir -pv /var/tmp/nginx/client

6、添加SysV啟動腳本

1、創(chuàng)建文件

vi /etc/init.d/nginx

2.按i進(jìn)入編輯狀態(tài)

#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
# pidfile: /var/run/nginx.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
nginx="/usr/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/etc/nginx/nginx.conf"
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
killall -9 nginx
}
restart() {
configtest || return $?
stop
sleep 1
start
}
reload() {
configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac

7.賦予腳本執(zhí)行權(quán)限

chmod +x /etc/init.d/nginx

8.添加nginx服務(wù)進(jìn)程用戶

groupadd -r nginx
useradd
-r -g nginx nginx

9、添加至服務(wù)管理列表,設(shè)置開機自啟

chkconfig --add nginx
chkconfig nginx on

?10、啟動nginx

關(guān)閉防火墻:systemctl stop firewalld

service nginx start

?

?

?

?

?

?2、詳細(xì)配置

配置選項說明
--prefixnginx的安裝目錄,默認(rèn)為/usr/local/nginx
--sbin-pathnginx可執(zhí)行文件路徑,若沒有設(shè)置則依賴于--prefix
--conf-path設(shè)置nginx.conf配置文件路徑,nginx啟動時可以通過-c參數(shù)指定配置文件
--error-log-path錯誤日志路徑
--http-log-pathhttp主請求日志文件
--pid-path存放nginx進(jìn)程的pid號
--lock-path共享存儲器互斥鎖文件路徑
--http-client-body-temp-path客戶端收到請求后,臨時存放請求體目錄
--http-proxy-temp-path使用代理后,通過該項設(shè)置存放請求體路徑
--http-fastcgi-temp-path設(shè)置FastCGI臨時文件的目錄
--http-uwsgi-temp-path設(shè)置uWSGI臨時文件的目錄
--http-scgi-temp-path設(shè)置SCGI臨時文件的目錄
--user指定nginx運行的用戶
--group指定nginx運行的用戶組
--with-pcre設(shè)置PCRE庫的源碼路徑
--with-http_v2_module用來支持 HTTP 2.0 的
--with-http_ssl_module如果需要對流量進(jìn)行加密,可以使用該選項,再URLs中開始部分將會是https(需要OpenSSL庫)

3.nginx.conf配置

#user nobody; worker_processes 1; #工作進(jìn)程:數(shù)目。根據(jù)硬件調(diào)整,通常等于cpu數(shù)量或者2倍cpu數(shù)量。#錯誤日志存放路徑 #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info;#pid logs/nginx.pid; # nginx進(jìn)程pid存放路徑events {worker_connections 1024; # 工作進(jìn)程的最大連接數(shù)量 }http {include mime.types; #指定mime類型,由mime.type來定義default_type application/octet-stream;# 日志格式設(shè)置#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; #用log_format指令設(shè)置日志格式后,需要用access_log來指定日志文件存放路徑sendfile on; #指定nginx是否調(diào)用sendfile函數(shù)來輸出文件,對于普通應(yīng)用,必須設(shè)置on。如果用來進(jìn)行下載等應(yīng)用磁盤io重負(fù)載應(yīng)用,可設(shè)著off,以平衡磁盤與網(wǎng)絡(luò)io處理速度,降低系統(tǒng)uptime。#tcp_nopush on; #此選項允許或禁止使用socket的TCP_CORK的選項,此選項僅在sendfile的時候使用#keepalive_timeout 0; #keepalive超時時間keepalive_timeout 65;#gzip on; #開啟gzip壓縮服務(wù)#虛擬主機server {listen 80; #配置監(jiān)聽端口號server_name localhost; #配置訪問域名,域名可以有多個,用空格隔開#charset koi8-r; #字符集設(shè)置#access_log logs/host.access.log main;location / {root html;index index.html index.htm;}#錯誤跳轉(zhuǎn)頁#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$ { #請求的url過濾,正則匹配,~為區(qū)分大小寫,~*為不區(qū)分大小寫。# root html; #根目錄# fastcgi_pass 127.0.0.1:9000; #請求轉(zhuǎn)向定義的服務(wù)器列表# fastcgi_index index.php; # 如果請求的Fastcgi_index URI是以 / 結(jié)束的, 該指令設(shè)置的文件會被附加到URI的后面并保存在變量$fastcig_script_name中# 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;#}}# another virtual host using mix of IP-, name-, and port-based configuration##server {# listen 8000;# listen somename:8080;# server_name somename alias another.alias;# location / {# root html;# index index.html index.htm;# }#}# HTTPS server##server {# listen 443 ssl; #監(jiān)聽端口# server_name localhost; #域名# ssl_certificate cert.pem; #證書位置# ssl_certificate_key cert.key; #私鑰位置# ssl_session_cache shared:SSL:1m;# ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5; #密碼加密方式# ssl_prefer_server_ciphers on; # ssl_prefer_server_ciphers on; ## location / {# root html;# index index.html index.htm;# }#}}

?

轉(zhuǎn)載于:https://www.cnblogs.com/weibanggang/p/11484970.html

總結(jié)

以上是生活随笔為你收集整理的linux下nginx部署以及配置详解的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 国产精品中文字幕在线观看 | 欧美亚洲高清 | 麻豆传媒网址 | 亚洲一区电影在线观看 | 精品伦一区二区三区 | a视频免费看 | 美国性生活大片 | 海角社区在线 | 色开心 | 一本一道av无码中文字幕 | 刘亦菲国产毛片bd | 黄色大片在线 | 宅男午夜在线 | 中文理论片 | 手机看片福利在线 | 国产亚洲一区二区三区 | 黄色免费网站观看 | 国产69精品久久 | 久久亚洲精品小早川怜子 | 免费观看黄色网 | 久久色在线观看 | 手机av在线网 | 色哟哟视频在线观看 | 麻豆成人入口 | 成人在线播放网站 | 亚洲666| 天天拍夜夜操 | 国产精品无码久久av | 无码人妻一区二区三区在线视频 | 久久99精品久久久久久水蜜桃 | 亚洲一区激情 | 国产一区欧美 | 99久免费精品视频在线观78 | 国产精品高清无码 | 亚洲妇熟xx妇色黄蜜桃 | 最新国产精品自拍 | 黄色亚洲网站 | 亚洲av无码国产在丝袜线观看 | 天堂网视频 | 色干干 | 影音先锋激情在线 | 国产高清视频免费观看 | 亚洲精品久久夜色撩人男男小说 | 久久久久久少妇 | 激情图片在线视频 | 免费av网站在线看 | 国产精品扒开腿做爽爽爽视频 | 欧美人妖另类 | 色天天干 | 国产精品久久久久毛片大屁完整版 | 黑人操欧美人 | 精品黄色av| 久久久久亚洲 | 精品国产视频一区二区三区 | 69xxx国产 | 欧美性吧 | a毛片成人| 国内自拍小视频 | 免费av手机在线观看 | 欧美一区二区三区精品 | 精产国品一二三区 | 秋霞一区 | 一出一进一爽一粗一大视频 | 香蕉成人av | 国产区视频在线观看 | 国产精品第一区 | 法国经典free性复古xxxx | 精品人妻一区二区三区四区在线 | 99热精品国产 | a级无毛片| 中文字幕一区二区三区5566 | 午夜亚洲AV永久无码精品蜜芽 | 青青青视频免费 | 亚洲精品久久久久久国产精华液 | 日韩欧美一级片 | 国产精品视频一区二区在线观看 | 久久国产精品精品国产色婷婷 | 极品美女一区二区三区 | 青青伊人网 | 日韩激情视频在线 | 国产精品99re | 在线天堂网| 好看的中文字幕电影 | av二区在线| 日韩精品久久一区二区 | 一级特黄录像免费看 | 夜夜嗨av一区二区三区免费区 | 欧美五月激情 | 天天看片天天干 | 中文一区二区在线观看 | 视频一区二区欧美 | 欧美亚洲精品在线 | 成人在线三级 | 七七久久 | 亚洲av成人精品日韩在线播放 | 中文字幕亚洲精品在线观看 | 鲁丝一区二区三区 | youjizz韩国 | 邻居交换做爰2 |