2分钟教你玩转Tengine编译安装部署

2分钟教你玩转Tengine编译安装部署,第1张

2分钟教你玩转Tengine编译安装部署

t发动机部分特征


  • NGX-M查看所有已经加载的模块。静态表示已经安装,共享表示动态安装。


  • nginx架构是模块化的,除了主模块,其他模块需要在安装时编译安装,也可以在安装后编译安装;


  • Tengine完全兼容nginx配置;


  • Tengine可以动态加载模块,无需重新编译就可以安装新模块。默认情况下将安装动态模块功能。Nginx不支持动态加载模块,需要编译重启。



  • 先下载tengine-2.2.0.tar.gz;下载链接:http://pan.baidu.com/s/1jI7cycm密码:ig6x


  • #安装编译所需的环境:

  • yumgroupinstall"开发工具""服务器平台开发"-y

  • #安装编译所需的扩展:

  • yum-yinstallzlib-develpcre-develOpenSSL-devel

    #评论

    Zlib-devel扩展模块:支持压缩

    Pcre-devel扩展模块:支持url重写和池扩展。

    Openssl-devel扩展模块:支持https协议


  • #检查编译支持的模块(个别常用的):

  • [[email protected]]#。/configure-help|less -prefix=Pathsetinstallationprefix#指定安装路径 -sbin-path=pathsetnginx二进制路径名#nginx二进制启动脚本路径 -conf-Path=Pathsetnginx.conf路径名#配置文件的路径 -error-log-Path=Pathseterrorlog路径名#errorlog路径名 -PID-Path=Pathsetnginx.PID路径名#Pid存储路径 -lock-path=pathsetnginx打开 -默认情况下不启用-http_stub_status_moduledisablengx_http_stub_status_module#ngixn的状态页,默认情况下关闭 -启用-http_gzip_static_moduleenablingx_http_gzip_static_的状态页。

  • 编译引擎:

  • [[email protected]]#。/configure-prefix=/usr/local/nginx-sbin-path=/usr/local/nginx/sbin/nginx-conf-path=/usr/local/nginx.conf-error-log-path=/usr/local/nginx/log/error.log-http-log-path=/usr/local/nginx/log/access.log-PID-path=/usr/local/nginx/nginx.PID-lock-path=/usr/local/nginx

    [[email protected]]#make-j4&;&进行安装

    剖面图部分:

  • #修改nginx.conf文件中http模块的配置,原文件可以用mv备份。

  • vimnginx.conf 用户root worker_processes4; error_log/usr/local/nginx/log/error.log; PID/usr/local/nginx/log/nginx.PID; 事件{ worker_connections10240; 使用epoll } http{ includemime.types; default_typeapplication/octet-stream; log_formatmain'$remote_addr-$remote_user[$time_local]$server_name"$request"' '$status$body_bytes_sent"$http_referer"' '"$http_user_agent""$http_x_forwarded_for""time:$request_time"'; access_log/usr/local/nginx/log/access.logmain; client_max_body_size500m; 在上发送文件; keepalive_timeout300; gzipon; gzip_disable"msie6"; gzip_proxyany; gzip_min_length2048; gzip_comp_level4; gzip_typestext/plainapplication/x-JavaScriptapplication/JavaScripttext/JavaScripttext/CSSapplication/XMLapplication/JSONp_w_picpath/JPEGp_w_picpath/gifp_w_picpath/png; include/usr/local/nginx/conf/conf.d/*。conf 包含conf.d/*。conf#当然也可以改成相对路径 }

  • #nginx启动脚本,复制nginx的或者网上复制一个启动脚本,自己修改。如下

  • [root@Meng~]#cat/etc/init.d/nginx #!/bin/bash # #nginx-这个脚本启动和停止nginx守护进程 # #chkconfig:-8515 #描述:nginx是HTTP(S)服务器、HTTP(S)反向 #代理和IMAP/POP3代理服务器 #processname:Nginx #config:/etc/Nginx/nginnx.conf #config:/ 。/etc/RC.d/init.d/functions #源网络配置。 。/etc/sysconfig/network #检查网络是否正常。 ["$NETWORKING"="no"]&;&exit0 TENGINE_HOME="/usr/local/NGINX/" NGINX=$TENGINE_HOME"sbin/NGINX" Prog=$(basename$NGINX) NGINX_CONF_FILE=$TENGINE_HOME"conf/NGINX.conf"[-f/etc/sysconfig/NGINX]&;&/etc/sysconfig/NGINX lockFILE=/usr/local/NGINX/lock/NGINX.lock start(){ [-x$NGINX]||exit5 [-f$NGINX_CONF_文件]||exit6 echo-n$"Starting$Prog:" daemon$NGINX-c$NGINX_CONF_FILE retval=$? echo [$retval-eq0]&;&touch$lockfile return$retval } stop(){ echo-n$"停止$Prog:" killproc$Prog-QUIT retval=$? echo [$retval-eq0]&;&RM-f$lockfile retval killall-9nginx } restart(){ configtest||return$? stop sleep1 start } reload(){ configtest||return$? echo-n$"重载$Prog:" killproc$nginx-HUP RETVAL=$? echo } force_reload(){ restart } configtest(){ $NGINX-t-c$NGINX_CONF_文件 } RH_status(){ status$Prog } RH_status_q(){ RH_status>;/dev/null2>;&1 } case"$1in start) RH_status_q&;&退出0 $1 ;; stop) RH_status_q||exit0 $1 ;; restart|configtest) $1 ;; reload) rh_status_q||出口7 $1 ;; force-reload) force_reload ;; status) RH_status ;; condrestart|try-restart) RH_status_q||exit0 ;; *) echo$"用法:$0{start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}" exit2 esac

  • #提示锁定目录文件不存在

  • [root@Meng~]#servicenginxstart 正在启动nginx:[OK] touch:无法创建“/usr/local/nginx/lock/nginx.lock”:没有这个文件或目录 [/

  • #创建一个锁目录并重启nginx

  • [root@Meng~]#mkdir/usr/local/nginx/lock/ [root@Meng~]#servicenginx重启 nginx:配置文件/usr/local/nginx/conf/nginx.conf语法正常 nginx:配置文件/usr/local/nginx/conf/nginx.conf测试成功 停止nginx:[正常] 启动nginx:[正常] []

  • #创建静态web服务器:

  • [[email protected]]#catstatic.conf server{ listen80default_server; server_name_; location/{ root/data/company/; 索引index.htmlindex.htm; } } server{ listen81default_server; server_name_; location/{ root/data/www/; 索引index.htmlindex.htm; } } server{ listen82default_server; server_name_; location/{ root/data/Meng/; 索引index.htmlindex.htm; } }

  • #创建静态资源目录:

  • mkdir/data/Meng

  • #创建一个index.html页面。

  • [root@孟梦]#猫index.html 192.168.121.128

  • #通过浏览器访问:

  • 直到编译和安装配置完成。

    欢迎分享,转载请注明来源:内存溢出

    原文地址: http://outofmemory.cn/zz/777756.html

    (0)
    打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
    上一篇 2022-05-03
    下一篇 2022-05-03

    发表评论

    登录后才能评论

    评论列表(0条)

    保存