linux离线安装nginx

Linux离线安装nginx

先看linux版本,下载相应rpm。

  1. 安装gcc
  2. 下载安装包手动安装
  3.   下载GCC所有需要的依赖包,逐个安装,可以从网站http://www.rpmfind.net/linux/rpm2html/search.php搜索下载,下面是所需要安装的GCC依赖列表
  4.   安装gcc编译环境依赖(真实版本可能有所不同,这无关紧要)
  5. 安装gcc模块依赖:cloog-pplcppglibc-devellibgomplibgomp.so.1
  6. 安装cloog-ppl模块依赖:libppl.so.7libppl_c.so.2
  7. 安装libppl.so.7libppl_c.so.2模块依赖:无
  8. 安装cpp模块依赖:libmpcfr.so.1
  9. 安装libmpcfr.so.1模块依赖:无
  10. 安装glibc-devel模块依赖:glibc-headers
  11. 安装glibc-headers模块依赖:kernel-headers
  12. 安装kernel-headers模块依赖:无
  13. 安装libgomplibgomp.so.1模块依赖:无
  14.   安装顺序:
  15. rpm -ivh ppl-0.10.2-11.el6.x86_64.rpm                                 #ppl(libppl.so.7libppl_c.so.2)
    rpm -ivh cloog-ppl-0.15.7-1.2.el6.x86_64.rpm                       #cloog-ppl
    rpm -ivh mpfr-2.4.1-6.el6.x86_64.rpm                                  #libmpcfr.so.1
    rpm -ivh cpp-4.4.7-17.el6.x86_64.rpm                                  #cpp
    rpm -ivh kernel-headers-2.6.32-642.el6.x86_64.rpm              #kernel-headers
    rpm -ivh glibc-headers-2.12-1.192.el6.x86_64.rpm                #glibc-headers
    rpm -ivh glibc-devel-2.12-1.192.el6.x86_64.rpm                    #glibc-devel
    rpm -ivh libgomp-4.4.7-17.el6.x86_64.rpm                           #libgomp(libgomp
    libgomp.so.1)
    rpm -ivh gcc-4.4.7-17.el6.x86_64.rpm                                  #gcc
  16.   至此安装成功
  17. 安装pcre依赖包:
  18. rpm -ivh pcre-7.8-7.el6.x86_64.rpm --force(由于机器上已经有低版本的pcre,所以强制安装)。
  19. rpm -ivh pcre-devel-7.8-7.el6.x86_64.rpm
  20. 3.安装libstdc++-develgcc-c++依赖)
  21. rpm -ivh libstdc++-devel-4.4.7-4.el6.x86_64.rpm
  22. 4.安装gcc-c++
  23. rpm -ivh gcc-c++-4.4.7-4.el6.x86_64.rpm
  24. 5.安装zlib-devel
  25. rpm -ivh zlib-devel-1.2.3-29.el6.x86_64.rpm
  26. 6.安装nginx
  27. cd nginx-1.12.1
  28. ./configure
  29. make
  30. make install
  31. 7.运行nginx
  32. cd /usr/local/nginx/sbin
  33. ./nginx

浏览器访问下http:ip 看能否进入nginx首页。

配置nginx   vi /usr/local/nginx/conf/nginx.conf

查看配置是否正确:/usr/local/nginx/sbin/nginx -t

查看nginx进程:ps -ef|grep nginx

强制关闭nginx:pkill nginx

nginx.conf配置文件实例:

==============================================================================================

#user  nobody;

worker_processes  2;

#error_log  logs/error.log;

#error_log  logs/error.log  notice;

#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

events {

    worker_connections  1024;

}

http {

    include       mime.types;

    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

    #                  '$status $body_bytes_sent "$http_referer" '

    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;

    #tcp_nopush     on;

    #keepalive_timeout  0;

    keepalive_timeout  65;

    #gzip  on;

######################主要的######################

    upstream site {

     #ip_hash 同一ip会被分配给固定的后端服务器,解决session问题

      ip_hash;

      server 172.21.132.132:9010;

      server 172.21.132.133:9013;

      server 172.21.132.134:9014;

      server 172.21.132.135:9015;

     }

################################################

    server {

        listen       9019;

        server_name  site;

        charset utf-8;

        #access_log  logs/host.access.log  main;

        location / {

            root   html;

            index  index.html index.htm;

          proxy_pass http://site;
          proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            client_max_body_size  100m;

        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html

        #

        error_page   500 502 503 504  /50x.html;

        location = /50x.html {

            root   html;

        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80

        #

        #location ~ \.php$ {

        #    proxy_pass   http://127.0.0.1;

        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

        #

        #location ~ \.php$ {

        #    root           html;

        #    fastcgi_pass   127.0.0.1:9000;

        #    fastcgi_index  index.php;

        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

        #    include        fastcgi_params;

        #}

        # deny access to .htaccess files, if Apache's document root

        # concurs with nginx's one

        #

        #location ~ /\.ht {

        #    deny  all;

        #}

    }

    # another virtual host using mix of IP-, name-, and port-based configuration

    #

    #server {

    #    listen       8000;

    #    listen       somename:8080;

    #    server_name  somename  alias  another.alias;

    #    location / {

    #        root   html;

    #        index  index.html index.htm;

    #    }

    #}

    # HTTPS server

    #

    #server {

    #    listen       443 ssl;

    #    server_name  localhost;

    #    ssl_certificate      cert.pem;

    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;

    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;

    #    ssl_prefer_server_ciphers  on;

    #    location / {

    #        root   html;

    #        index  index.html index.htm;

    #    }

    #}

 

}

 

 

 

 

通过IP访问,可以看到  welcome nginx 的提示

下面我重启linux服务器,重启后通过ip访问,死活连接不上了?没办法了,只有在百度和google

最后发现问题不是出在nginx上,而是出在iptable上,在iptable上添加80端口

  1. #vi /etc/sysconfig/iptables  
  2. //在倒数第二行加入80端口  
  3. -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT  
  4.   
  5.   
  6. //重启iptables  
  7. #/etc/init.d/iptables restart  
  8. 再通过ip访问  ok~  没问题了
  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值