Nginx 安装过程

  • 下载

    wget http://nginx.org/download/nginx-1.10.2.tar.gz

  • 安装
  1. 上传到Linux服务器

  2. 解压缩 :tar -zxvf nginx-1.10.2.tar.gz

  3. 编译nginx

    1. 配置makefile

      ./configure \
        --prefix=/usr/local/nginx \
        --pid-path=/var/run/nginx/nginx.pid \
        --lock-path=/var/lock/nginx.lock \
        --error-log-path=/var/log/nginx/error.log \
        --http-log-path=/var/log/nginx/access.log \
        --with-http_gzip_static_module \
        --http-client-body-temp-path=/var/temp/nginx/client \
        --http-proxy-temp-path=/var/temp/nginx/proxy \
        --http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
        --http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
        --http-scgi-temp-path=/var/temp/nginx/scgi
      

    注意:上边将临时文件目录指定为/var/temp/nginx,需要在/var下创建temp及nginx目录
    [root@bogon nginx-1.8.0]# mkdir /var/temp/nginx -p

    1. 编译安装

      make
      make  install
      
  4. 启动nginx

     sudo  ./nginx
    
  5. 关闭nginx 和配置防火墙

    1. 关闭
      [root@bogon sbin]# ./nginx -s stop

    2. 重新加载配置文件:修改了配置文件,不想让nginx重启。
      [root@bogon sbin]# ./nginx -s reload

    3. 关闭防火墙
      1. 关闭
      [root@bogon sbin]# service iptables stop iptables: Flushing firewall rules: [ OK ] iptables: Setting chains to policy ACCEPT: filter [ OK ] iptables: Unloading modules: [ OK ]
      3. 也可以修改防火墙配置文件:

        	 [root@bogon sbin]# vim /etc/sysconfig/iptables
           修改后需要重启防火墙:
           [root@bogon sbin]# service iptables restart
      
  6. 访问nginx服务

    1. 直接在 浏览器地址栏输入nginx 主机地址
      1. 如 192.168.43.106

安装好以后,安装在了/usr/local/nginx 目录下

目录结构

  nginx

	  |----------conf :所用的配置文件

 	 |----------html :显示用的html

  		|----------sbin

	  |--------nginx:可执行文件

./nginx 执行此文件,启动服务器
在这里插入图片描述

配置Nginx服务器

修改配置文件
/usr/local/nginx/conf/nginx.conf
在这里插入图片描述

创建 /home/ftpuser/www文件夹

mkdir -p /home/ftpuser/www
需要nginx重新加载配置文件:
[root@bogon sbin]# ./nginx -s reload

访问 /home/ftpuser/www 文件夹下的资源
假如说是 /home/ftpuser/www/image/a.img

http://nginx服务器IP地址:端口号/image/a.img

就可以访问到了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值