CentOS7.4安裝Nginx1.14.2過(guò)程及配置
十余年的敦化網(wǎng)站建設(shè)經(jīng)驗(yàn),針對(duì)設(shè)計(jì)、前端、開(kāi)發(fā)、售后、文案、推廣等六對(duì)一服務(wù),響應(yīng)快,48小時(shí)及時(shí)工作處理。全網(wǎng)營(yíng)銷(xiāo)推廣的優(yōu)勢(shì)是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動(dòng)調(diào)整敦化建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無(wú)論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。成都創(chuàng)新互聯(lián)公司從事“敦化網(wǎng)站設(shè)計(jì)”,“敦化網(wǎng)站推廣”以來(lái),每個(gè)客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。
安裝make:
yum?-y?install?gcc?automake?autoconf?libtool?make
安裝g++:
yum?install?gcc?gcc-c++
安裝pcre和pcre-devel
yum?install?-y?pcre?pcre-devel
安裝zlib zlib提供了很多壓縮和解方式,nginx需要zlib對(duì)http進(jìn)行g(shù)zip
yum?install?-y?zlib?zlib-devel
安裝openssl openssl是一個(gè)安全套接字層密碼庫(kù),nginx要支持https,需要使用openssl
yum?install?-y?openssl?openssl-devel
下載nginx
wget?http://nginx.org/download/nginx-1.14.2.tar.gz
解壓
tar?-zxvf?nginx-1.14.2.tar.gz
cd到文件路徑
cd?nginx-1.14.2
編譯
?./configure --prefix=/usr --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/tem/nginx/client --http-proxy-temp-path=/var/tem/nginx/proxy --http-fastcgi-temp-path=/var/tem/nginx/fcgi --with-http_stub_status_module
安裝
make?&&?make?install
創(chuàng)建開(kāi)機(jī)啟動(dòng)命令腳本文件
vim?/etc/init.d/nginx
插入啟動(dòng)腳本代碼
#!/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. [?"$NETWORK"?=?"no"?]?&&?exit?0 nginx="/usr/sbin/nginx"????????????????????????#對(duì)應(yīng)編譯安裝時(shí)的sbin-path prog=$(basename?$nginx) NGINX_CONF_FILE="/etc/nginx/nginx.conf" [?-f?/etc/sysconfig/nginx?]?&&?.?/etc/sysconfig/nginx lockfile=/var/lock/subsys/nginx make_dirs()?{ ??#?make?required?directories ??user=`$nginx?-V?2>&1?|?grep?"configure?arguments:"?|?sed?'s/[^*]*--user=\([^?]*\).*/\1/g'?-` ??if?[?-z?"`grep?$user?/etc/passwd`"?];?then ???useradd?-M?-s?/bin/nologin?$user ??fi ???options=`$nginx?-V?2>&1?|?grep?'configure?arguments:'` ???for?opt?in?$options;?do ???if?[?`echo?$opt?|?grep?'.*-temp-path'`?];?then ???value=`echo?$opt?|?cut?-d?"="?-f?2` ???if?[?!?-d?"$value"?];?then ???#?echo?"creating"?$value ???mkdir?-p?$value?&&?chown?-R?$user?$value ???fi ???fi ???done } start()?{ [?-x?$nginx?]?||?exit?5 [?-f?$NGINX_CONF_FILE?]?||?exit?6 make_dirs 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 } 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
保存
:wq
設(shè)置所有人都有對(duì)這個(gè)啟動(dòng)腳本nginx文件的執(zhí)行權(quán)限
chmod?a+x?/etc/init.d/nginx
把nginx加入系統(tǒng)服務(wù)中
chkconfig --add nginx
1)如果出現(xiàn)[emerg] getpwnam("nginx") failed錯(cuò)誤,執(zhí)行useradd nginx
2)如果出現(xiàn) [emerg] mkdir() “/var/temp/nginx/client” failed (2: No such file or directory) 錯(cuò)誤 執(zhí)行
mkdir -p /var/tem/nginx/client
檢查nginx配置是否成功
nginx -t
啟動(dòng)
nginx?
重啟
nginx -s reload
如果您正在運(yùn)行防火墻,請(qǐng)運(yùn)行以下命令以允許HTTP和HTTPS通信:
?sudo firewall-cmd --permanent --zone=public --add-service=http?
?sudo firewall-cmd --permanent --zone=public --add-service=https
?sudo firewall-cmd --reload
至此服務(wù)器配置完成。
-------------------------------------------------------------------------------------------------------------------------------?
? ? ? ?