聰明屋視角
關注互聯(lián)網,關注技術開發(fā),透析與分享移動互聯(lián)網行業(yè)最新動態(tài)Nginx安裝配置詳解
時間:2019-02-17 13:38:20 閱讀:79011次 分類:解決方案
yum install nginx
啟動 sbin/nginx 重啟 /usr/sbin/nginx -s reload
/usr/share/nginx/html
首先執(zhí)行命令找到nginx路徑
ps aux | grep nginx
如nginx路徑為
/usr/local/nginx/sbin/nginx
然后執(zhí)行以下命令
/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
{
#監(jiān)聽的端口
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年,經過10多年定制開發(fā)經驗,積累了大量技術儲備和定制開發(fā)經驗,率先創(chuàng)建安徽省內自主研發(fā)的云計算平臺,具有大數據、高并發(fā)等高強度計算能力,為眾多政府、學校、公安部門、中小企業(yè)解決數據計算與管理難題。2013年公司內部專門創(chuàng)建電商服務部,為企業(yè)提供全方位電商解決方案與配套服務。多次獲得國家、省市級領導接見,被國內近20家電視臺、報紙媒體爭相報道。至今,聰明屋智能科技服務過上市公司、大型國企、各類私企超800家,為多家公司提供各類政務系統(tǒng)、app開發(fā)定制、微信小程序開發(fā)定制、智能家居、電商系統(tǒng)、連鎖收銀等技術解決方案服務。同時,聰明屋智能科技在智能硬件方面、區(qū)塊鏈應用方面持續(xù)投入關注及創(chuàng)新。