Nginx安装配置详解
时间:2019-02-17 13:38:20 阅读:19700次 分类: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年,经过10多年定制开发经验,积累了大量技术储备和定制开发经验,是一家集软件研发、互联网应用为一体的综合信息技术服务提供商。公司拥有核心的策划团队和专业的技术研发团队,致力于采用领先的信息技术,长期为涉及智慧园区/厂区/校园领域的各个企业提供快速、高效、安全的信息技术支持。公司立足智慧园区和智慧教育行业,通过软硬件的研发和互联网应用,疏通各企业间“端到端”的信息传输,灵活满足智慧园区和智慧教育企业间不同用户的需求,为其提供完善的信息化解决方案。
园区管理系统,提供智慧园区综合管理系统,智慧园区设计方案咨询,智慧园区管理系统、...