linux下nginx的安装

首先我们来看看使用Nginx的必备软件:

1.GCC编译器

        安装指令 :yum  install -y  gcc    

        如果你所使用的是ubuntu,则安装指令为:apt-get install -y  gcc        因为ubuntu可不用yum,下同哦..............

        如果涉及到C++来编写Nginx HTTP模块,则还需要安装G++编译器,

        安装指令:yum install -y gcc-c++

2. PCRE库

        首先我们需要下载PCRE,这个步骤简单,我们可以自行完成。例如这里我们下载的安装包为pcre-8.34.tar.gz,我们需要用到移动到指定的文件夹下面,然后解压安装。

      移动指令:mv “指定文件目录”  “目标文件目录”。假设我们需要将源码移动到/home目录下 mv  /home  "源码所在目录/pcre-8.34.tar.gz"

      解压指令:tar zxvf pcre-8.34.tar.gz   然后执行如下指令。

      cd /home/pcre-8.34

      ./configure  此过程中会生成一大堆文件,不用去管它。

      make

      make install

3.OpenSSL开发库

     yum  install -y openssl openssl-devel  

     如果是ubuntu系统,安装指令:# sudo apt-get install openssl # sudo apt-get install libssl-dev

OK,准备工作已经做完,我们来安装Nginx。首先得下载源码,然后将其移动到目标文件夹,当然也可以就地解压。这里我们以nginx-1.6.0.tar.gz,移动到/home目录下来进行实例说明。cd到/home目录,解压。

      # tar zxvf nginx-1.6.0.tar.gz

      # cd nginx-1.6.0

       ./configure --prefix=/usr/local/nginx --with-http_stub_status_module

make

make install

如果在make的时候出现make: *** 没有规则可以创建“default”需要的目标“build”这种提示,请回到OpenSSL开发库的安装上去,一般是这一步出了问题。而且你肯定没有注意./configure时候的错误提示:

./configure: error: the HTTP cache module requires md5 functions
from OpenSSL library.  You can either disable the module by using
--without-http-cache option, or install the OpenSSL library into the system,
or build the OpenSSL library statically from the source with nginx by using
--with-http_ssl_module --with-openssl= options.
如果一切都没有问题,我们来检查下安装是否成功。

  cd  /usr/local/nginx/sbin

      ./nginx -t 

      结果显示:

      nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok

      nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

则表示安装正确,现在我们来启动Nginx:

cd  /usr/local/nginx/sbin

./nginx 启动 nginx

这个时候打开浏览器,输入自己电脑的ip。对于不知道自己电脑ip的童靴,可以使用ifconfig指令进行查看。

这里我在浏览器中输入:http://127.0.0.1 出现如下信息:



看到上面nginx 欢迎界面说明启动成功

          停止nginx: pkill -9 nginx

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值