linux安装nginx
2016-05-23 16:13
615 查看
linux安装nginx
1. 下载nginx,传送门:http://nginx.org/en/download.html。此处下载要么下载到本地后用xftp放到服务器上去,要么复制一下下载链接,到linux服务器的命令行下, wget + 链接下载。
2. 安装nginx依赖包,依赖包安装顺序依次为:openssl、zlib、pcre, 然后安装Nginx包。请读者另行百度,也可以看看我找的这个,/article/1429906.html。
此处我用的是阿里云,阿里云给了一个脚本,是为安装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端口被占用,改那个就看你自己啦。
相关文章推荐
- nginx rewrite proxy_pass location 的理解
- 2016 -Nginx的负载均衡 - 一致性哈希 (Consistent Hash)
- 转:nginx 从入门到精通的博文
- 使用Nginx负载均衡
- Nginx防攻击杀手锏
- Ubuntu FastDFSv5.05+Nginx1.9.15 环境搭建
- nginx的基本配置和虚拟主机的配置
- Ansible安装配置Nginx
- nginx禁止未绑定域名访问 并且强行断开连接
- nginx配置静态资源地址
- 转:Nginx RTMP 功能研究
- Ubuntu下Nginx简单使用
- nginx整理
- CenOS Linux安装nginx
- nginx 静态服务器搭建
- NGINX日志切割
- Nginx安装/配置/使用
- nginx配置location总结及rewrite规则写法
- 高流量站点NGINX与PHP-fpm配置优化
- nginx的编译参数说明(百度的)