实验环境

ubuntu16.04.1

怎么安装

网上有很多安装的教程,自己摸索吧

我是通过sudo apt-get install nginx命令安装的nginx

上述命令执行完,都干了什么?如何找到它的文件在哪呢?

使用locate nginx查看文件位置

ubuntu@VM-90-170-ubuntu:~$ locate nginx
/etc/nginx
/etc/default/nginx
/etc/init/nginx.conf
/etc/init.d/nginx
/etc/logrotate.d/nginx
/etc/nginx/conf.d
/etc/nginx/fastcgi.conf
/etc/nginx/fastcgi_params
/etc/nginx/koi-utf
/etc/nginx/koi-win
/etc/nginx/mime.types
/etc/nginx/nginx.conf
/etc/nginx/proxy_params
/etc/nginx/scgi_params
/etc/nginx/sites-available
/etc/nginx/sites-enabled
/etc/nginx/snippets
/etc/nginx/uwsgi_params
/etc/nginx/win-utf
/etc/nginx/sites-available/default
/etc/nginx/sites-enabled/default
/etc/nginx/snippets/fastcgi-php.conf
/etc/nginx/snippets/snakeoil.conf
/etc/rc0.d/K01nginx
/etc/rc1.d/K01nginx
/etc/rc2.d/S02nginx
/etc/rc3.d/S02nginx
/etc/rc4.d/S02nginx
/etc/rc5.d/S02nginx
/etc/rc6.d/K01nginx
/etc/systemd/system/multi-user.target.wants/nginx.service
/etc/ufw/applications.d/nginx
/lib/systemd/system/nginx.service
/usr/sbin/nginx
/usr/share/nginx
/usr/share/apport/package-hooks/source_nginx.py
/usr/share/doc/nginx
/usr/share/doc/nginx-common
/usr/share/doc/nginx-core
/usr/share/doc/nginx/changelog.Debian.gz
/usr/share/doc/nginx/copyright
/usr/share/doc/nginx-common/NEWS.Debian.gz
/usr/share/doc/nginx-common/README.Debian
/usr/share/doc/nginx-common/changelog.Debian.gz
/usr/share/doc/nginx-common/copyright
/usr/share/doc/nginx-core/changelog.Debian.gz
/usr/share/doc/nginx-core/copyright
/usr/share/lintian/overrides/nginx-common
/usr/share/lintian/overrides/nginx-core
/usr/share/nginx/html
/usr/share/nginx/html/index.html
/usr/share/vim/addons/ftdetect/nginx.vim
/usr/share/vim/addons/indent/nginx.vim
/usr/share/vim/addons/syntax/nginx.vim
/usr/share/vim/registry/nginx.yaml
/var/cache/apt/archives/nginx-common_1.10.3-0ubuntu0.16.04.2_all.deb
/var/cache/apt/archives/nginx-core_1.10.3-0ubuntu0.16.04.2_amd64.deb
/var/cache/apt/archives/nginx_1.10.3-0ubuntu0.16.04.2_all.deb
/var/lib/nginx
/var/lib/dpkg/info/nginx-common.conffiles
/var/lib/dpkg/info/nginx-common.config
/var/lib/dpkg/info/nginx-common.list
/var/lib/dpkg/info/nginx-common.md5sums
/var/lib/dpkg/info/nginx-common.postinst
/var/lib/dpkg/info/nginx-common.postrm
/var/lib/dpkg/info/nginx-common.preinst
/var/lib/dpkg/info/nginx-common.templates
/var/lib/dpkg/info/nginx-core.list
/var/lib/dpkg/info/nginx-core.md5sums
/var/lib/dpkg/info/nginx-core.postinst
/var/lib/dpkg/info/nginx-core.prerm
/var/lib/dpkg/info/nginx.list
/var/lib/dpkg/info/nginx.md5sums
/var/lib/nginx/body
/var/lib/nginx/fastcgi
/var/lib/nginx/proxy
/var/lib/nginx/scgi
/var/lib/nginx/uwsgi
/var/lib/systemd/deb-systemd-helper-enabled/nginx.service.dsh-also
/var/lib/systemd/deb-systemd-helper-enabled/multi-user.target.wants/nginx.service
/var/log/nginx
/var/log/nginx/access.log
/var/log/nginx/access.log.1
/var/log/nginx/access.log.2.gz
/var/log/nginx/error.log
/var/www/html/index.nginx-debian.html
ubuntu@VM-90-170-ubuntu:~$

可以看出

/etc/nginx/nginx.conf文件是配置文件,查看其内容

ubuntu@VM-90-170-ubuntu:/etc/nginx$ pwd
/etc/nginx
ubuntu@VM-90-170-ubuntu:/etc/nginx$ cat nginx.conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;events {worker_connections 768;# multi_accept on;
}http {### Basic Settings##sendfile on;tcp_nopush on;tcp_nodelay on;keepalive_timeout 65;types_hash_max_size 2048;# server_tokens off;# server_names_hash_bucket_size 64;# server_name_in_redirect off;include /etc/nginx/mime.types;default_type application/octet-stream;### SSL Settings##ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLEssl_prefer_server_ciphers on;### Logging Settings##access_log /var/log/nginx/access.log;error_log /var/log/nginx/error.log;### Gzip Settings##gzip on;gzip_disable "msie6";# gzip_vary on;# gzip_proxied any;# gzip_comp_level 6;# gzip_buffers 16 8k;# gzip_http_version 1.1;# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;### Virtual Host Configs##include /etc/nginx/conf.d/*.conf;include /etc/nginx/sites-enabled/*;
}#mail {#   # See sample authentication script at:
#   # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
#   # auth_http localhost/auth.php;
#   # pop3_capabilities "TOP" "USER";
#   # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
#   server {#       listen     localhost:110;
#       protocol   pop3;
#       proxy      on;
#   }
#
#   server {#       listen     localhost:143;
#       protocol   imap;
#       proxy      on;
#   }
#}
ubuntu@VM-90-170-ubuntu:/etc/nginx$ 

看到http下有incluede

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;

遂去探探究竟

发现

  • /etc/nginx/conf.d/文件夹下无内容

  • /etc/nginx/sites-enabled/有一个default文件,内容如下

ubuntu@VM-90-170-ubuntu:/etc/nginx/sites-enabled$ cat default
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
### Default server configuration
#
server {listen 80 default_server;listen [::]:80 default_server;# SSL configuration## listen 443 ssl default_server;# listen [::]:443 ssl default_server;## Note: You should disable gzip for SSL traffic.# See: https://bugs.debian.org/773332## Read up on ssl_ciphers to ensure a secure configuration.# See: https://bugs.debian.org/765782## Self signed certs generated by the ssl-cert package# Don't use them in a production server!## include snippets/snakeoil.conf;root /var/www/html;# Add index.php to the list if you are using PHPindex index.html index.htm index.nginx-debian.html;server_name _;location / {# First attempt to serve request as file, then# as directory, then fall back to displaying a 404.try_files $uri $uri/ =404;}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000##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;#}# deny access to .htaccess files, if Apache's document root# concurs with nginx's one##location ~ /\.ht {#   deny all;#}
}# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {#   listen 80;
#   listen [::]:80;
#
#   server_name example.com;
#
#   root /var/www/example.com;
#   index index.html;
#
#   location / {#       try_files $uri $uri/ =404;
#   }
#}

default文件里添加虚拟主机,使能够反向代理

server {listen       80;server_name  tomcat.abc.com;location / {proxy_pass http://127.0.0.1:8080;}
}

添加好了虚拟主机,重启nginx

以下操作要使终端在/etc/init.d/nginx下执行

  • 平滑的重启nginx
nginx -s reload
  • 快速的停止nginx
nginx -s stop
  • 优雅的停止nginx
nginx -s quit

首页的文件在/var/www/html文件夹下,自己可以更改

ubuntu@VM-90-170-ubuntu:/var/www/html$ pwd
/var/www/html
ubuntu@VM-90-170-ubuntu:/var/www/html$ cat index.nginx-debian.html
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>body {width: 35em;margin: 0 auto;font-family: Tahoma, Verdana, Arial, sans-serif;}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p><p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p>
</body>
</html>
ubuntu@VM-90-170-ubuntu:/var/www/html$ 

反向代理前

反向代理后

参考链接

nginx反向代理(端口转发)

在Ubuntu16.04.1上安装、配置、使用Nginx相关推荐

  1. linux系统安装佳能打印机驱动,在ubuntu16.04 64-bit上安装佳能打印机驱动Linux_UFRII_PrinterDriver_V320_us_EN...

    在ubuntu16.04 64-bit上安装佳能打印机驱动Linux_UFRII_PrinterDriver_V320_us_EN 发布时间:2018-04-06 21:46, 浏览次数:631 , ...

  2. Ubuntu16.04+caffe+digits安装配置

    注:本文主要介绍的是如何在ubuntu16.04系统下安装caffe以及可视化工具digits,至于cuda和cudnn的安装配置在我前一篇文章http://blog.csdn.net/cdwxx12 ...

  3. 在Ubuntu 14.04 64bit上安装配置sublime text 3(Build 3083)

    Sublime Text是一个轻量.简洁.高效.跨平台的编辑器,同时支持Windows.Linux.Mac OS X等操作系统.Sublime Text是由程序员Jon Skinner于2008年1月 ...

  4. debian安装sqlserver_在ubuntu16.04(虚拟机)上安装SQLSERVER

    遇到的问题及解决方案 Ubuntu 16.04下载地址: 客户机操作系统已将 CD-ROM 门锁定,并且可能正在使用 CD-ROM,这可能会导致客户机无法识别介质的更改.如果可能,请在断开连接之前从客 ...

  5. Ubuntu16.04 LTS上安装Go1.10

    原因 Ubuntu资源库上默认使用的是Go1.6.2版本,给最新版本代码编译带来了不少问题.本文就记录下在Ubuntu下直接安装Go最新版1.10的步骤. 准备工作 1.卸载已有版本 # 卸载已经安装 ...

  6. 在ubuntu16.04 64-bit上安装佳能打印机驱动Linux_UFRII_PrinterDriver_V320_us_EN

    1. 安装一些依赖项 (不确定它们是否都需要): sudo apt install libc6-i386 lib32ncurses5 lib32z1 sudo apt install libxml2: ...

  7. ubuntu16.04系统上安装CAJViewer方法步骤教程详解

    下载链接: http://pan.baidu.com/s/1jIqHxLs 或: http://download.csdn.net/detail/arhaiyun/5457947 安装wine1.6: ...

  8. Ubuntu16.04 anaconda 上安装 opencv

    一.anaconda 安装   如未安装anaconda,可参考博文:Ubuntu Anaconda 使用手册 . 二.anaconda 下安装 opencv   1.anaconda 下创建 pyt ...

  9. ubuntu16.04系统上安装RTL8822CE网卡驱动

    参考https://github.com/juanro49/rtl88x2ce-dkms 安装显卡驱动 重启进入bios界面,将secure reboot设为disable

最新文章

  1. Android开发 - 掌握ConstraintLayout(四)创建基本约束
  2. IE6下png图片透明代码
  3. GDCM:DICOM文件转储ADAC文件的测试程序
  4. windows下 安装 rabbitMQ 及操作常用命令
  5. ES19-Java API全文搜索
  6. Cause: java.sql.SQLException: Could not retrieve transation read-only status server
  7. 有参组装新转录本cufflinks_RNA-Seq流程(cutadapt-tophat2-cufflinks)
  8. android--------自定义控件 之 组合控件篇
  9. python字符串与列表与运算_what's the python之基本运算符及字符串、列表、元祖、集合、字典的内置方法...
  10. C++与STL简单介绍( C/C++机试)
  11. Mac OS黑苹果系统安装工具及懒人版镜像文件 for macOS High Sierra/macOS Sierra
  12. 数据库工具DBeaver
  13. C# 读写json文件
  14. LumaQQ.NET 试用
  15. Appium自动化下拉刷新
  16. linux用ping命令测试网速,怎么用ping命令测试网速
  17. 北京知产局:鼓励当事人用区块链,获取、固定知识产权纠纷证据
  18. windows下软件安装:Anaconda下安装Pymol
  19. QQ安装目录内的文件及子目录的详细作用
  20. notepad拼心形_用shell脚本写个心形动画表格

热门文章

  1. 软件测试分类-按照开发阶段划分
  2. 身份证ocr的API接口,让身份证信息录入更快捷
  3. 主从博弈论文中关于均衡解证明的写作总结
  4. LeetCode刷题第8天字符串系列之《378字符串中的第一个唯一字符》
  5. 链表ADT设计模板的简单应用——链表的ADT的实现C++版
  6. ETL:WJLYZQWDD
  7. 让米帝领事馆给你报空气质量(动态网页爬取及简单的数据整理)
  8. 去掉图片水印方法 小技巧
  9. 用聊天机器人假扮人类
  10. 《个人理财》书中的精髓:如何通过金融学理论知识的学习,建立更加完善的金融体系,让自己更加富有。