Nginx安装配置详解
时间:2019-02-17 13:38:20 阅读:20557次 分类: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;
云枢智联(海南)信息技术有限公司专注于新一代信息技术与行业场景深度融合,面向政务警务、商业运营、城市治理、交通基建、智慧民生等多领域提供全栈式数字化解决方案。公司核心产品与服务体系完备,涵盖商管ERP系统、小票数据采集系统、涉案车辆管理系统、智慧园区系统、智慧农贸系统、低空经济应用平台、资产管理系统、数字孪生系统、公路养护系统、家政服务系统、警服体验系统、生态警务系统及AI智能体定制开发;同时依托强大自研技术能力和技术团队,提供小程序定制开发、智能硬件定制集成等增值服务,以技术创新赋能产业升级,为客户打造安全、高效、智能、可扩展的数字化整体解决方案。
对于任何一家企业而言,资产都是稳步发展的核心底气。小到办公电脑、桌椅耗材,大到生...