• Nginx使用笔记


      本篇记录使用Nginx的一些tricks。

    一、更改默认Web根目录

    修改配置文件

      Nginx默认的Web根目录是:/usr/share/nginx/html/,一般我们都是习惯的是:/var/www/html。现进行更改,具体操作如下:

    [lz@mail ~]$ sudo cat /etc/nginx/conf.d/default.conf 
    server {   
        listen       80;
        server_name  192.168.202.129;
    
        root /var/www/html;
    
        index index.php index.html index.htm;
       
        location / {
            try_files $uri $uri/ =404;
        }
        error_page 404 /404.html;
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
            root /var/www/html;
        }
    
        location ~ .php$ {
            try_files $uri =404;
            fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }
    }

      修改root处的配置为: root /var/www/html;

    重启服务

    [lz@mail ~]$ sudo service nginx restart
    Redirecting to /bin/systemctl restart  nginx.service
    [lz@mail ~]$ sudo service nginx status
    Redirecting to /bin/systemctl status  nginx.service
    ● nginx.service - nginx - high performance web server
       Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
       Active: active (running) since 五 2018-08-17 16:49:06 CST; 6s ago
         Docs: http://nginx.org/en/docs/
      Process: 3768 ExecStop=/bin/kill -s TERM $MAINPID (code=exited, status=0/SUCCESS)
      Process: 3773 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
     Main PID: 3774 (nginx)
       CGroup: /system.slice/nginx.service
               ├─3774 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
               └─3775 nginx: worker process
    
    8月 17 16:49:06 mail.starnight.com systemd[1]: Starting nginx - high performance web server...
    8月 17 16:49:06 mail.starnight.com systemd[1]: Started nginx - high performance web server.

    References:

      centos6.4下配置nginx服务器更改根目录

  • 相关阅读:
    一个简单粗暴的爬虫
    Linux 目录结构
    python 部署 Restful web
    JVM 运行时数据区总结 栈 堆 堆大小配置总结
    成都法律援助申请流程
    JavaEE error整理(不断更新)
    ehcache.xml 属性大全
    SpringMVC 构建Restful风格 及问题处理
    Http Content-Type
    Redis 教程 Java工程师学习知识点
  • 原文地址:https://www.cnblogs.com/Hi-blog/p/9494210.html
Copyright © 2020-2023  润新知