摘要:編譯安裝所需要的等軟件不再贅述下載解壓切換到解壓后的目錄進(jìn)行配置添加組添加用戶設(shè)置用戶名設(shè)置用戶組設(shè)置安裝位置用來(lái)監(jiān)控的當(dāng)前狀態(tài)打開功能允許改變客戶端請(qǐng)求頭中或等可用于記錄客戶編譯安裝
編譯安裝所需要的gcc等軟件不再贅述
1.下載Nginx
wget http://nginx.org/download/nginx-1.14.0.tar.gz
2.解壓
tar xf nginx-1.14.0.tar.gz
3.切換到解壓后的目錄, 進(jìn)行配置
cd nginx-1.14.0 # 添加Nginx組 groupadd nginx # 添加Nginx用戶 useradd nginx -g nginx -s /sbin/nologin -M ./configure --user=nginx # 設(shè)置用戶名 --group=nginx # 設(shè)置用戶組 --prefix=/usr/local/nginx # 設(shè)置安裝位置 --with-http_stub_status_module # 用來(lái)監(jiān)控 Nginx 的當(dāng)前狀態(tài) --with-http_ssl_module # 打開HTTPS功能 --with-http_realip_module # 允許改變客戶端請(qǐng)求頭中X-Real-IP 或 X-Forwarded-For等, 可用于記錄客戶IP --with-http_gzip_static_module
4.編譯安裝
make && make install
開機(jī)啟動(dòng)和制作啟停工具
將下面的文件, 寫到/etc/init.d/nginx中
#!/bin/bash # nginx Startup script for the Nginx HTTP Server # # chkconfig: - 85 15 # description: Nginx is a high-performance web and proxy server. # It has a lot of features, but it"s not for everyone. # processname: nginx # pidfile: /var/run/nginx.pid # config: /usr/local/nginx/conf/nginx.conf nginxd=/usr/local/nginx/sbin/nginx nginx_config=/usr/local/nginx/conf/nginx.conf nginx_pid=/usr/local/nginx/nginx.pid RETVAL=0 prog="nginx" # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ ${NETWORKING} = "no" ] && exit 0 [ -x $nginxd ] || exit 0 # Start nginx daemons functions. start() { if [ -e $nginx_pid ];then echo "nginx already running...." exit 1 fi echo -n $"Starting $prog: " daemon $nginxd -c ${nginx_config} RETVAL=$? echo [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx return $RETVAL } # Stop nginx daemons functions. stop() { echo -n $"Stopping $prog: " killproc $nginxd RETVAL=$? echo [ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /var/run/nginx.pid } # reload nginx service functions. reload() { echo -n $"Reloading $prog: " $nginxd -s reload #if your nginx version is below 0.8, please use this command: "kill -HUP `cat ${nginx_pid}`" RETVAL=$? echo } # See how we were called. case "$1" in start) start ;; stop) stop ;; reload) reload ;; restart) stop start ;; status) status $prog RETVAL=$? ;; *) echo $"Usage: $prog {start|stop|restart|reload|status|help}" exit 1 esac exit $RETVAL
6.添加執(zhí)行權(quán)限
chmod 755 /etc/init.d/nginx
7.開機(jī)自啟動(dòng)
chkconfig --level 345 nginx on
參考文章: https://www.cnblogs.com/lucky...
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請(qǐng)注明本文地址:http://systransis.cn/yun/40050.html
摘要:準(zhǔn)備工作進(jìn)入繼續(xù)操作編譯安裝庫(kù)下載安裝高版本會(huì)出現(xiàn)錯(cuò)誤,建議選擇版本低一些,因?yàn)闀翰恢С?,可以使用版本。編譯錯(cuò)誤解決輸入命令,然后重新編譯。安裝庫(kù)下載安裝安裝解壓即可編譯安裝常用編譯選項(xiàng)說(shuō)明指定的安裝目錄。默認(rèn)情況下,該模塊沒有被構(gòu)建。 原文來(lái)自http://www.hoohack.me/2016/01/27/compile-install-nginx-in-opensuse/ 下載源...
閱讀 2567·2021-09-22 15:25
閱讀 2979·2021-09-14 18:03
閱讀 1228·2021-09-09 09:33
閱讀 1712·2021-09-07 09:59
閱讀 2939·2021-07-29 13:50
閱讀 1509·2019-08-30 15:44
閱讀 1723·2019-08-29 16:22
閱讀 1295·2019-08-29 12:49