首页 > 其他 > 详细

nginx服务器的安装

时间:2015-02-16 19:44:49      阅读:376      评论:0      收藏:0      [点我收藏+]

准备工作

首先,创建相应的目录

userdel www
groupadd www
mkdir -p /hcdata/www
mkdir -p /hcdata/server/nginx
useradd -g www -M -d /hcdata/www -s /sbin/nologin www &> /dev/null

然后,安装依赖的library包,这里需要下载一个脚本,该脚本是阿里云提供的,为安装nginx准备的依赖环境

下载地址:

http://www.codingyun.com/downDirectory/install_env.sh

下载下来以后,可以读读脚本,这里面提到的library都是nginx环境需要用到的

上传该sh脚本到服务器后,执行脚本,执行该脚本时会先下载几个library的tar文件,所以最好新建一个目录,把这个sh脚本文件放到这个新建的目录下,然后再执行。

sh install_env.sh

三、解压

我一般都会把文件下载到/root/softDown

因此nginx的tar文件也在这个目录下

tar zxvf nginx-1.6.1.tar.gz
cd nginx-1.6.1

当前所在目录/root/softDown/nginx-1.6.1

执行以下命令,命令如果太长,可以换行,换行符为\

./configure --user=www \
--group=www \
--prefix=/hcdata/server/nginx \
--with-http_stub_status_module \
--without-http-cache \
--with-http_ssl_module \
--with-http_gzip_static_module

如果报错的话,如下的错误:

./configure: error: SSL modules require the OpenSSL library. You can either do not enable the modules, or install the OpenSSL library into the system, or build the OpenSSL library statically from the source with nginx by using --with-openssl=option.

代表依赖的OpenSSL library包还没有安装(上面阿里云提供的sh脚本少了这个library依赖,这里我们自己下载安装)

所以先下载依赖包,执行以下命令,安装该OpenSSL library

cd /usr/local/src
wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
tar -zxvf openssl-1.0.1c.tar.gz

这样的话缺少的依赖包安装好了,就可以继续安装nginx了

cd  /root/softDown/nginx-1.6.1
./configure --user=www \
--group=www \
--prefix=/hcdata/server/nginx \
--with-http_stub_status_module \
--without-http-cache \
--with-http_ssl_module \
--with-http_gzip_static_module \
--with-openssl=/usr/local/src/openssl-1.0.1c

四、编译,安装

make -jn (n = cpu核心x2)的多线程编译的参数

我的服务器是2核的,所以用的是make -j4 (所以你的是x核,那么这里就是make -j2x)

make -j4  

执行安装

make install
chmod 775 /hcdata/server/nginx/logs
chown -R www:www /hcdata/server/nginx/logs
chmod -R 775 /hcdata/www
chown -R www:www /hcdata/www
chmod 755 /hcdata/server/nginx/sbin/nginx
mv /hcdata/server/nginx/sbin/nginx /etc/init.d/
chmod +x /etc/init.d/nginx

五、运行

/etc/init.d/nginx

nginx服务器的安装

原文:http://yaomy.blog.51cto.com/8892139/1614666

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!