nginx安裝及自啟動
安裝過程參考 http://www.nginx.cn/install
nginx相關文件 http://www.nginx.cn/doc/index.html
安裝過程
-
準備環境
- 安裝make:
yum -y install gcc automake autoconf libtool make
- 安裝g++:
yum install gcc gcc-c++
- 安裝make:
1、選定原始碼目錄
/usr/local/src
,儲存原始碼2、安裝PCRE庫,注意:若pcre-8.40路徑找不到,到ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/下選取版本號
cd /usr/local/src
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz
tar -zxvf pcre-8.40.tar.gz
cd pcre-8.40
./configure
make
make install
- 3、安裝zlib庫,注意:http://zlib.net/ 下選取最新的版本號
cd /usr/local/src
wget http://zlib.net/zlib-1.2.11.tar.gz
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make
make install
- 4、安裝ssl
cd /usr/local/src
wget https://www.openssl.org/source/openssl-1.0.1t.tar.gz
tar -zxvf openssl-1.0.1t.tar.gz
- 5、安裝nginx
cd /usr/local/src
wget http://nginx.org/download/nginx-1.4.2.tar.gz
tar -zxvf nginx-1.4.2.tar.gz
cd nginx-1.4.2
./configure --sbin-path=/usr/local/nginx/nginx \
--conf-path=/usr/local/nginx/nginx.conf \
--pid-path=/usr/local/nginx/nginx.pid \
--with-http_ssl_module \
--with-pcre=/usr/local/src/pcre-8.40 \
--with-zlib=/usr/local/src/zlib-1.2.11 \
--with-openssl=/usr/local/src/openssl-1.0.1t
make
make install
<br />
-
6、啟動nginx, 安裝成功後nginx在
/usr/local/nginx
目錄下
保證80埠未被佔用,執行/usr/local/nginx/nginx
,啟動nginx,訪問ip,出現Welcome to nginx!
<br /><br />
設定nginx為服務,開機自啟動###
- 在
/etc/init.d
目錄下新建nginx啟動指令碼,其中指令碼內容中的modify部分需要根據自己的安裝目錄來設定:
#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
# it is v.1.12.0 version.
# 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
#modify
nginxd=/usr/local/nginx/nginx #nginx的啟動檔案
nginx_config=/usr/local/nginx/nginx.conf #
nginx_pid=/usr/local/nginx/nginx.pid #
#modify
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: "
#kill -HUP `cat ${nginx_pid}`
killproc $nginxd -HUP
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
<br />
- 新增執行許可權
chmod +x nginx
,設為服務chkconfig --add nginx
,即可開機自啟動。
相關文章
- mysql 的原始碼安裝方法及自動啟動方法MySql原始碼
- AeroSpike安裝及啟動ROS
- Kafka 的安裝及啟動Kafka
- 編譯安裝nginx時配置開機自啟編譯Nginx
- nginx安裝及配置Nginx
- Linux安裝Nginx並配置啟動命令LinuxNginx
- xampp安裝步驟及啟動
- Memcached安裝及啟動指令碼指令碼
- nginx 特點及安裝Nginx
- centos6.9安裝nginx,啟動hexo部落格CentOSNginxHexo
- 安裝nginx並安全地配置和啟動Nginx
- 安裝QTP後,啟動qtp程式自動退出QT
- windows下mongodb的安裝及啟動WindowsMongoDB
- 在Linux裡安裝和啟動nginx的方法LinuxNginx
- Nginx--入門及安裝Nginx
- Nginx安裝及配置詳解Nginx
- 安裝node及vue專案的啟動Vue
- nginx 加入到開機自動啟動Nginx
- linux安裝nginx及配置(一)LinuxNginx
- Centos下安裝FastDFS及Nginx模組CentOSASTNginx
- nginx upload module安裝及使用Nginx
- Nginx為已安裝nginx動態新增模組Nginx
- Ubuntu上安裝Robomongo及新增到啟動器UbuntuGo
- Nginx每天莫名自動重啟問題Nginx
- Linux下Nginx的安裝、升級及動態新增模組LinuxNginx
- mac下安裝nginx及相關配置MacNginx
- Docker Linux快速安裝及Nginx部署DockerLinuxNginx
- Nginx的介紹及安裝過程Nginx
- Linux之換源、Tomcat及jdk的安裝配置和設定Tomcat自動啟動LinuxTomcatJDK
- 【Nginx】Ubuntu 安裝 NginxNginxUbuntu
- [Nginx] Ubuntu 安裝 NginxNginxUbuntu
- 設定開機自啟動nginx和httpdNginxhttpd
- 樹莓派安裝vnc server並設定自啟動樹莓派VNCServer
- Linux下Nginx安裝並開啟SSLLinuxNginx
- 自動取款機 軟體安裝及操作故障總結
- 分享 jdk ant 綠色安裝及自動化配置 for windowsJDKWindows
- Nginx 安裝Nginx
- 安裝nginxNginx