Ubuntu 18.04.1 nginx 配置安装

本文详细介绍了在Ubuntu系统中安装Nginx的过程,包括必要的依赖库安装,如pcre、zlib和ssl等,并提供了具体的命令行操作步骤。此外,还展示了如何配置Nginx以代理Tornado应用,通过修改nginx.conf文件实现网站的运行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  1. 首先需安装nginx依赖库
apt-get install build-essential
apt-get install libtool
  1. 安装pcre依赖库
sudo apt-get update
sudo apt-get install libpcre3 libpcre3-dev
  1. 安装zlib依赖库
apt-get install zlib1g-dev
  1. 安装ssl依赖库
apt-get install openssl
  1. nginx download url
  2. tar -zxvf nginx-1.12.2.tar.gz
  3. cd nginx-1.12.2
  4. ./configure --prefix=/usr/local/nginx
nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx modules path: "/usr/local/nginx/modules"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

bingo=_=
  1. make
  2. sudo make install
  3. (qidong start)sudo /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
  4. (view process) ps -ef|grep nginx
/home/jackray/Public/soft/nginx-1.12.2# ps -ef|grep nginx
root     13803  1178  0 18:59 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nobody   13804 13803  0 18:59 ?        00:00:00 nginx: worker process
root     13806  1910  0 18:59 pts/0    00:00:00 grep --color=auto nginx
  1. cd /usr/local/nginx/conf/ start to config
  2. touch ihasy.conf
  3. view
/nginx/conf# ls ihasy.conf
ihasy.conf
  1. vim ihasy.conf insert the context like follows
upstream ihasy  {
    server 127.0.0.1:9001; #Tornado
}

## Start www.ihasy.com ##
server {
    listen 80;
    server_name  www.ihasy.com ihasy.com;

    #root   html;
    #index  index.html index.htm index.py index;

    ## send request back to Tornado ##
    location / {
        proxy_pass  http://ihasy;

        #Proxy Settings
        proxy_redirect     off;
        proxy_set_header   Host             $host;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
        proxy_max_temp_file_size 0;
        proxy_connect_timeout      90;
        proxy_send_timeout         90;
        proxy_read_timeout         90;
        proxy_buffer_size          4k;
        proxy_buffers              4 32k;
        proxy_busy_buffers_size    64k;
        proxy_temp_file_write_size 64k;
   }
}
## End www.ihasy.com ##
                      
  1. shift + : wq! enter ~bingo
  2. /usr/local/nginx/conf# vim nginx.conf
  3. 在http下添加一行
http {
    include ihasy.conf;
  1. pkill -9 nginx

view the ubuntu’s version
how to config nginx for ubuntu

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值