本文已参与「掘力星计划」nginx作为一款web服务器软件,在一些场景下需要编译安装,这里进行一下文章分享
- 1.准备软件
sudo wget http://nginx.org/download/nginx-1.11.10.tar.gz
sudo tar -xf nginx-1.11.10.tar.gz
- 2.编译环境准备
sudo yum -y groupinstall "Developemt Tools"
sudo yum -y install epel-release
sudo yum -y install GeoIP-devel perl-ExtUtils-Embed gperftools-devel libatomic_ops-devel openssl-devel perl-devel libxslt-devel libxml2-devel pcre-devel gd-devel
- 3.开始编译
cd nginx-1.11.10
./configure --with-select_module --with-poll_module --with-threads --with-file-aio --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_xslt_module=dynamic --with-http_image_filter_module --with-http_image_filter_module=dynamic --with-http_geoip_module --with-http_geoip_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module --with-http_perl_module=dynamic --with-mail --with-mail=dynamic --with-mail_ssl_module --with-stream --with-stream=dynamic --with-stream_ssl_module --with-stream_realip_module --with-stream_geoip_module --with-stream_geoip_module=dynamic --with-stream_ssl_preread_module --with-google_perftools_module --with-cpp_test_module
sudo make -j 10
- 4.编译完成并安装
sudo make install
- 5.准备配置文件
sudo vi /usr/lib/systemd/system/nginx.service
[Unit]
Description=High-perfomance, web service or proxy application
After=network.target
[Service]
Type=forking
PIDFile=/var/run/nginx/nginx.pid
ExecStartPre=/usr/bin/rm -f /var/run/nginx/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx -c /usr/local/nginx/nginx.conf
ExecReload=/usr/bin/nginx -s reload
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=mixed
PrivateTmp=true
[Install]
WantedBy=multi-user.target