进入到 /usr/local 目录下执行下面1 2 3 4,此处路劲与之后安装nginx对应,需要注意*
源码编译依赖环境
apt-get install build-essential
apt-get install libtool
// gcc --version 查看gcc版本
// gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4PCRE(Perl Compatible Regular Expressions)是一个Perl库,包括 perl 兼容的正则表达式库。nginx的http模块使用pcre来解析正则表达式
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz
tar -zxvf pcre-8.38.tar.gz
cd pcre-8.38
./configure
make
make install zlib库提供了很多种压缩和解压缩的方式,nginx使用zlib对http包的内容进行gzip
wget http://zlib.net/zlib-1.2.11.tar.gz
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make
make install OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及SSL协议,并提供丰富的应用程序供测试或其它目的使用. nginx不仅支持http协议,还支持https(即在ssl协议上传输http)
wget https://www.openssl.org/source/openssl-1.0.2n.tar.gz
tar -zxvf openssl-1.0.2n.tar.gzwget https://nginx.org/download/nginx-1.8.1.tar.gz
tar -zxvf nginx-1.8.1.tar.gz
安装nginx到 /usr/local/nginx目录下
cd nginx-1.8.1
// 配置nginx
./configure --sbin-path=/usr/local/nginx/nginx \
--conf-path=/usr/local/nginx/nginx.conf \
--pid-path=/usr/local/nginx/nginx.pid \
--with-http_ssl_module \
--with-pcre=/usr/local/pcre-8.38 \
--with-zlib=/usr/local/zlib-1.2.11 \
--with-openssl=/usr/local/openssl-1.0.2n
// 编译
make
// 安装
make install至此nginx安装完成!
建议使用第一种启动,否则可能会出现如下错误
nginx: [error] open() "/***/***/***/nginx.pid" failed (2: No such file or directory)第一种
cd /usr/local/nginx
./nginx -c ./nginx.conf第二种
/usr/local/nginx/nginx
重新加载配置
./nginx -s reloadapt-get install nginx启动程序文件在/usr/sbin/nginx
日志放在了/var/log/nginx中,分别是access.log和error.log
并已经在/etc/init.d/下创建了启动脚本nginx
/etc/init.d/nginx start更多 nginx 学习 推荐 : http://www.nginx.cn