zoukankan      html  css  js  c++  java
  • linux 安装nginx -查看 linux的环境变量

    我发现在linux上面安装linux很简单 在CentOS release 6.5 上面
    先看一下操作系统的版本:
    lsb_release -a
    直接执行 
    yum install nginx

    系统自动的将nginx注册到环境变量当中,

    如何查看linux的环境变量

    echo $PATH

    结果:

    [root@tx-qcs-regulation-xm-staging01 sbin]# echo $PATH
    /usr/local/java/bin:/sbin:/bin:/usr/sbin:/usr/bin
    [root@tx-qcs-regulation-xm-staging01 sbin]# 
    请注意:linux的环境变量,有三组:
    /usr/local/java/bin
    /sbin:/bin
    /usr/sbin:/usr/bin
    也就是说 在这三组文件夹下面的文件 都在环境变量里,都可以执行的:
    看一下nginx是否在这底下:
    whereis nginx
    [root@tx-qcs-regulation-xm-staging01 sbin]# echo $PATH
    /usr/local/java/bin:/sbin:/bin:/usr/sbin:/usr/bin
    [root@tx-qcs-regulation-xm-staging01 sbin]# whereis nginx
    nginx: /usr/sbin/nginx /etc/nginx /usr/share/nginx

    注意到:nginx在/usr/sbin/nginx底下,因此 nginx已经注册到环境变量里面了,可以直接执行

    启动nginx :

    [root@tx-qcs-regulation-xm-staging01 sbin]# nginx

    [root@tx-qcs-regulation-xm-staging01 sbin]# 

    这就是启动了,验证一下:

    使用 ps -ef | grep 'nginx'

    [root@tx-qcs-regulation-xm-staging01 sbin]# nginx
    [root@tx-qcs-regulation-xm-staging01 sbin]# ps -ef|grep 'nginx'
    root     10363     1  0 19:17 ?        00:00:00 nginx: master process nginx
    nginx    10364 10363  0 19:17 ?        00:00:00 nginx: worker process
    root     10857  7344  0 19:17 pts/0    00:00:00 grep nginx
    有master进程,说明启动成功了;

    就可以了;停止NGINX:命令:

     nginx -s stop



    以下是原来的博客;

    如果安装了centos 之后无法上网,只需要修改一个小小的配置使用 root用户,进入 /etc/sysconfig/network-script/ifcfg-ens33 (可能你的网卡不是这名字,需要找到自己的网卡 在这个文件夹中输入 ifcfg-e 然后按TAB键就可以) 在这个文件中 修改onboot=yes (原来是 no) 然后 重启机器 命令 reboot now 就可以上网了;

    (1) 登陆linux: 下载nginx: wget http://nginx.org/download/nginx-1.8.0.tar.gz 下载openssl : wget http://www.openssl.org/source/openssl-fips-2.0.9.tar.gz 下载zlib : wget http://zlib.net/zlib-1.2.11.tar.gz
    (这里是最新的版本,如果这个地址无法下载,请在浏览器中输入
    http://zlib.net/ 看看最近的是什么版本,改一下版本号就可以 比如 wget http://zlib.net/zlib-1.2.34.tar.gz)
    下载pcre : wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz 
    (如果没有此压缩包,跟刚才一样的处理,输入
    ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/,看一下最近发布的包,然后改一下 包的版本,再下载即可
    下载perl5  wget http://www.cpan.org/src/5.0/perl-5.16.1.tar.gz

    如果各位下载不方便可以直接从本人云盘下载
    zlib:
    https://pan.baidu.com/s/1dE0TGdV
    pcre:
    https://pan.baidu.com/s/1boNs3lP
    perl:
    https://pan.baidu.com/s/1i4RjZRB
    (2)如果没有安装c++编译环境,还得安装,通过yum install gcc-c++ -y完成安装
    (3)别忘了安装perl5 (编译openssl需要perl5)

    解压源码包
    [root@akinlau /]# tar -xzf perl-5.16.1.tar.gz

    编译并安装,目录可以自定义

    [root@akinlau /]# cd perl-5.16.1
    [root@akinlau perl-5.16.1]# ./Configure -des -Dprefix=/usr/local/perl

    [root@akinlau perl-5.16.1]# make
    [root@akinlau perl-5.16.1]# make test
    [root@akinlau perl-5.16.1]# make install

    如果系统以前已安装了旧版本的perl的话,替换系统原有的版本。
    [root@akinlau perl-5.16.1]# mv /usr/bin/perl /usr/bin/perl.bak
    [root@akinlau perl-5.16.1]# ln -s /usr/local/perl/bin/perl /usr/bin/perl

    再看看是不是最新的版本

    [root@akinlau perl-5.16.1]# perl -v

    This is perl 5, version 16, subversion 1 (v5.16.1) built for x86_64-linux

    Copyright 1987-2012, Larry Wall

    Perl may be copied only under the terms of either the Artistic License or the
    GNU General Public License, which may be found in the Perl 5 source kit.

    Complete documentation for Perl, including FAQ lists, should be found on
    this system using “man perl” or “perldoc perl”. If you have access to the
    Internet, point your browser at http://www.perl.org/, the Perl Home Page.

    如果看到以上信息,就证明perl安装成功了。



    (4)然后开始安装:openssl : [root@localhost] tar zxvf openssl-fips-2.0.9.tar.gz [root@localhost] cd openssl-fips-2.0.9 [root@localhost] ./config && make && make install (5)安装pcre: [root@localhost] tar zxvf pcre-8.36.tar.gz [root@localhost] cd pcre-8.36 [root@localhost] ./configure && make && make install (6)开始安装:zlib: [root@localhost]tar zxvf zlib-1.2.8.tar.gz [root@localhost] cd zlib-1.2.8 [root@localhost] ./configure && make && make install (7) 最后安装nginx [root@localhost]tar zxvf nginx-1.8.0.tar.gz [root@localhost] cd nginx-1.8.0 [root@localhost] ./configure && make && make install

     (8) 启动nginx

    /usr/local/nginx/sbin/nginx

    然后测试一下:
    使用ps -ef | grep nginx

    然后前台访问: 使用 http://192.168.111.135(请换成您机器的ip)

    (9)然后总是无法显示
    原因需要把 防火墙关掉

    方法: systemctl stop firewalld.service
    systemctl disable firewalld.service


    (10)然后安装成功
    (11) 如果想要停止,请使用:

    pkill -9 nginx


    后面的问题; 后来我发现 修改了 html/index.html中的文件,却没有生效,把 conf/nginx.conf中的开始页面,也是没效果,这个一直不知道原因,哪位知道能否说一下原因;

    参考:http://www.centoscn.com/image-text/install/2014/0928/3869.html

    安装perl5:
    http://www.centoscn.com/image-text/install/2014/0928/3869.html

    启动nginx

    http://www.cnblogs.com/codingcloud/p/5095066.html

  • 相关阅读:
    Media change : please insert the disk labeled
    ubuntu 关闭和开启防火墙
    CentOS6.3上部署Ceph
    Keepalived_vrrp: ip address associated with VRID not present in received packet
    Python 错误和异常小结
    nova network-vif-plugged 事件分析1
    ansible 之条件语句 when
    ansible 判断和循环
    openvswitch dpdk
    ES6之Promise
  • 原文地址:https://www.cnblogs.com/aspirant/p/6714548.html
Copyright © 2011-2022 走看看