您好,欢迎来到爱玩科技网。
搜索
您的当前位置:首页Ubuntu下Nginx安装

Ubuntu下Nginx安装

来源:爱玩科技网

1.1 安装Nginx

$sudo apt-get install nginx

  

Ubuntu安装之后的文件结构大致为:

所有的配置文件都在/etc/nginx下,并且每个虚拟主机已经安排在了/etc/nginx/sites-available下

  程序文件在/usr/sbin/nginx

  日志放在了/var/log/nginx中

  并已经在/etc/init.d/下创建了启动脚本nginx

 

1.2 启动Nginx

$sudo /etc/init.d/nginx start

[ ok ] Starting nginx (via systemctl): nginx.service.

 

Nginx的配置文件是 cd /etc/nginx/nginx.conf

vim nginx.conf

cd  /etc/nginx/sites-enabled

vim default

server {
    #服务启动时监听的端口
    listen 80 default_server;
    listen [::]:80 default_server;
    #服务启动时文件加载的路径
    root /var/www/html/wordpress;
    #默认加载的第一个文件
    index index.php index.html index.htm index.nginx-debian.html;
    #页面访问域名,如果没有域名也可以填写_
    server_name www.xiexianbo.xin;

    location / {
        #页面加载失败后所跳转的页面
        try_files $uri $uri/ =404;
    }
    
      
    #以下配置只服务于php
    # 将PHP脚本传递给在127.0.0.1:9000上监听的FastCGI服务器
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        # With php7.0-cgi alone:
        #fastcgi_pass 127.0.0.1:9000;
        # With php7.0-fpm:
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }

    # 如果Apache的文档为root,则拒绝访问.htaccess文件
    location ~ /\.ht {
        deny all;
    }
}

  

新增touch  +文件名

转载于:https://www.cnblogs.com/Lolita-web/p/10574931.html

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- aiwanbo.com 版权所有 赣ICP备2024042808号-3

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务