當前位置:首頁 » 編程軟體 » centos7nginx啟動腳本

centos7nginx啟動腳本

發布時間: 2022-10-03 17:24:27

⑴ 怎麼在centos 6.5安裝nginx

一、准備事項
(1) 因為nginx需要訪問80埠所以請先關閉或者開放防火牆埠,和selinux
參考命令
關閉防火牆:
[root@local ~]# iptables -I INPUT -p tcp --dport 80 -j ACCEPT
[root@local ~]# service iptables save
關閉selinux:
[root@local ~]# setenforce 0
[root@local ~]# vim /etc/selinux/config
將SELINUX=enforcing改為SELINUX=disabled

(2) 如果用到域名請自行構建DNS服務
二、安裝
(1) 因為nginx的運行需要安裝pcre、zlib等軟體包,因此我們進行安裝
Pcre=Pcre Compatible Regular Expressions(中文pcre兼容正則表達式)
Yum配置請參考: http://www.linuxidc.com/Linux/2015-11/125332.htm
[root@local ~] yum -y install pcre* zlib* #或者進行編譯安裝
[root@local ~]# useradd -M -s /sbin/nologin nginx #創建nginx服務

啟動用戶
(3) 編譯安裝nginx,下載地址:http://nginx.org/en/download.html 此次安裝為最新穩定版nginx-1.8.0
[root@local ~]# tar zxf nginx-1.8.0.tar.gz
[root@local ~]# cd nginx-1.8.0
[root@local nginx-1.8.0]# ls
auto CHANGES.ru configure html Makefile objs src
CHANGES conf contrib LICENSE man README
[root@local nginx-1.8.0]# ./configure --user=nginx --group=nginx --prefix=/application/nginx-1.8.0 --with-http_stub_status_mole --with-http_ssl_mole #./configure –help 參數詳解
[root@local nginx-1.8.0]# make
[root@local nginx-1.8.0]# make install

(4) 製作軟連接
[root@local nginx-1.8.0]#ln –a /application/nginx-1.8.0/
/application/nginx

(5) 基本使用
#語法檢查
[root@local nginx-1.8.0]# /application/nginx/sbin/nginx –t
nginx: the configuration file /application/nginx-1.8.0/conf/nginx.conf syntax is ok
nginx: configuration file /application/nginx-1.8.0/conf/nginx.conf test is successful
#啟動服務
[root@local nginx-1.8.0]# /application/nginx/sbin/nginx
#埠檢查
[root@local nginx-1.8.0]# netstat –lnt
#檢查進程
[root@local nginx-1.8.0]# ps -ef | grep nginx #埠信息保存在
/application/nginx/logs/ nginx.pid 文件中
#通過埠查看佔用進程
[root@local nginx-1.8.0]# lsof -i :80
#錯誤日誌
/application/nginx/logs/error.log

三、編寫nginx服務腳本
為了方便使用習慣,通過server 來啟動、關閉、開啟、重載nginx服務所以我們來編
寫nginx的服務腳本(自己編寫的腳本僅供參考!)
[root@local ~]# vim /etc/init.d/nginx
#!/bin/bash
#chkconfig: - 99 20
#description:Nginx Server Contorl Script
PROG="/application/nginx/sbin/nginx"
PIDF="/application/nginx/logs/nginx.pid"
ok=`echo -e "\e[1;31m [ok] \e[0m"`
no=`echo -e "\e[1;31m [no] \e[0m"`
detection=`/application/nginx/sbin/nginx -t 2>&1`
screen_1=`echo $detection | awk '{print $6,$7,$8}'`
screen_2=`echo $detection | awk '{print $13,$14,$15}'`
if [ "$screen_1" = "syntax is ok" ] && [ "$screen_2" = "test is successful" ];
then
case "$1" in
start)
$PROG
echo "Nginx Is starting state $ok"
;;
stop)
kill -s QUIT $(cat $PIDF)
echo "Nginx Is closing state $ok"
;;
restart)
$0 stop
$0 start
echo "Nginx Is to restart state $ok"
;;
reload)
kill -s HUP $(cat $PIDF)
echo "Nginx Is overloaded state $ok"
;;
*)
echo "Usage: $0 (start|stop|restart|reload)"
exit 1
esac
else
echo "Nginx check state $no "
echo "Please check the configuration file"
echo "$detection"
fi
exit 0

[root@local ~]# chmod +x /etc/init.d/nginx
[root@local ~]# chkconfig –add nginx #添加為系統服務
[root@local ~]# chkconfig nginx on

四、簡單的nginx web站點
Nginx的默認站點目錄,是安裝目錄下的html這里是(/application/nginx/html)
在主配置文件/application/nginx/conf/nginx.conf 中查看,對於重新部署web頁面
只需將/application/nginx/html/中的index.html替換即可
主配置文件講解

[root@local ~]# egrep -v "#|^$" /application/nginx/conf/nginx.conf
worker_processes 1; #指定Nginx開啟的進程數
events { #設定Nginx的工作模式及連接數上線
worker_connections 1024;
}
http {
include mime.types; #主模塊命令,實現對配置文件所有包含文件的設置
default_type application/octet-stream; #屬於http核心模塊命令,這里設
置類型為二進制流,也就是當文件類型未定義時使用這種方式,例如,沒有配置php
環境時,nginx是不給予解析的,此時,用瀏覽器訪問PHP文件就會出現下載窗口。
sendfile on; #用於高效文件傳輸模式
keepalive_timeout 65; 設置客戶端請求頭文件讀取超時時間,如果超過這個時
間伺服器會關閉該連接。
server { #定義虛擬主機開始的關鍵字
listen 80; #用於指定虛擬主機的服務埠
server_name localhost; 用於指定ip地址或者域名,多個域名用空格隔開
location / {
root html;
index index.html index.htm; #用於設定訪問的默認首頁
}
error_page 500 502 503 504 /50x.html;# 靜態頁面重定向伺服器錯誤
頁面,例如攜程的網站崩潰出現的頁面
location = /50x.html {
root html;
}
}
}

⑵ 為什麼 centos 7 安裝 nginx 後顯示 Welcome to nginx on Fedora

安裝環境為:最小化安裝的centos7,關閉seliunx。最小化安裝centos:關閉selinuxsed–i『s/SELINUX=enforcing/SELINUX=disabled/g』/etc/selinux/config開始安裝nginx1.7.8創建群組groupaddpilerccisnotfound解決方法:yuminstallgccgcc-c++如果有錯誤提示:./configure:error:.–without-http_rewrite_moleoption,,–with-pcre=option.解決方法:yuminstallpcre-devel如果有錯誤提示:./configure:error:.,,–with-openssl=option.解決方法:yuminstallopenssl-devel以上錯誤提示依次解決後:再一次的運行./configure--user=www--group=www--prefix=/usr/local/nginx--with-http_stub_status_mole--with-http_ssl_mole--with-http_gzip_static_molemakemekeinstall編譯參數解釋:#指定運行許可權的用戶--user=www#指定運行的許可權用戶組--group=www#指定安裝路徑--prefix=/usr/local/nginx#支持nginx狀態查詢--with-http_stub_status_mole#開啟ssl支持--with-http_ssl_mole#開啟GZIP功能--with-http_gzip_static_mole因此要順利的通過nginx編譯安裝必須安裝的依賴關系有:yuminstallgcgccgcc-c++pcre-develzlib-developenssl-devel2、在centos7中為nginx的啟動、重啟、重載配置添加腳本nginx直接啟動的方法:/usr/local/nginx/sbin/nginx但是不是很方便,因此使用下面的腳本來控制nginx的啟動關閉重載更加合理一些。編輯文件:vim/usr/lib/systemd/system/nginx.service添加下面的腳本,注意路徑![Unit]Description=nginx-=kill-sQUIT$MAINPIDPrivateTmp=true[Install]WantedBy=multi-user.targetsystemctl的一些使用方法:systemctlis-enabledservicename.service#查詢服務是否開機啟動systemctlenablexxx.service#開機運行服務systemctldisablexxx.service#取消開機運行systemctlstartxxx.service#啟動服務systemctlstopxxx.service#停止服務systemctlrestartxxx.service#重啟服務systemctlreloadxxx.service#重新載入服務配置文件systemctlstatusxxx.service#查詢服務運行狀態systemctl--failed#顯示啟動失敗的服務因此,添加上面腳本後,centos7中操作nginx的方法有systemctlis-enablednginx.service#查詢nginx是否開機啟動systemctlenablenginx.service#開機運行nginxsystemctldisablenginx.service#取消開機運行nginxsystemctlstartnginx.service#啟動nginxsystemctlstopnginx.service#停止nginxsystemctlrestartnginx.service#重啟nginxsystemctlreloadnginx.service#重新載入nginx配置文件systemctlstatusnginx.service#查詢nginx運行狀態systemctl--failed#顯示啟動失敗的服務

⑶ nginx啟動失敗了,怎麼解決centos7

你這個是安裝nginx時出現錯誤了,你是通過yum安裝的,還是apt-get?這兩種方式安裝會生成一些非原生的東西,比如說使用apt-get安裝,它會生成兩個配置文件,一個是原生的nginx.conf,還有一個叫user.conf吧,具體什麼名忘了,是以前一個同事這么安裝我看到的。就是說,你使用這樣安裝它會生成一些跟編譯安裝不一樣的東西,如果這些東西裡面有哪個不正確就會出錯,建議你重新安裝一下。如果你使用yum安裝的,那麼使用yum -e卸載重新再試一次。
不過我還是建議你使用編譯安裝,編譯安裝的方式不會生成那麼多自己不知道的東西,全部都在一個文件夾下面,一個make&&make install就行了,你網上搜一下相關資料

⑷ 裝了幾次centos7了。每次配完nginx重啟再開機開到一半就黑屏。在線等

發出來安裝ngnix步驟
腳本安裝的話注意下添加到服務的步驟看下是否有誤把系統之前的服務搞沒有了

⑸ 如何在 CentOS 7 用 cPanel 配置 Nginx 反向代理

第一步: 安裝 EPEL 庫
root@server1 [/usr]# yum -y install epel-release
Loaded plugins: fastestmirror, tsflags, universal-hooks
Loading mirror speeds from cached hostfile
* EA4: 66.23.237.210
* base: mirrors.linode.com
* extras: mirrors.linode.com
* updates: mirrors.linode.com
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-5 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================
Package Arch Version Repository Size
========================================================================================
Installing:
epel-release noarch 7-5 extras 14 k

第二步: 安裝 nDeploy 的 CentOS RPM 庫
可以安裝 nDeploy 的 CentOS RPM 庫來安裝我們所需的 nDeploy Web 類軟體和 Nginx 插件
root@server1 [/usr]# yum -y install http://rpm.piserve.com/nDeploy-release-centos-1.0-1.noarch.rpm
Loaded plugins: fastestmirror, tsflags, universal-hooks
nDeploy-release-centos-1.0-1.noarch.rpm | 1.7 kB 00:00:00
Examining /var/tmp/yum-root-ei5tWJ/nDeploy-release-centos-1.0-1.noarch.rpm: nDeploy-release-centos-1.0-1.noarch
Marking /var/tmp/yum-root-ei5tWJ/nDeploy-release-centos-1.0-1.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package nDeploy-release-centos.noarch 0:1.0-1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================
Package Arch Version Repository Size
========================================================================================
Installing:
nDeploy-release-centos noarch 1.0-1 /nDeploy-release-centos-1.0-1.noarch 110

第三步:安裝 nDeploy 和 Nginx nDeploy 插件
root@server1 [/usr]# yum --enablerepo=ndeploy install nginx-nDeploy nDeploy
Loaded plugins: fastestmirror, tsflags, universal-hooks
epel/x86_64/metalink | 9.9 kB 00:00:00
epel | 4.3 kB 00:00:00
ndeploy | 2.9 kB 00:00:00
(1/4): ndeploy/7/x86_64/primary_db | 14 kB 00:00:00
(2/4): epel/x86_64/group_gz | 169 kB 00:00:00
(3/4): epel/x86_64/primary_db | 3.7 MB 00:00:02

Dependencies Resolved

========================================================================================
Package Arch Version Repository Size
========================================================================================
Installing:
nDeploy noarch 2.0-11.el7 ndeploy 80 k
nginx-nDeploy x86_64 1.8.0-34.el7 ndeploy 36 M
Installing for dependencies:
PyYAML x86_64 3.10-11.el7 base 153 k
libevent x86_64 2.0.21-4.el7 base 214 k
memcached x86_64 1.4.15-9.el7 base 84 k
python-inotify noarch 0.9.4-4.el7 base 49 k
python-lxml x86_64 3.2.1-4.el7 base 758 k

Transaction Summary
========================================================================================
Install 2 Packages (+5 Dependent packages)

通過以上這些步驟,我們完成了在我們的伺服器上 Nginx 插件的安裝。現在我們可以配置 Nginx 作為反向代理和為已有的 cPanel 用戶賬戶創建虛擬主機,為此我們可以運行如下腳本。
第四步:啟動 Nginx 作為默認的前端 Web 伺服器,並創建默認的配置文件
root@server1 [/usr]# /opt/nDeploy/scripts/cpanel-nDeploy-setup.sh enable
Modifying apache http and https port in cpanel

httpd restarted successfully.
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/ndeploy_watcher.service to /usr/lib/systemd/system/ndeploy_watcher.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/ndeploy_backends.service to /usr/lib/systemd/system/ndeploy_backends.service.
ConfGen:: saheetha
ConfGen:: satest

你可以看到這個腳本將修改 Apache 的埠從 80 到另一個埠來讓 Nginx 作為前端 Web 伺服器,並為現有的 cPanel 用戶創建虛擬主機配置文件。一旦完成,確認 Apache 和 Nginx 的狀態。
Apache 狀態:
root@server1 [/var/run/httpd]# systemctl status httpd
● httpd.service - Apache Web Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2016-01-18 06:34:23 UTC; 12s ago
Process: 25606 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 24760 (httpd)
CGroup: /system.slice/httpd.service
‣ 24760 /usr/local/apache/bin/httpd -k start

Jan 18 06:34:23 server1.centos7-test.com systemd[1]: Starting Apache Web Server...
Jan 18 06:34:23 server1.centos7-test.com apachectl[25606]: httpd (pid 24760) already running
Jan 18 06:34:23 server1.centos7-test.com systemd[1]: Started Apache Web Server.

Nginx 狀態:
root@server1 [~]# systemctl status nginx
● nginx.service - nginx-nDeploy - high performance web server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: active (running) since Sun 2016-01-17 17:18:29 UTC; 13h ago
Docs: http://nginx.org/en/docs/
Main PID: 3833 (nginx)
CGroup: /system.slice/nginx.service
├─ 3833 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
├─25473 nginx: worker process
├─25474 nginx: worker process
└─25475 nginx: cache manager process

Jan 17 17:18:29 server1.centos7-test.com systemd[1]: Starting nginx-nDeploy - high performance web server...
Jan 17 17:18:29 server1.centos7-test.com nginx[3804]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Jan 17 17:18:29 server1.centos7-test.com nginx[3804]: nginx: configuration file /etc/nginx/nginx.conf test is successful
Jan 17 17:18:29 server1.centos7-test.com systemd[1]: Started nginx-nDeploy - high performance web server.

Nginx 作為前端伺服器運行在 80 埠,Apache 配置被更改為監聽 http 埠 9999 和 https 埠 4430。請看他們的情況:
root@server1 [/usr/local/src]# netstat -plan | grep httpd
tcp 0 0 0.0.0.0:4430 0.0.0.0:* LISTEN 17270/httpd
tcp 0 0 0.0.0.0:9999 0.0.0.0:* LISTEN 17270/httpd
tcp6 0 0 :::4430 :::* LISTEN 17270/httpd
tcp6 0 0 :::9999 :::* LISTEN 17270/httpd

root@server1 [/usr/local/src]# netstat -plan | grep nginx
tcp 0 0 127.0.0.1:80 0.0.0.0:* LISTEN 17802/nginx: master
tcp 0 0 45.79.183.73:80 0.0.0.0:* LISTEN 17802/nginx: master

為已有用戶創建的虛擬主機的配置文件在 「/etc/nginx/sites-enabled」。 這個文件路徑包含了 Nginx 主要配置文件。
root@server1 [/etc/nginx/sites-enabled]# ll | grep .conf
-rw-r--r-- 1 root root 311 Jan 17 09:02 saheetha.com.conf
-rw-r--r-- 1 root root 336 Jan 17 09:02 saheethastest.com.conf

一個域名的示例虛擬主機:
server {

listen 45.79.183.73:80;
#CPIPVSIX:80;

# ServerNames
server_name saheetha.com www.saheetha.com;
access_log /usr/local/apache/domlogs/saheetha.com main;
access_log /usr/local/apache/domlogs/saheetha.com-bytes_log bytes_log;

include /etc/nginx/sites-enabled/saheetha.com.include;

}

我們可以啟動瀏覽器查看網站來確定 Web 伺服器的工作狀態。安裝後,請閱讀伺服器上的 web 服務信息。
root@server1 [/home]# ip a | grep -i eth0
3: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
inet 45.79.183.73/24 brd 45.79.183.255 scope global dynamic eth0
root@server1 [/home]# nginx -v
nginx version: nginx/1.8.0

Nginx 將會為任何最新在 cPanel 中創建的賬戶創建虛擬主機。通過這些簡單的的步驟,我們能夠在一台 CentOS 7 / cPanel 的伺服器上配置 Nginx 作為反向代理。
Nginx 作為反向代理的優勢
便於安裝和配置。
效率高、性能好。
防止 Ddos 攻擊。
支持使用 .htaccess 作為 PHP 的重寫規則。

⑹ 如何安裝nginx

nginx
windows版
v1.13.3免費版http://www.ddooo.com/softdown/29113.htm
nginx
windows安裝配置方法
第一步、安裝方法
一、下載好後,把nginx
windows版軟體解壓到c盤根目錄。
二、雙擊nginx.exe圖標,可見黑窗口一閃而過,啟動完畢。
三、按下win+R快捷鍵,輸入cmd打開命令行。
四、命令行到nginx目錄,輸入nginx啟動。(注,此方式命令行窗口無任何提示,且被鎖定)
五、打開瀏覽器,輸入http://127.0.0.1,如果看到下圖片則安裝成功。
六、以後啟動軟體直接雙擊圖標即可。
七、啟動後,默認情況下(無修改配置),可見到有兩個nginx的進程,一個是master
process,一個是worker
processes測試。
第二步、配置方法
配置目標:能正常運行PHP腳本程序
大部分情況下,我們需要修改的配置文件只有一個,那就是nginx.conf,該文件位於conf目錄下。具體配置項目為:
1.
server_tokens
off;
出於安全方面的考慮,最好是隱藏nginx版本號信息
2.
listen
8088;
8088為監聽埠,根據需要可以填寫其它埠號
3.
server_name
localhost;
localhost為伺服器訪問名稱,也就是我們在瀏覽器里輸入的那個url地址
4.
charset
utf-8;
字元集編碼
5.
工作目錄
將如下配置
修改為:
root
定義了工作空間,也就是我們php項目所在的目錄。
加入index.php是為了讓nginx能夠識別php腳本,否則,在訪問php文件時,會出現直接下載的情況。
6.
整合php
將location
~
\.php配置部分的注釋全部去掉,最終配置如下:
注意這裡面的$document_root變數,它對應的內容就是root參數值,如果我們沒有定義root參數或者把root注釋掉,在訪問php的時候,頁面上就會出現No
input
file
specified.提示。
7.
啟動php-cgi
打開cmd命令窗口,切換到php的安裝目錄,執行php-cgi
-b
127.0.0.1:9000,即可啟動php-cgi,啟動完成後,cmd窗口切勿關閉,否則php-cgi也會被關掉的。
特別提醒:只有在開啟php-cgi的情況下,nginx才能正常訪問php。
8.
重啟nginx
打開cmd命令窗口,切換到nginx所在目錄,執行nginx
-s
reload即可重啟nginx。其它相關nginx相關命令如下:
啟動:start
nginx
停止:nginx
-s
stop
退出:nginx
-s
quit

⑺ centos 7 啟動程序 帶參數d 是什麼意思

首先,系統貌似沒有加 d 的參數,除非程序是你自己開發的特定程序,加d為特定參數。
linux 添加開機啟動項的三種方法。
(1)編輯文件 /etc/rc.local
輸入命令:vim /etc/rc.local 將出現類似如下的文本片段:
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
/etc/init.d/mysqld start #mysql開機啟動
/etc/init.d/nginx start #nginx開機啟動
/etc/init.d/php-fpm start #php-fpm開機啟動
/etc/init.d/memcached start #memcache開機啟動
#在文件末尾(exit 0之前)加上你開機需要啟動的程序或執行的命令即可(執行的程序需要寫絕對路徑,添加到系統環境變數的除外),如:
/usr/local/thttpd/sbin/thttpd -C /usr/local/thttpd/etc/thttpd.conf

(2)自己寫一個shell腳本
將寫好的腳本(.sh文件)放到目錄 /etc/profile.d/ 下,系統啟動後就會自動執行該目錄下的所有shell腳本。
(3)通過chkconfig命令設置
將啟動文件cp到 /etc/init.d/或者/etc/rc.d/init.d/(前者是後者的軟連接)下
vim 啟動文件,文件前面務必添加如下三行代碼,否側會提示chkconfig不支持
#!/bin/sh 告訴系統使用的shell,所以的shell腳本都是這樣
#chkconfig: 35 20 80 分別代表運行級別,啟動優先權,關閉優先權,此行代碼必須
#description: http server(自己隨便發揮)//兩行都注釋掉!!!,此行代碼必須
chkconfig --add 腳本文件名 操作後就已經添加了

⑻ centos7怎麼編譯安裝nginx

安裝環境為:最小化安裝的centos7,關閉seliunx。
最小化安裝centos:
關閉selinux
sed –i 『s/SELINUX=enforcing/SELINUX=disabled/g』 /etc/selinux/config

開始安裝nginx1.7.8
創建群組
groupadd www
創建一個用戶,不允許登陸和不創主目錄
useradd -s /sbin/nologin -g www -M www
#下載最新版nginx
wget -C http://nginx.org/download/nginx-1.7.8.tar.gz
tar zxvf nginx-1.7.8.tar.gz
#編譯基本能運行的nginx
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_mole --with-http_ssl_mole --with-http_gzip_static_mole
make
make install

如果有錯誤提示:
./configure: error: C compiler cc is not found
解決方法:
yum install gcc gcc-c++

如果有錯誤提示:
./configure: error: the HTTP rewrite mole requires the PCRE library.
You can either disable the mole by using –without-http_rewrite_mole
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using –with-pcre=<path> option.
解決方法:
yum install pcre-devel

如果有錯誤提示:
./configure: error: SSL moles require the OpenSSL library.
You can either do not enable the moles, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using –with-openssl=<path> option.
解決方法:
yum install openssl-devel

以上錯誤提示依次解決後:再一次的運行
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_mole --with-http_ssl_mole --with-http_gzip_static_mole
make
meke install

編譯參數解釋:
#指定運行許可權的用戶
--user=www
#指定運行的許可權用戶組
--group=www
#指定安裝路徑
--prefix=/usr/local/nginx
#支持nginx狀態查詢
--with-http_stub_status_mole
#開啟ssl支持
--with-http_ssl_mole
#開啟GZIP功能
--with-http_gzip_static_mole

因此要順利的通過nginx編譯安裝必須安裝的依賴關系有:
yum install gc gcc gcc-c++ pcre-devel zlib-devel openssl-devel

2、在 centos7 中為nginx的啟動、重啟、重載配置添加腳本
nginx直接啟動的方法:
/usr/local/nginx/sbin/nginx

但是不是很方便,因此使用下面的腳本來控制nginx的啟動關閉重載更加合理一些。
編輯文件:vim /usr/lib/systemd/system/nginx.service 添加下面的腳本,注意路徑 !
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

systemctl的一些使用方法:
systemctl is-enabled servicename.service #查詢服務是否開機啟動
systemctl enable xxx.service #開機運行服務
systemctl disable xxx.service #取消開機運行
systemctl start xxx.service #啟動服務
systemctl stop xxx.service #停止服務
systemctl restart xxx.service #重啟服務
systemctl reload xxx.service #重新載入服務配置文件
systemctl status xxx.service #查詢服務運行狀態
systemctl --failed #顯示啟動失敗的服務

因此,添加上面腳本後,centos7 中操作nginx的方法有
systemctl is-enabled nginx.service #查詢nginx是否開機啟動
systemctl enable nginx.service #開機運行nginx
systemctl disable nginx.service #取消開機運行nginx
systemctl start nginx.service #啟動nginx
systemctl stop nginx.service #停止nginx
systemctl restart nginx.service #重啟nginx
systemctl reload nginx.service #重新載入nginx配置文件
systemctl status nginx.service #查詢nginx運行狀態
systemctl --failed #顯示啟動失敗的服務

熱點內容
內置存儲卡可以拆嗎 發布:2025-05-18 04:16:35 瀏覽:336
編譯原理課時設置 發布:2025-05-18 04:13:28 瀏覽:378
linux中進入ip地址伺服器 發布:2025-05-18 04:11:21 瀏覽:612
java用什麼軟體寫 發布:2025-05-18 03:56:19 瀏覽:32
linux配置vim編譯c 發布:2025-05-18 03:55:07 瀏覽:107
砸百鬼腳本 發布:2025-05-18 03:53:34 瀏覽:944
安卓手機如何拍視頻和蘋果一樣 發布:2025-05-18 03:40:47 瀏覽:741
為什麼安卓手機連不上蘋果7熱點 發布:2025-05-18 03:40:13 瀏覽:803
網卡訪問 發布:2025-05-18 03:35:04 瀏覽:511
接收和發送伺服器地址 發布:2025-05-18 03:33:48 瀏覽:372