1.ソースパッケージをダウンロードコンパイル解凍します
ビューnginxのパッケージパス:http://nginx.org/download/、2つのダウンロード方法:
1、Xftpをダウンロードする公式サイトでは、Linuxにアップロード(推奨されません)
2、次のように:(ダウンロード、選択されたバージョンにダウンロードするためのダイレクトコマンドを(推奨)のnginx-1.16.1.tar.gzのバージョンは)それがホームディレクトリに推奨されるコマンドを実行し、見つけるのは簡単
wgetののhttp:// nginx.org/download/ nginxの-1.16.1.tar.gz
これは、インストールされています
3、解凍
nginx-あるxvタール1.16。1 .tar.gzの-Cは/ usr / local / srcに/
4、適切なツールをインストールします
groupinstall yumの" 開発ツール" のyumのgccのwgetのgcc-C ++のautomake autoconfのlibtoolののlibxml2-develののlibxsltの-develのperlの-develのperlの-のExtUtils-埋め込みPCRE-のdevel opensslの-develのインストール-y
5、nginxのをコンパイルしてインストールするディレクトリを入力します。
ディレクトリへの1、
CDは/ usr / local / srcに/ nginx- 1.16。1
2次のコマンドを直接貼り付けることができ、実行
./ 設定\ --prefix =は/ usr / local / nginxの\ --sbinパス=は/ usr / sbinに/ nginxの\ --confパス=の/ etc / nginxの/ nginx.conf \ --errorログパス= / VAR /ログ/ nginxの/ error.logファイル\ --http-ログパス= / VAR /ログ/ nginxの/ access.logを\ --pid-パス= / VAR /実行/ nginx.pid \ - ロック -パス= / VAR /実行/ nginxの。ロック\ --http-クライアント・ボディTEMPパス= / VARを/ tmp / nginxの/ クライアント\ --http-プロキシTEMPパス= / VARを/ tmp / nginxの/ プロキシ\ --http-のfastcgi-temp-パス= /VARは/ tmp / nginxの/ FCGI \ --http-uwsgi-TEMPパス= / VARを/ tmp / nginxの/ uwsgi \ --http-SCGI-TEMPパス= / 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- メール\ --with- mail_ssl_module \ --with-ファイル- AIO \ --with- IPv6の\ --with- http_v2_module \ --with- スレッド\ --with- ストリーム\ --with-stream_ssl_module
3、コンパイルと完全なインストール
make installを&&作り
ます。mkdir -pvの/ var / tmpに/ nginxの/クライアント
6、SysVの起動スクリプトを追加
1、ファイルを作成します
我々は/etc/init.d/nginx
2.私は、編集モードに入ります
#!/ / shのビン
#の
#のnginxの-このスクリプトが起動し、nginxのデーモンを停止する
#の
#1のchkconfig: - 85 15
#説明:nginxのはHTTPですが(S)、サーバ、HTTP(S)リバース\
#プロキシとIMAP / POP3プロキシサーバ
#1 ProcessNameの:nginxの
#の設定:/etc/nginx/nginx.conf
#の設定:の/ etc /のsysconfig / nginxの
#pidファイル:/var/run/nginx.pid
#のソース関数ライブラリ。
。/etc/rc.d/init.d/functions
#のソースの構成ネットワーキング。
。の/ etc / sysconfig / networkファイルの
ネットワークが稼働していることを確認#。
[ "$のNETWORKING" = "NO"] &&出口0
nginxの= "は/ usr / sbinに/ nginxの"
PROG = $(ベース名$ nginxの)
NGINX_CONF_FILE = "の/ etc / nginxの/ nginx.conf"
[-fの/ etc /のsysconfig / nginxの] &&。の/ etc /のsysconfig / nginxの
ロックファイル=の/ var /ロック/ SUBSYS / nginxの
開始(){
[-x $ nginxの] || 5番出口
[-f $ NGINX_CONF_FILE] || 6番出口は
:$ "$ progの起動" -nエコー
デーモン$ nginxの-c $ NGINX_CONF_FILE
のretval = $を?
エコー
[$ RETVAL -eq 0] &&タッチ$ロックファイルの
戻りの$ RETVAL
}
(停止){
エコー-n $ "$のPROGを停止:"
killproc $ PROG -QUIT
RETVAL = $?
エコー
[$ retvalの-eq 0] &&
RM -f $ロックファイルを返す$ RETVAL
のkillall -9 nginxの
}
リスタート(){
configtestを|| $返しますか?
停止
スリープ1つの
スタート
}
{)(リロード
設定試験|| $返しますか?
: "$ progのリロード" -n $エコー
killproc $ nginxの-HUP
RETVAL = $を?
エコー
}
force_reload(){
再起動
}
configtestを(){
$ nginxの-t -c $ NGINX_CONF_FILE
}
rh_statusを(){
ステータスの$ PROG
}
rh_status_q(){
rh_status>を/ dev / null 2>&1
}
の場合に"$ 1"
の開始)
rh_status_q &&終了0
$ 1
;;
停止)
rh_status_q || 終了0
$ 1
;;
リスタート|設定試験)
$ 1
;;
リロード)
rh_status_q || 7番出口
$ 1
;;
力リロード)
force_reload
;;
状態)
rh_status
;;
condrestart |トライ再起動)
rh_status_q || 終了0
;;
*)
エコー$ "使用上の:$ 0 {開始|停止|状況|再起動| condrestart |試す再始動|力リロード| |リロード設定試験を}"
2番出口
ESAC
7.スクリプトの実行権限を与えます
chmodの+ X /etc/init.d/nginx
8. nginxのサーバープロセスのユーザーを追加します。
groupaddの- Rのnginx
のuseradd -r -g nginxのnginxの
9は、カイからの起動を設定し、サービス管理のリストに追加されました
chkconfigを- nginxの追加
chkconfigをnginxの上を
10、nginxの起動
systemctl停止firewalld:ファイアウォールをオフにします
サービスnginxの開始