安装扩展工具包yum源
yum -y install epel-release
安装工具
yum install net-tools wget nscd lsof
DNS缓存
/etc/resolv.conf 配置DNS服务器,打开NSCD服务,缓存DNS,提高域名解析响应速度
systemctl start nscd.service 启动NSCD服务 systemctl enable nscd.service
修改文件打开数限制
echo "* soft nofile 655536 \* hard nofile 65536" >>/etc/security/limits.conf
Nginx源码编译
源码获取
[root@Linux ~]# mkdir -p /opt/data/source [root@Linux ~]# cd /opt/data/source/ [root@Linux source]# wget http://nginx.org/download/nginx-1.17.4.tar.gz [root@Linux source]# ll total 1012 -rw-r--r-- 1 root root 1034845 Sep 24 2019 nginx-1.17.4.tar.gz [root@Linux source]# tar zxmf nginx-1.17.4.tar.gz [root@Linux source]# ll total 1016 drwxr-xr-x 8 1001 1001 4096 Oct 1 07:03 nginx-1.17.4 -rw-r--r-- 1 root root 1034845 Sep 24 2019 nginx-1.17.4.tar.gz
编译配置参数
首先需要通过编译配置命令configure 进行编译配置
安装编译工具及依赖库
yum -y install gcc pcre-devel zlib-devel openssl-devel libxml2-devel \ libxslt-devel gd-devel GeoIP-devel jemalloc-devel libatomic_ops_devel \ perl-devel perl-ExtUtils-Embed
安装完依赖库之后要进入到Nginx解压目录下
cd /opt/data/source/nginx-1.17.4
编译功能模块
./configure \ --with-threads \ --with-file-aio \ --with-http_ssl_module
#make
#make install
添加第三方模块
执行configure时,通过--add-module=PATH 参数指定第三方模块的代码路径
在make编译
添加第三方静态模块的方法
./configure --add-module=../ngx_http_proxy_connect_module
添加第三方动态模块的方法
./configure --add-dynamic-module=../ngx_http_proxy_connect_module \ --with-compat
Nginx部署
[root@Linux nginx-1.17.4]# cat >/etc/profile.d/nginx.sh << EOF > PATH=$PATH:/usr/local/nginx/sbin > EOF [root@Linux nginx-1.17.4]# [root@Linux nginx-1.17.4]# [root@Linux nginx-1.17.4]# [root@Linux nginx-1.17.4]# [root@Linux nginx-1.17.4]# source /etc/profile
进入nginx编译目录下/usr/local/nginx/sbin
启动nginx
#./nginx
然后通过ip地址访问即可看到正常