设为首页 收藏本站
查看: 2502|回复: 0

[经验分享] nginx 安装手记

[复制链接]

尚未签到

发表于 2015-7-26 13:38:57 | 显示全部楼层 |阅读模式
  
Nginx需要依赖下面3个包


  • 1. gzip 模块需要 zlib 库 ( 下载: http://www.zlib.net/ )  zlib-1.2.8.tar.gz
  • 2. rewrite 模块需要 pcre 库 ( 下载: http://www.pcre.org/ )  pcre-8.21.tar.gz
  • 3. ssl 功能需要 openssl 库 ( 下载: http://www.openssl.org/ )  openssl-1.0.1.tar.gz
  注意:如果用源码安装的话,后面nginx安装的时候需要指定 --with-pcre 对应的压缩包路径,如果用二进制包安装则不需指定
  依赖包一键安装: yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel
  
  yum -y groupinstall "Development Tools" "Development Libraries" 此命令可以一键安装开发工具包
  
  安装命令: 



openssl:
tar -xzvf openssl-1.0.1.tar.gz
cd openssl-1.0.1
./config(注意) && make && make install
pcre:
tar -xzvf pcre-8.21.tar.gz
cd pcre-8.21
./configure  && make && make install
zlib:
tar -xzvf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure  && make && make install
  
  nginx安装命令: nginx各个版本下载地址:http://nginx.org/download/



groupadd -r nginx
useradd -r -g nginx -s /bin/false -M nginx
#注意 \ 前面至少一个有空格
./configure --sbin-path=/usr/local/nginx/nginx \
--conf-path=/usr/local/nginx/nginx.conf \
--pid-path=/usr/local/nginx/nginx.pid \
--with-http_ssl_module \
--with-pcre=../pcre-8.21 \  #指向解压的源码目录
--with-zlib=../zlib-1.2.8 \    #指向解压的源码目录
--with-openssl=../openssl-1.0.1 \ #指向解压的源码目录
--with-http_stub_status_module \#启用 nginx 的 NginxStatus 功能,用来监控 Nginx 的当前状态
--user=nginx \
--group=nginx
  注:编译好的nginx可以通过 /usr/local/nginx/nginx -V  (具体路径以安装的为主) 查看编译时候的参数
  
  启动nginx



/usr/local/nginx/nginx #不指定配置文件地址
/usr/local/nginx/nginx -c /usr/local/nginx/nginx.conf #指定配置文件地址
  
  停止服务



sudo kill `cat /usr/local/nginx/nginx.pid`
  
  服务控制脚本(todo)
  
  浏览器中输入localhost如果可以看到欢迎界面则安装成功
DSC0000.jpg
  虚拟主机配置
  只需更改 server_name 为对应的网站域名即可
DSC0001.jpg
  
  检测配置文件  



/usr/local/nginx/nginx -t
  
  重新加载配置文件(不停止服务)



/usr/local/nginx/nginx -s reload
  
  打开目录浏览功能



location / {
autoindex on;#打开目录列表
autoindex_exact_size off; #on显示文件的确切大小,off则会用M、G等单位
autoindex_localtime on; #显示文件服务器时间,off显示GMT时间
root   html;
index  index.html index.htm;
}
  
  Nginx编译参数解析



–prefix #nginx安装目录,默认在/usr/local/nginx
–pid-path #pid问件位置,默认在logs目录
–lock-path #lock问件位置,默认在logs目录
–with-http_ssl_module #开启HTTP SSL模块,以支持HTTPS请求。
–with-http_dav_module #开启WebDAV扩展动作模块,可为文件和目录指定权限
–with-http_flv_module #支持对FLV文件的拖动播放
–with-http_realip_module #支持显示真实来源IP地址
–with-http_gzip_static_module #预压缩文件传前检查,防止文件被重复压缩
–with-http_stub_status_module #取得一些nginx的运行状态
–with-mail #允许POP3/IMAP4/SMTP代理模块
–with-mail_ssl_module #允许POP3/IMAP/SMTP可以使用SSL/TLS
–with-pcre=../pcre-8.11 #注意是未安装的pcre路径
–with-zlib=../zlib-1.2.5 #注意是未安装的zlib路径
–with-debug #允许调试日志
–http-client-body-temp-path #客户端请求临时文件路径
–http-proxy-temp-path #设置http proxy临时文件路径
–http-fastcgi-temp-path #设置http fastcgi临时文件路径
–http-uwsgi-temp-path=/var/tmp/nginx/uwsgi #设置uwsgi 临时文件路径
–http-scgi-temp-path=/var/tmp/nginx/scgi #设置scgi 临时文件路径
  
  pcre安装日志



pcre-8.21 configuration summary:
Install prefix .................. : /usr/local
C preprocessor .................. : gcc -E
C compiler ...................... : gcc
C++ preprocessor ................ : g++ -E
C++ compiler .................... : g++
Linker .......................... : /usr/bin/ld
C preprocessor flags ............ :
C compiler flags ................ : -O2
C++ compiler flags .............. : -O2
Linker flags .................... :
Extra libraries ................. :
Build C++ library ............... : yes
Enable JIT compiling support .... : no
Enable UTF-8 support ............ : no
Unicode properties .............. : no
Newline char/sequence ........... : lf
\R matches only ANYCRLF ......... : no
EBCDIC coding ................... : no
Rebuild char tables ............. : no
Use stack recursion ............. : yes
POSIX mem threshold ............. : 10
Internal link size .............. : 2
Match limit ..................... : 10000000
Match limit recursion ........... : MATCH_LIMIT
Build shared libs ............... : yes
Build static libs ............... : yes
Use JIT in pcregrep ............. : no
Buffer size for pcregrep ........ : 20480
Link pcregrep with libz ......... : no
Link pcregrep with libbz2 ....... : no
Link pcretest with libreadline .. : no
——————————————————————————————————————————————————————————————————————
make[1]: Entering directory `/root/software/pcre-8.21'
test -z "/usr/local/lib" || /bin/mkdir -p "/usr/local/lib"
/bin/sh ./libtool   --mode=install /usr/bin/install -c   libpcre.la libpcreposix.la libpcrecpp.la '/usr/local/lib'
libtool: install: /usr/bin/install -c .libs/libpcre.so.0.0.1 /usr/local/lib/libpcre.so.0.0.1
libtool: install: (cd /usr/local/lib && { ln -s -f libpcre.so.0.0.1 libpcre.so.0 || { rm -f libpcre.so.0 && ln -s libpcre.so.0.0.1 libpcre.so.0; }; })
libtool: install: (cd /usr/local/lib && { ln -s -f libpcre.so.0.0.1 libpcre.so || { rm -f libpcre.so && ln -s libpcre.so.0.0.1 libpcre.so; }; })
libtool: install: /usr/bin/install -c .libs/libpcre.lai /usr/local/lib/libpcre.la
libtool: install: warning: relinking `libpcreposix.la'
libtool: install: (cd /root/software/pcre-8.21; /bin/sh /root/software/pcre-8.21/libtool  --tag CC --mode=relink gcc -O2 -version-info 0:0:0 -o libpcreposix.la -rpath /usr/local/lib pcreposix.lo libpcre.la )
libtool: relink: gcc -shared  -fPIC -DPIC  .libs/pcreposix.o   -Wl,-rpath -Wl,/usr/local/lib -L/usr/local/lib -lpcre  -O2   -Wl,-soname -Wl,libpcreposix.so.0 -o .libs/libpcreposix.so.0.0.0
libtool: install: /usr/bin/install -c .libs/libpcreposix.so.0.0.0T /usr/local/lib/libpcreposix.so.0.0.0
libtool: install: (cd /usr/local/lib && { ln -s -f libpcreposix.so.0.0.0 libpcreposix.so.0 || { rm -f libpcreposix.so.0 && ln -s libpcreposix.so.0.0.0 libpcreposix.so.0; }; })
libtool: install: (cd /usr/local/lib && { ln -s -f libpcreposix.so.0.0.0 libpcreposix.so || { rm -f libpcreposix.so && ln -s libpcreposix.so.0.0.0 libpcreposix.so; }; })
libtool: install: /usr/bin/install -c .libs/libpcreposix.lai /usr/local/lib/libpcreposix.la
libtool: install: warning: relinking `libpcrecpp.la'
libtool: install: (cd /root/software/pcre-8.21; /bin/sh /root/software/pcre-8.21/libtool  --tag CXX --mode=relink g++ -O2 -version-info 0:0:0 -o libpcrecpp.la -rpath /usr/local/lib pcrecpp.lo pcre_scanner.lo pcre_stringpiece.lo libpcre.la )
libtool: relink: g++  -fPIC -DPIC -shared -nostdlib /usr/lib/gcc/i686-redhat-linux/4.4.4/../../../crti.o /usr/lib/gcc/i686-redhat-linux/4.4.4/crtbeginS.o  .libs/pcrecpp.o .libs/pcre_scanner.o .libs/pcre_stringpiece.o   -Wl,-rpath -Wl,/usr/local/lib -L/usr/local/lib -lpcre -L/usr/lib/gcc/i686-redhat-linux/4.4.4 -L/usr/lib/gcc/i686-redhat-linux/4.4.4/../../.. -lstdc++ -lm -lc -lgcc_s /usr/lib/gcc/i686-redhat-linux/4.4.4/crtendS.o /usr/lib/gcc/i686-redhat-linux/4.4.4/../../../crtn.o  -O2   -Wl,-soname -Wl,libpcrecpp.so.0 -o .libs/libpcrecpp.so.0.0.0
libtool: install: /usr/bin/install -c .libs/libpcrecpp.so.0.0.0T /usr/local/lib/libpcrecpp.so.0.0.0
libtool: install: (cd /usr/local/lib && { ln -s -f libpcrecpp.so.0.0.0 libpcrecpp.so.0 || { rm -f libpcrecpp.so.0 && ln -s libpcrecpp.so.0.0.0 libpcrecpp.so.0; }; })
libtool: install: (cd /usr/local/lib && { ln -s -f libpcrecpp.so.0.0.0 libpcrecpp.so || { rm -f libpcrecpp.so && ln -s libpcrecpp.so.0.0.0 libpcrecpp.so; }; })
libtool: install: /usr/bin/install -c .libs/libpcrecpp.lai /usr/local/lib/libpcrecpp.la
libtool: install: /usr/bin/install -c .libs/libpcre.a /usr/local/lib/libpcre.a
libtool: install: chmod 644 /usr/local/lib/libpcre.a
libtool: install: ranlib /usr/local/lib/libpcre.a
libtool: install: /usr/bin/install -c .libs/libpcreposix.a /usr/local/lib/libpcreposix.a
libtool: install: chmod 644 /usr/local/lib/libpcreposix.a
libtool: install: ranlib /usr/local/lib/libpcreposix.a
libtool: install: /usr/bin/install -c .libs/libpcrecpp.a /usr/local/lib/libpcrecpp.a
libtool: install: chmod 644 /usr/local/lib/libpcrecpp.a
libtool: install: ranlib /usr/local/lib/libpcrecpp.a
libtool: finish: PATH="/usr/lib/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/mysql/bin:/root/bin:/sbin" ldconfig -n /usr/local/lib
----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
- use the `-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.

  
  openssl安装日志



[iyunv@localhost openssl-fips-2.0.2]# make install
if [ -n "libcrypto" ]; then \
EXCL_OBJ='aes-586.o aesni-x86.o bn-586.o co-586.o x86-mont.o x86-gf2m.o des-586.o crypt586.o x86cpuid.o sha1-586.o sha256-586.o sha512-586.o ghash-x86.o ../crypto/aes/aes_cfb.o ../crypto/aes/aes_ecb.o ../crypto/aes/aes_ofb.o ../crypto/bn/bn_add.o ../crypto/bn/bn_blind.o ../crypto/bn/bn_ctx.o ../crypto/bn/bn_div.o ../crypto/bn/bn_exp2.o ../crypto/bn/bn_exp.o ../crypto/bn/bn_gcd.o ../crypto/bn/bn_gf2m.o ../crypto/bn/bn_lib.o ../crypto/bn/bn_mod.o ../crypto/bn/bn_mont.o ../crypto/bn/bn_mul.o ../crypto/bn/bn_nist.o ../crypto/bn/bn_prime.o ../crypto/bn/bn_rand.o ../crypto/bn/bn_recp.o ../crypto/bn/bn_shift.o ../crypto/bn/bn_sqr.o ../crypto/bn/bn_word.o ../crypto/bn/bn_x931p.o ../crypto/buffer/buf_str.o ../crypto/cmac/cmac.o ../crypto/cryptlib.o ../crypto/des/cfb64ede.o ../crypto/des/cfb64enc.o ../crypto/des/cfb_enc.o ../crypto/des/ecb3_enc.o ../crypto/des/ofb64ede.o ../crypto/des/fcrypt.o ../crypto/des/set_key.o ../crypto/dh/dh_check.o ../crypto/dh/dh_gen.o ../crypto/dh/dh_key.o ../crypto/dsa/dsa_gen.o ../crypto/dsa/dsa_key.o ../crypto/dsa/dsa_ossl.o ../crypto/ec/ec_curve.o ../crypto/ec/ec_cvt.o ../crypto/ec/ec_key.o ../crypto/ec/ec_lib.o ../crypto/ec/ecp_mont.o ../crypto/ec/ec_mult.o ../crypto/ec/ecp_nist.o ../crypto/ec/ecp_smpl.o ../crypto/ec/ec2_mult.o ../crypto/ec/ec2_smpl.o ../crypto/ecdh/ech_key.o ../crypto/ecdh/ech_ossl.o ../crypto/ecdsa/ecs_ossl.o ../crypto/evp/e_aes.o ../crypto/evp/e_des3.o ../crypto/evp/e_null.o ../crypto/evp/m_sha1.o ../crypto/evp/m_dss1.o ../crypto/evp/m_dss.o ../crypto/evp/m_ecdsa.o ../crypto/hmac/hmac.o ../crypto/modes/cbc128.o ../crypto/modes/ccm128.o ../crypto/modes/cfb128.o ../crypto/modes/ctr128.o ../crypto/modes/gcm128.o ../crypto/modes/ofb128.o ../crypto/modes/xts128.o ../crypto/rsa/rsa_eay.o ../crypto/rsa/rsa_gen.o ../crypto/rsa/rsa_crpt.o ../crypto/rsa/rsa_none.o ../crypto/rsa/rsa_oaep.o ../crypto/rsa/rsa_pk1.o ../crypto/rsa/rsa_pss.o ../crypto/rsa/rsa_ssl.o ../crypto/rsa/rsa_x931.o ../crypto/rsa/rsa_x931g.o ../crypto/sha/sha1dgst.o ../crypto/sha/sha256.o ../crypto/sha/sha512.o ../crypto/thr_id.o ../crypto/uid.o' ; export EXCL_OBJ ; \
ARX='/usr/bin/perl ${TOP}/util/arx.pl ar  r' ; \
else \
ARX='ar  r' ; \
fi ; export ARX ; \
if [ y = "y" ]; then \
AS='/usr/bin/perl ${TOP}/util/fipsas.pl ${TOP} ${

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-90832-1-1.html 上篇帖子: nginx摘录 下篇帖子: django 部署,gunicorn、virtualenv、nginx
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表