您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

服务器搭建2

2024/3/16 16:26:48发布19次查看
1.将nginx安装包拷贝到/opt/nginx目录下,修改权限,解压缩,同时编译安装.root@iz25n0utdnmz:/opt/nginx# chmod 777 nginx-1.9.3.tar.gz root@iz25n0utdnmz:/opt/nginx# ls -ltotal 848-rwxrwxrwx 1 root root 864430 aug 318:37 nginx-1.9.3.tar.gzroot@iz25n0utdnmz:/opt/nginx# tar -zxvf nginx-1.9.3.tar.gz root@iz25n0utdnmz:/opt/nginx/nginx-1.9.3# ./configure......(很多输出)......checking for pcre libraryin /usr/include/pcre/ ... not foundchecking for pcre libraryin /usr/pkg/ ... not foundchecking for pcre libraryin /opt/local/ ... not found./configure: error: the http rewrite module requires the pcre library.you can either disable the module by using --without-http_rewrite_moduleoption, or install the pcre library into the system, or build the pcre librarystatically from the source with nginx by using --with-pcre= option.提示缺少pcre,下载pcre并拷贝到/opt/pcre目录下,修改权限,解压缩,同时编译安装,root@iz25n0utdnmz:/opt/pcre# chmod 777 pcre-8.37.tar.gz root@iz25n0utdnmz:/opt/pcre# ls -ltotal 1996-rwxrwxrwx 1 root root 2041593 aug 518:31 pcre-8.37.tar.gzroot@iz25n0utdnmz:/opt/pcre# tar -zxvf pcre-8.37.tar.gz root@iz25n0utdnmz:/opt/pcre/pcre-8.37# ./configureroot@iz25n0utdnmz:/opt/pcre/pcre-8.37# makeroot@iz25n0utdnmz:/opt/pcre/pcre-8.37# make install安装完pcre后,继续安装nginx.root@iz25n0utdnmz:/opt/nginx/nginx-1.9.3# ./configure......(很多输出)......checking for sha1 in system md library... not foundchecking for sha1 in system openssl crypto library... not foundchecking for zlib library... not found./configure: error: the http gzip module requires the zlib library.you can either disable the module by using --without-http_gzip_moduleoption, or install the zlib library into the system, or build the zlib librarystatically from the source with nginx by using --with-zlib= option.提示缺少zlib,下载zlib并拷贝到/zlib/zlib目录下,修改权限,解压缩,同时编译安装,root@iz25n0utdnmz:/opt/zlib# chmod 777 zlib-1.2.8.tar.gz root@iz25n0utdnmz:/opt/zlib# ls -ltotal 560-rwxrwxrwx 1 root root 571091 aug 518:39 zlib-1.2.8.tar.gzroot@iz25n0utdnmz:/opt/zlib# tar -zxvf zlib-1.2.8.tar.gz root@iz25n0utdnmz:/opt/zlib/zlib-1.2.8# ./configureroot@iz25n0utdnmz:/opt/zlib/zlib-1.2.8# make root@iz25n0utdnmz:/opt/zlib/zlib-1.2.8# make install安装完zlib后,继续安装nginx.root@iz25n0utdnmz:/opt/nginx/nginx-1.9.3# ./configureconfiguration summary + using system pcre library + openssl library is not used + using builtin md5 code + sha1 library is not found + using system zlib library nginx path prefix: /usr/local/nginx nginx binary file: /usr/local/nginx/sbin/nginx nginx configuration prefix: /usr/local/nginx/conf nginx configuration file: /usr/local/nginx/conf/nginx.conf nginx pid file: /usr/local/nginx/logs/nginx.pid nginx error log file: /usr/local/nginx/logs/error.log nginx http access log file: /usr/local/nginx/logs/access.log nginx http client request body temporary files: client_body_temp nginx http proxy temporary files: proxy_temp nginx http fastcgi temporary files: fastcgi_temp nginx http uwsgi temporary files: uwsgi_temp nginx http scgi temporary files: scgi_temproot@iz25n0utdnmz:/opt/nginx/nginx-1.9.3# makeroot@iz25n0utdnmz:/opt/nginx/nginx-1.9.3# make install注意:ginx默认是在安在/usr/local/nginx下.2.启动,重启和停止nginx.root@iz25n0utdnmz:/usr/local/nginx/sbin# ./nginx root@iz25n0utdnmz:/usr/local/nginx/sbin# ./nginx -s reloadroot@iz25n0utdnmz:/usr/local/nginx/sbin# ./nginx -s stop3.nginx和tomcat集成配置.打开nginx的配置文件nginx.conf,在其中加入如下配置:参考配置1.conf.location ~ \.mvc { proxy_pass http://101.201.89.5:8080;}其中重要的配置如下:server { listen 80; server_name localhost; location ~ \.mvc { proxy_pass http://101.201.89.5:8080; }}这段配置的意思是:服务器监听80端口,当有以.mvc结尾的请求时,服务器将请求交给代理处理.其余配置先不做详细介绍.注意可以使用nginx -t指令校验配置文件配置的是否正确.root@iz25n0utdnmz:/usr/local/nginx/sbin# ./nginx -tnginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is oknginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful4.nginx和tomcat负载均衡配置.打开nginx的配置文件nginx.conf,在其中加入如下配置:参考配置2.conf.upstream myserver { server 101.201.89.5:8080 weight=1; server 101.201.89.5:8081 weight=1;}server { listen 80; server_name localhost; location ~ \.mvc { proxy_pass http://myserver; }}这段配置的意思是:服务器监听80端口,当有以.mvc结尾的请求时,服务器将请求交给代理处理,而代理指向的是一个服务器列表,通过upstream配置,通过名字myserver匹配,在服务器列表中有两个服务器,端口分别是8080,8081,权重都是1,即nginx会将发过来的请求按1:1的比例交给两个服务器处理,注意:如果某个服务器瘫痪了或者根本不存在,也不会影响业务,另一个服务器会处理所有请求.另一个tomcat的server.xml文件配置需要修改的地方如下:将8005改为8006:将8080改为8081:20000 redirectport=8443 />将8009改为8010: 如果两个服务都正常运行,可以通过记录log测试两个服务分别处理了不同的请求,如下:log4j.appender.file.file=/log/tomcat1/aplay-web.loglog4j.appender.file.file=/log/tomcat2/aplay-web.log
版权声明:本文为博主原创文章,未经博主允许不得转载。
以上就介绍了服务器搭建2,包括了方面的内容,希望对php教程有兴趣的朋友有所帮助。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product