码迷,mamicode.com
首页 > 其他好文 > 详细

centos7 源码编译安装nginx教程 nginx安装脚本

时间:2019-08-28 13:02:13      阅读:88      评论:0      收藏:0      [点我收藏+]

标签:安装教程   安装nginx   tab   crt   stc   文件描述符   firewalld   error   top   

  • 安装nginx需要pcre zlib openssl的库,下文都是在官网直接下载用作编译安装
  • 该nginx安装教程,有安装maxmind IP 库
  • 该nginx安装教程有安装openrestry
  • 系统使用了centos 7
  • 该教材有修改最大打开文件描述符数到最大
  • 该教程是nginx安装的shell脚本
#!/bin/bash

yum install epel-release -y
yum install gcc gcc-c++ make automake autoconf libtool iptables-services wget bind-utils unzip -y

cd /usr/local/src

mv /etc/localtime /etc/localtime.bak
/bin/cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
echo ZONE="CST" > /etc/sysconfig/clock

setenforce 0
sed -i "s/=enforcing/=disabled/g" /etc/selinux/config

systemctl disable firewalld
systemctl stop firewalld

chkconfig iptables on
service iptables start
iptables -F
service iptables save

wget https://github.com/openresty/luajit2/archive/v2.1-agentzh.zip
unzip v2.1-agentzh.zip

cd luajit2-2.1-agentzh
mkdir -p /usr/local/nginx/
make install PREFIX=/usr/local/nginx/luajit
echo "/usr/local/nginx/luajit/lib" > /etc/ld.so.conf.d/usr_local_luajit_lib.conf
ldconfig

cd /usr/local/src/
wget https://github.com/maxmind/libmaxminddb/releases/download/1.3.2/libmaxminddb-1.3.2.tar.gz
tar zxf libmaxminddb-1.3.2.tar.gz
cd libmaxminddb-1.3.2
./configure
make && make install
[[ -z `cat /etc/ld.so.conf |grep "\/usr\/local\/lib"` ]] && echo "/usr/local/lib" >> /etc/ld.so.conf
ldconfig

mkdir -p /usr/local/nginx/temp
mkdir -p /usr/local/nginx/geoip
cd /usr/local/nginx/geoip


wget https://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz
tar zxf GeoLite2-City.tar.gz
cd GeoLite2-City_*
mv GeoLite2-City.mmdb maxmind-city.mmdb
mv maxmind-city.mmdb /usr/local/nginx/geoip/

cd /usr/local/src/
wget http://nginx.org/download/nginx-1.16.0.tar.gz
tar zxf nginx-1.16.0.tar.gz

wget -O openssl-master.zip https://github.com/openssl/openssl/archive/master.zip
unzip openssl-master.zip


wget https://nchc.dl.sourceforge.net/project/pcre/pcre2/10.33/pcre2-10.33.zip
unzip pcre2-10.33.zip


wget http://zlib.net/zlib-1.2.11.tar.gz
tar -zxf zlib-1.2.11.tar.gz


wget -O lua-nginx-module-master.zip https://github.com/openresty/lua-nginx-module/archive/master.zip
unzip lua-nginx-module-master.zip


wget -O ngx_http_geoip2_module-master.zip https://github.com/leev/ngx_http_geoip2_module/archive/master.zip
unzip ngx_http_geoip2_module-master.zip

useradd -M -s /sbin/nologin www

export LUAJIT_LIB=/usr/local/nginx/luajit/lib
export LUAJIT_INC=/usr/local/nginx/luajit/include/luajit-2.1

cd /usr/local/src/nginx-1.16.0
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_ssl_module --with-http_sub_module --with-http_gzip_static_module --with-http_gunzip_module --with-http_stub_status_module --with-http_realip_module --with-pcre-jit --with-http_v2_module --error-log-path=/usr/local/nginx/logs/error.log --http-log-path=/usr/local/nginx/logs/access.log --http-client-body-temp-path=/usr/local/nginx/temp/client_body_temp --http-proxy-temp-path=/usr/local/nginx/temp/proxy_temp --http-fastcgi-temp-path=/usr/local/nginx/temp/fastcgi_temp --http-scgi-temp-path=/usr/local/nginx/temp/scgi_temp --http-uwsgi-temp-path=/usr/local/nginx/temp/uwsgi_temp --with-openssl=/usr/local/src/openssl-master --with-zlib=/usr/local/src/zlib-1.2.11 --with-pcre=/usr/local/src/pcre2-10.33 --with-ld-opt=-ljemalloc --with-ld-opt=-Wl,-rpath,/usr/local/nginx/luajit/lib --add-module=/usr/local/src/lua-nginx-module-master --add-module=/usr/local/src/ngx_http_geoip2_module-master

make && make install

echo "export PATH=$PATH:/usr/local/nginx/sbin/" >> /etc/profile
source /etc/profile


mkdir -p /usr/local/nginx/ssl

openssl req -x509 -nodes -days 10000 -newkey rsa:2048 -keyout /usr/local/nginx/ssl/nginx.key -out /usr/local/nginx/ssl/nginx.crt -subj "/C=US/ST=US/L=US/O=ssl/OU=ssl/CN=ssl.com/emailAddress=admin@ssl.com"


echo "ulimit -n 65535" >> /etc/profile
echo "root soft nofile 65535" >> /etc/security/limits.conf
echo "root hard nofile 65535" >> /etc/security/limits.conf
echo "* soft nofile 65535" >> /etc/security/limits.conf
echo "* hard nofile 65535" >> /etc/security/limits.conf
source /etc/profile

 

centos7 源码编译安装nginx教程 nginx安装脚本

标签:安装教程   安装nginx   tab   crt   stc   文件描述符   firewalld   error   top   

原文地址:https://www.cnblogs.com/faberbeta/p/nginx-install01.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!