linux安装nginx

linux安装nginx

1. 下载nginx,传送门:http://nginx.org/en/download.html
此处下载要么下载到本地后用xftp放到服务器上去,要么复制一下下载链接,到linux服务器的命令行下, wget + 链接下载。
2. 安装nginx依赖包,依赖包安装顺序依次为:openssl、zlib、pcre, 然后安装Nginx包。请读者另行百度,也可以看看我找的这个,http://blog.csdn.net/dyllove98/article/details/8892509
此处我用的是阿里云,阿里云给了一个脚本,是为安装nginx准备的依赖环境,下载地址:http://www.codingyun.com/downDirectory/install_env.sh。下载完成后,执行脚本,执行脚本之前最好把脚本单独放到一个temp目录下,因为它会下载好多tar文件。执行sh install_env.sh。
3. Tar –zxvf 文件名.tar.gz 解压到当前文件夹。
4. 进入解压完的文件夹,执行安装nginx ,命令:./configure –prefix=/alidata/server/nginx –with-http_stub_status_module –without-http-cache –with-http_ssl_module –with-http_gzip_static_module
5. 碰到了问题:./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 Libernary。安装。

6. 下载OpenSSL,移步 ftp://ftp.openssl.org/source/
cd /usr/local/src
wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
tar -zxvf openssl-1.0.1c.tar.gz

7. 然后,继续安装nginx。
./configure –prefix=/alidata/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

8.编译,安装nginx。命令:make -j4
make -jn (n = cpu核心x2)的多线程编译的参数
我的服务器是2核的,所以用的是make -j4 (所以你的是x核,那么这里就是make -j2x)
这里结果我出现两个错误。但是看看报错的路径都是openssl报的错,所以我就没管他。有兴趣的可以去看看。
9. 执行安装 ,更改权限。
make install
chmod 775 /alidata/server/nginx/logs
chmod 755 /alidata/server/nginx/sbin/nginx
mv /alidata/server/nginx/sbin/nginx /etc/init.d/
chmod +x /etc/init.d/nginx

10. 运行/etc/init.d/nginx。
如果这个时候出现nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use),说明80端口被占用,改那个就看你自己啦。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值