zoukankan      html  css  js  c++  java
  • 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服务器更改根目录

  • 相关阅读:
    1-27 awk 基本使用
    计算机网络(一)带宽
    CRC检错技术原理
    Wireshark漫谈(一)
    SQL字符串拼接
    MySQL学习笔记(二)
    MySQL学习笔记(一)
    Java 反射机制(二)
    Java 反射机制(一)
    Windows使用MySQL数据库管理系统中文乱码问题
  • 原文地址:https://www.cnblogs.com/Hi-blog/p/9494210.html
Copyright © 2011-2022 走看看