zoukankan      html  css  js  c++  java
  • ubuntu server nginx 安装与配置

    ubuntu server nginx 安装与配置

    一:关于nginx

         http://wiki.ubuntu.org.cn/Nginx

         http://nginx.org/cn

      http://wiki.nginx.org/NginxChs

    二:ubuntu server 安装

         如果你之前安装了 apache2服务,请先停止掉

         sudo service apache2 stop

         sudo apt-get install nginx #安装

         

         安装完成之后,打开  localhost测试

         安装成功之后,默认会开启nginx服务,可自行关闭,启动,重启

         sudo service nginx stop,start,restart

        

    三:nginx配置

    • 配置文件都在 /etc/nginx 下
    • 默认网站在 /usr/share/nginx/ 下
    • 全局配置文件 /etc/nginx/nginx.conf
    • 网站配置文件在 /etc/nginx/site-available 

    四:虚拟主机配置示例

       编辑 sudo /etc/nginx/site-available/default

      添加如下:

     

    示例

    两个虚拟主机(纯静态-html 支持) - Two Virtual Hosts, Serving Static Files
    http {
    : server {
    : listen          80;
    : server_name     www.domain1.com;
    : access_log      logs/domain1.access.log main;
    : location / {
    : index index.html;
    : root  /var/www/domain1.com/htdocs;
    : }
    : }
    : server {
    : listen          80;
    : server_name     www.domain2.com;
    : access_log      logs/domain2.access.log main;
    : location / {
    : index index.html;
    : root  /var/www/domain2.com/htdocs;
    : }
    : }
    }
    虚拟主机标准配置(简化) - A Default Catchall Virtual Host
    http {
    : server {
    : listen          80 default;
    : server_name     _ *;
    : access_log      logs/default.access.log main;
    : location / {
    : index index.html;
    : root  /var/www/default/htdocs;
    : }
    : }
    }
  • 相关阅读:
    第三次博客作业
    多项式求导--三次作业小结
    Python实现批量修改文件名
    汉字编程 —— 第一次个人编程作业
    PAT甲级代码仓库
    谈谈自己 —— 第一次博客作业
    爬取豆瓣网图书TOP250的信息
    HDU1862
    HDU1408
    HDU1302
  • 原文地址:https://www.cnblogs.com/cocoajin/p/3805541.html
Copyright © 2011-2022 走看看