zoukankan      html  css  js  c++  java
  • Nginx源代码安装

    1.确认系统平台及版本
    [root@Trial html]# uname -r
    2.6.32-696.6.3.el6.x86_64
    [root@Trial html]# cat /etc/redhat-release
    CentOS release 6.9 (Final)

    2.安装Niginx所需要的pcre库(使Nginx支持具备URL重写功能的rewrite模块。)

    [root@Trial ~]# yum -y install pcre.x86_64 pcre-devel.x86_64
    [root@Trial ~]# rpm -q pcre.x86_64 pcre-devel.x86_64

    3.安装基础依赖包openssl、openssl-devel
    [root@Trial ~]# yum -y install openssl openssl-devel
    [root@Trial ~]# rpm -q openssl openssl-devel

    4.下载nginx1.6.3.tar.gz包
    [kennminn@Trial ~]$ mkdir -p /home/kennminn/tools
    [kennminn@Trial tools]$ cd /home/kennminn/tools
    [kennminn@Trial tools]$ wget -q http://nginx.org/download/nginx-1.6.3.tar.gz
    [kennminn@Trial tools]$ tar -tvf nginx-1.6.3.tar.gz #查看一下nginx的目录结构
    [kennminn@Trial tools]$ tar -xvf nginx-1.6.3.tar.gz
    [kennminn@Trial tools]$ cd nginx-1.6.3
    [kennminn@Trial nginx-1.6.3]$ ls
    CHANGES LICENSE auto configure html src
    CHANGES.ru README conf contrib man

    5.新建nginx的安装目录以及nginx用户(Root用户权限)
    [root@Trial ~]# mkdir -p /application/nginx-1.6.3
    [root@Trial ~]# useradd nginx -M -s /sbin/nologin #-M选项的作用是不用生成家目录,因为nginx用户不用登录系统

    6.安装Nginx
    [root@Trial ~]# cd /home/kennminn/tools/nginx-1.6.3
    [root@Trial nginx-1.6.3]# ./configure --user=nginx --group=nginx --prefix=/application/nginx-1.6.3/ --with-http_stub_status_module --with-http_ssl_module
    [root@Trial nginx-1.6.3]# make
    [root@Trial nginx-1.6.3]# make install
    [root@Trial nginx-1.6.3]# ln -s /application/nginx-1.6.3/ /application/nginx
    [root@Trial nginx-1.6.3]# ll /application/
    total 4
    lrwxrwxrwx. 1 root root 25 Jul 25 11:55 nginx -> /application/nginx-1.6.3//
    drwxr-xr-x. 6 root root 4096 Jul 25 11:54 nginx-1.6.3/

    7.启动Nginx进程
    [root@Trial nginx]# /application/nginx/sbin/nginx

    8.验证
    [root@Trial nginx]# lsof -i :80
    COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
    nginx 7656 root 6u IPv4 29052 0t0 TCP *:http (LISTEN)
    nginx 7657 nginx 6u IPv4 29052 0t0 TCP *:http (LISTEN)

    [root@Trial nginx]# netstat -tlnup |grep nginx
    tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 7656/nginx

    [root@Trial nginx]# wget 127.0.0.1
    --2017-07-25 12:00:57-- http://127.0.0.1/
    Connecting to 127.0.0.1:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 612 [text/html]
    Saving to: “index.html”

    100%[=========================================>] 612 --.-K/s in 0s

    [root@Trial nginx]# curl 127.0.0.1

    Welcome to nginx!

    Welcome to nginx!

    If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

    For online documentation and support please refer to nginx.org.
    Commercial support is available at nginx.com.

    Thank you for using nginx.

    这些都说明Nginx服务已经正常的启动了。

    问题1 本地可以正常访问,远程无法访问
    原因:防火墙开启了,关闭防火墙或者在防火墙增加访问80的端口的策略。也有可能是selinux开启造成的。

  • 相关阅读:
    3.31考试T2
    P3225 [HNOI2012]矿场搭建
    P2714 四元组统计
    3.29考试T2 变戏法
    开发中可能会用到的几个小tip----QT, pycharm, android, 等
    pycharm下: conda installation is not found ----一个公开的bug的解决方案
    ubuntu16.04 opencv3.4.1 opencv-contribute3.4.1 compile
    vs 2015 update 3各版本下载地址
    在金融业工作了六年,给想入这行的说几个经验
    在centos上安装smplayer播放器
  • 原文地址:https://www.cnblogs.com/minn/p/7233863.html
Copyright © 2011-2022 走看看