聪明屋视角

关注互联网,关注技术开发,透析与分享移动互联网行业最新动态

Nginx安装配置详解

时间:2019-02-17 13:38:20    阅读:78702次 分类:解决方案
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 ...

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多年定制开发经验,积累了大量技术储备和定制开发经验,率先创建安徽省内自主研发的云计算平台,具有大数据、高并发等高强度计算能力,为众多政府、学校、公安部门、中小企业解决数据计算与管理难题。2013年公司内部专门创建电商服务部,为企业提供全方位电商解决方案与配套服务。多次获得国家、省市级领导接见,被国内近20家电视台、报纸媒体争相报道。至今,聪明屋智能科技服务过上市公司、大型国企、各类私企超800家,为多家公司提供各类政务系统、app开发定制、微信小程序开发定制、智能家居、电商系统、连锁收银等技术解决方案服务。同时,聪明屋智能科技在智能硬件方面、区块链应用方面持续投入关注及创新。

聪明屋智能科技