Nginx安装与配置

Nginx源码编译与安装:

1. 环境包的安装:

apt-get update
apt-get -y install make g++ gcc libpcre3 libpcrecpp* libpcre3-dev libssl-dev autoconf automake libtool libncurses5-dev libaio.dev

2. 下载或上传安装包,同时上传一些其他的辅助组件:

 

echo-nginx-module-0.59.tar.gz、nginx-1.11.3.tar.gz、nginx-1.17.1.tar.gz、nginx-upstream-fair-a18b409.tar.gz、ngx_cache_purge-2.3.tar.gz

3. 将Nginx源码解压到“/usr/local/src/”目录中:

tar xzvf /srv/ftp/nginx-1.11.3.tar.gz -C /usr/local/src/
tar xzvf /srv/ftp/echo-nginx-module-0.59.tar.gz -C /usr/local/src/
tar xzvf /srv/ftp/nginx-upstream-fair-a18b409.tar.gz -C /usr/local/src/
tar xzvf /srv/ftp/ngx_cache_purge-2.3.tar.gz -C /usr/local/src/

4. 创建Nginx编译后的工作目录:

mkdir -p /usr/local/nginx/{logs,conf,fastcgi_temp,sbin,client_body_temp,proxy_temp,uwsgi_temp,scgi_temp}

5. 进入Nginx源代码所在目录:

cd /usr/local/src/nginx-1.11.3/

6. 由于本次Nginx里面需要追加一些其他的组件,所以先对Nginx编译做一些配置:

./configure --prefix=/usr/local/nginx/ \
--sbin-path=/usr/local/nginx/sbin/  \
--with-http_ssl_module \
--conf-path=/usr/local/nginx/conf/nginx.conf \
--pid-path=/usr/local/nginx/logs/nginx.pid \
--error-log-path=/usr/local/nginx/logs/error.log \
--http-log-path=/usr/local/nginx/logs/access.log \
--http-fastcgi-temp-path=/usr/local/nginx/fastcgi_temp \
--http-client-body-temp-path=/usr/local/nginx/client_body_temp \
--http-proxy-temp-path=/usr/local/nginx/proxy_temp \
--http-uwsgi-temp-path=/usr/local/nginx/uwsgi_temp \
--http-scgi-temp-path=/usr/local/nginx/scgi_temp \
--add-module=/usr/local/src/echo-nginx-module-0.59 \
--add-module=/usr/local/src/gnosek-nginx-upstream-fair-a18b409 \
--add-module=/usr/local/src/ngx_cache_purge-2.3 

7. 对Nginx进行编译与安装:

make && make install

8. 启动Nginx:

/usr/local/nginx/sbin/nginx

9. 查看端口:

netstat -nptl

10. 浏览器访问:默认80端口

http://192.168.28.222/

ubuntu安装nginx

 

https://blog.csdn.net/qq_23832313/article/details/83578836

posted @ 2019-07-04 23:18  SweetBaby。  阅读(221)  评论(0编辑  收藏  举报