编译安装多好,什么参数都可以自己改,而且apt-get的安装方式有点过于简单了,所有的配置和参数都是按官方的,出了幺蛾子都不能自己一点点Debug,再说编译安装是给你的机器量身订造的,安装完成后可维护性和稳定性十分高。
另外国内很多源给的Nginx版本很旧(TUNA的Nginx是1.10.2,现在的Nginx-Stable都更到1.20.2了)。
这篇文章不会使用正常的apt-get方式安装,所以这里会用编译安装的方式搭建环境(额,搭建编译安装的环境还是需要一点点软件包依赖。。。)。
编译环境
国外机直接用自带的CDN apt或者yum源,国内机建议用清华TUNA源。
#Debian/Ubuntu
sudo apt-get install build-essential -y
#RedHat系
yum install -y gcc gcc-c++ cmake ncurses ncurses-devel bison
下载安装包
以下安装包在2022年2月为最新的稳定版,建议你看到这里的时候先去下面的网站看看目前的稳定版本。
wget https://nginx.org/download/nginx-1.20.2.tar.gz
wget https://www.openssl.org/source/openssl-3.0.1.tar.gz --no-check-certificate
wget http://nchc.dl.sourceforge.net/project/pcre/pcre/8.45/pcre-8.45.tar.gz
wget http://www.zlib.net/zlib-1.2.11.tar.gz
最好把附加包都解压在Nginx的安装目录里。
编译时间到!
以下是按照我的安装环境所写的,自己装的时候检查一下再跑
./configure
--prefix=/etc/nginx
--sbin-path=/usr/sbin/nginx
--conf-path=/etc/nginx/nginx.conf
--error-log-path=/var/log/nginx/error.log
--http-log-path=/var/log/nginx/access.log
--pid-path=/var/run/nginx.pid
--lock-path=/var/run/nginx.lock
--http-client-body-temp-path=/var/cache/nginx/client_temp
--http-proxy-temp-path=/var/cache/nginx/proxy_temp
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp
--http-scgi-temp-path=/var/cache/nginx/scgi_temp
--user=www-data
--group=www-data
--with-file-aio
--with-threads
--with-http_addition_module
--with-http_auth_request_module
--with-openssl=./openssl-3.0.1
--with-pcre=./pcre-8.45
--with-zlib=./zlib-1.2.11
--with-http_dav_module
--with-http_flv_module
--with-http_gunzip_module
--with-http_gzip_static_module
--with-http_mp4_module
--with-http_random_index_module
--with-http_realip_module
--with-http_secure_link_module
--with-http_slice_module
--with-http_ssl_module
--with-http_stub_status_module
--with-http_sub_module
--with-http_v2_module
--with-mail
--with-mail_ssl_module
--with-stream
--with-stream_realip_module
--with-stream_ssl_module
--with-stream_ssl_preread_module
configure没问题就可以开始安装了
make && make install
#你可以你在make后面加 -j[你的处理器数量] ,以对多处理器的机器优化编译
Warning: Trying to access array offset on value of type bool in /www/wwwroot/www.tkong.net/wp-content/themes/zaxu/inc/functions/helpers.php on line 2072
Warning: Trying to access array offset on value of type bool in /www/wwwroot/www.tkong.net/wp-content/themes/zaxu/inc/functions/helpers.php on line 2073