云樞智聯視角
關注互聯網,關注技術開發,透析與分享移動互聯網行業最新動態Nginx安裝配置詳解
時間:2019-02-17 13:38:20 閱讀:20063次 分類:APP開發
yum install nginx
啟動 sbin/nginx 重啟 /usr/sbin/nginx -s reload
/usr/share/nginx/html
首先執行命令找到nginx路徑
ps aux | grep nginx
如nginx路徑為
/usr/local/nginx/sbin/nginx
然后執行以下命令
/usr/local/nginx/sbin/nginx -V
默認放在 安裝目錄下 conf/nginx.conf
3)開機自啟動nginx
這里使用的是編寫shell腳本的方式來處理
vi /etc/init.d/nginx (輸入下面的代碼)
#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
# it is v.0.0.2 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
nginxd=/usr/local/nginx/sbin/nginx
nginx_config=/usr/local/nginx/conf/nginx.conf
nginx_pid=/var/run/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: "
#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
建設虛擬機 /etc/nginx/nginx.conf
http
{
#第一個虛擬主機
server
{
#監聽的端口
listen 80;
#主機名稱
server_name aaa.domain.com
#訪問日志文件存放路徑
access_log log/aaa.domain.com.access.log combined;
location/
{
#默認首頁文件,順序從左到右,如果找不到index.html文件,則查找index.htm文件作為首頁文件
index index.html index.htm;
#HTML網頁文件存放的目錄
root /data0/htddocs/aaa.domain.com;
云樞智聯(海南)信息技術有限公司(原中江網絡),成立于2005年,經過20多年定制開發經驗,積累了大量技術儲備和定制開發經驗,是一家集軟件研發、互聯網應用為一體的綜合信息技術服務提供商。公司擁有核心的策劃團隊和專業的技術研發團隊,致力于采用領先的信息技術,長期為涉及智慧園區/廠區/校園領域的各個企業提供快速、高效、安全的信息技術支持。公司立足智慧園區和智慧教育行業,通過軟硬件的研發和互聯網應用,疏通各企業間“端到端”的信息傳輸,靈活滿足智慧園區和智慧教育企業間不同用戶的需求,為其提供完善的信息化解決方案。
園區管理系統,提供智慧園區綜合管理系統,智慧園區設計方案咨詢,智慧園區管理系統、...