search

<code><span>1.</span>将nginx安装包拷贝到/opt/nginx目录下,修改权限,解压缩,同时编译安装.
root@iZ25n0utdnmZ:/opt/nginx<span># chmod 777 nginx-1.9.3.tar.gz </span>
root@iZ25n0utdnmZ:/opt/nginx<span># ls -l</span>
total <span>848</span>
-rwxrwxrwx <span>1</span> root root <span>864430</span> Aug  <span>3</span><span>18</span>:<span>37</span> nginx-<span>1.9</span><span>.3</span>.tar.gz
root@iZ25n0utdnmZ:/opt/nginx<span># tar -zxvf nginx-1.9.3.tar.gz </span>
root@iZ25n0utdnmZ:/opt/nginx/nginx-<span>1.9</span><span>.3</span><span># ./configure</span>
......(很多输出)......
checking <span>for</span> PCRE <span>library</span><span>in</span> /usr/include/pcre/ <span>...</span> not found
checking <span>for</span> PCRE <span>library</span><span>in</span> /usr/pkg/ <span>...</span> not found
checking <span>for</span> PCRE <span>library</span><span>in</span> /opt/local/ <span>...</span> not found

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE <span>library</span> into the system, or build the PCRE <span>library</span>
statically from the <span>source</span> with nginx by using --with-pcre=<path> option.
提示缺少pcre,下载pcre并拷贝到/opt/pcre目录下,修改权限,解压缩,同时编译安装,
root@iZ25n0utdnmZ:/opt/pcre<span># chmod 777 pcre-8.37.tar.gz </span>
root@iZ25n0utdnmZ:/opt/pcre<span># ls -l</span>
total <span>1996</span>
-rwxrwxrwx <span>1</span> root root <span>2041593</span> Aug  <span>5</span><span>18</span>:<span>31</span> pcre-<span>8.37</span>.tar.gz
root@iZ25n0utdnmZ:/opt/pcre<span># tar -zxvf pcre-8.37.tar.gz </span>
root@iZ25n0utdnmZ:/opt/pcre/pcre-<span>8.37</span><span># ./configure</span>
root@iZ25n0utdnmZ:/opt/pcre/pcre-<span>8.37</span><span># make</span>
root@iZ25n0utdnmZ:/opt/pcre/pcre-<span>8.37</span><span># make install</span>
安装完pcre后,继续安装nginx.
root@iZ25n0utdnmZ:/opt/nginx/nginx-<span>1.9</span><span>.3</span><span># ./configure</span>
......(很多输出)......
checking <span>for</span> sha1 <span>in</span> system md <span>library</span><span>...</span> not found
checking <span>for</span> sha1 <span>in</span> system OpenSSL crypto <span>library</span><span>...</span> not found
checking <span>for</span> zlib <span>library</span><span>...</span> not found

./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib <span>library</span> into the system, or build the zlib <span>library</span>
statically from the <span>source</span> with nginx by using --with-zlib=<path> option.
提示缺少zlib,下载zlib并拷贝到/zlib/zlib目录下,修改权限,解压缩,同时编译安装,
root@iZ25n0utdnmZ:/opt/zlib<span># chmod 777 zlib-1.2.8.tar.gz </span>
root@iZ25n0utdnmZ:/opt/zlib<span># ls -l</span>
total <span>560</span>
-rwxrwxrwx <span>1</span> root root <span>571091</span> Aug  <span>5</span><span>18</span>:<span>39</span> zlib-<span>1.2</span><span>.8</span>.tar.gz
root@iZ25n0utdnmZ:/opt/zlib<span># tar -zxvf zlib-1.2.8.tar.gz </span>
root@iZ25n0utdnmZ:/opt/zlib/zlib-<span>1.2</span><span>.8</span><span># ./configure</span>
root@iZ25n0utdnmZ:/opt/zlib/zlib-<span>1.2</span><span>.8</span><span># make </span>
root@iZ25n0utdnmZ:/opt/zlib/zlib-<span>1.2</span><span>.8</span><span># make install</span>
安装完zlib后,继续安装nginx.
root@iZ25n0utdnmZ:/opt/nginx/nginx-<span>1.9</span><span>.3</span><span># ./configure</span>
Configuration summary
  + using system PCRE <span>library</span>
  + OpenSSL <span>library</span> is not used
  + using builtin md5 code
  + sha1 <span>library</span> is not found
  + using system zlib <span>library</span>  nginx path prefix: <span>"/usr/local/nginx"</span>
  nginx binary file: <span>"/usr/local/nginx/sbin/nginx"</span>
  nginx configuration prefix: <span>"/usr/local/nginx/conf"</span>
  nginx configuration file: <span>"/usr/local/nginx/conf/nginx.conf"</span>
  nginx pid file: <span>"/usr/local/nginx/logs/nginx.pid"</span>
  nginx error log file: <span>"/usr/local/nginx/logs/error.log"</span>
  nginx http access log file: <span>"/usr/local/nginx/logs/access.log"</span>
  nginx http client request body temporary files: <span>"client_body_temp"</span>
  nginx http proxy temporary files: <span>"proxy_temp"</span>
  nginx http fastcgi temporary files: <span>"fastcgi_temp"</span>
  nginx http uwsgi temporary files: <span>"uwsgi_temp"</span>
  nginx http scgi temporary files: <span>"scgi_temp"</span>
root@iZ25n0utdnmZ:/opt/nginx/nginx-<span>1.9</span><span>.3</span><span># make</span>
root@iZ25n0utdnmZ:/opt/nginx/nginx-<span>1.9</span><span>.3</span><span># make install</span>
注意:ginx默认是在安在/usr/local/nginx下.


<span>2.</span>启动,重启和停止nginx.
root@iZ25n0utdnmZ:/usr/local/nginx/sbin<span># ./nginx </span>
root@iZ25n0utdnmZ:/usr/local/nginx/sbin<span># ./nginx -s reload</span>
root@iZ25n0utdnmZ:/usr/local/nginx/sbin<span># ./nginx -s stop</span><span>3.</span>nginx和tomcat集成配置.
打开nginx的配置文件nginx.conf,在其中加入如下配置:参考配置<span>1.</span>conf.
location ~ \.mvc {
    proxy_pass http://<span>101.201</span><span>.89</span><span>.5</span>:<span>8080</span>;
}
其中重要的配置如下:
server {
    listen       <span>80</span>;
    server_name  localhost;

    location ~ \.mvc {
        proxy_pass http://<span>101.201</span><span>.89</span><span>.5</span>:<span>8080</span>;
    }
}
这段配置的意思是:服务器监听<span>80</span>端口,当有以.mvc结尾的请求时,服务器将请求交给代理处理.其余配置先不做详细介绍.
注意可以使用nginx -t指令校验配置文件配置的是否正确.
root@iZ25n0utdnmZ:/usr/local/nginx/sbin<span># ./nginx -t</span>
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful


<span>4.</span>nginx和tomcat负载均衡配置.
打开nginx的配置文件nginx.conf,在其中加入如下配置:参考配置<span>2.</span>conf.
upstream myserver {
    server <span>101.201</span><span>.89</span><span>.5</span>:<span>8080</span> weight=<span>1</span>;
        server <span>101.201</span><span>.89</span><span>.5</span>:<span>8081</span> weight=<span>1</span>;
}

server {
    listen       <span>80</span>;
    server_name  localhost;

    location ~ \.mvc {
        proxy_pass http://myserver;
    }
}
这段配置的意思是:服务器监听<span>80</span>端口,当有以.mvc结尾的请求时,服务器将请求交给代理处理,而代理指向的是一个服务器列表,通过upstream配置,
通过名字myserver匹配,在服务器列表中有两个服务器,端口分别是<span>8080</span>,<span>8081</span>,权重都是<span>1</span>,即nginx会将发过来的请求按<span>1</span>:<span>1</span>的比例交给两个服务器处理,
注意:如果某个服务器瘫痪了或者根本不存在,也不会影响业务,另一个服务器会处理所有请求.
另一个tomcat的server.xml文件配置需要修改的地方如下:
将<span>8005</span>改为<span>8006</span>:<server port="<span">"8006" shutdown=<span>"SHUTDOWN"</span>>
将<span>8080</span>改为<span>8081</span>:<connector port="<span">"8081" protocol=<span>"HTTP/1.1"</span> c>"20000" redirectPort=<span>"8443"</span> />
将<span>8009</span>改为<span>8010</span>:<connector port="<span">"8010" protocol=<span>"AJP/1.3"</span> redirectPort=<span>"8443"</span> /> 
如果两个服务都正常运行,可以通过记录log测试两个服务分别处理了不同的请求,如下:
log4j.appender.file.File=/log/tomcat1/aplay-web.log
log4j.appender.file.File=/log/tomcat2/aplay-web.log





</connector></connector></server></path></path></code>

Copyright Statement: This article is the original article of the blogger and may not be reproduced without the permission of the blogger.

The above introduces server building 2, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Beyond the Hype: Assessing PHP's Role TodayBeyond the Hype: Assessing PHP's Role TodayApr 12, 2025 am 12:17 AM

PHP remains a powerful and widely used tool in modern programming, especially in the field of web development. 1) PHP is easy to use and seamlessly integrated with databases, and is the first choice for many developers. 2) It supports dynamic content generation and object-oriented programming, suitable for quickly creating and maintaining websites. 3) PHP's performance can be improved by caching and optimizing database queries, and its extensive community and rich ecosystem make it still important in today's technology stack.

What are Weak References in PHP and when are they useful?What are Weak References in PHP and when are they useful?Apr 12, 2025 am 12:13 AM

In PHP, weak references are implemented through the WeakReference class and will not prevent the garbage collector from reclaiming objects. Weak references are suitable for scenarios such as caching systems and event listeners. It should be noted that it cannot guarantee the survival of objects and that garbage collection may be delayed.

Explain the __invoke magic method in PHP.Explain the __invoke magic method in PHP.Apr 12, 2025 am 12:07 AM

The \_\_invoke method allows objects to be called like functions. 1. Define the \_\_invoke method so that the object can be called. 2. When using the $obj(...) syntax, PHP will execute the \_\_invoke method. 3. Suitable for scenarios such as logging and calculator, improving code flexibility and readability.

Explain Fibers in PHP 8.1 for concurrency.Explain Fibers in PHP 8.1 for concurrency.Apr 12, 2025 am 12:05 AM

Fibers was introduced in PHP8.1, improving concurrent processing capabilities. 1) Fibers is a lightweight concurrency model similar to coroutines. 2) They allow developers to manually control the execution flow of tasks and are suitable for handling I/O-intensive tasks. 3) Using Fibers can write more efficient and responsive code.

The PHP Community: Resources, Support, and DevelopmentThe PHP Community: Resources, Support, and DevelopmentApr 12, 2025 am 12:04 AM

The PHP community provides rich resources and support to help developers grow. 1) Resources include official documentation, tutorials, blogs and open source projects such as Laravel and Symfony. 2) Support can be obtained through StackOverflow, Reddit and Slack channels. 3) Development trends can be learned by following RFC. 4) Integration into the community can be achieved through active participation, contribution to code and learning sharing.

PHP vs. Python: Understanding the DifferencesPHP vs. Python: Understanding the DifferencesApr 11, 2025 am 12:15 AM

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

PHP: Is It Dying or Simply Adapting?PHP: Is It Dying or Simply Adapting?Apr 11, 2025 am 12:13 AM

PHP is not dying, but constantly adapting and evolving. 1) PHP has undergone multiple version iterations since 1994 to adapt to new technology trends. 2) It is currently widely used in e-commerce, content management systems and other fields. 3) PHP8 introduces JIT compiler and other functions to improve performance and modernization. 4) Use OPcache and follow PSR-12 standards to optimize performance and code quality.

The Future of PHP: Adaptations and InnovationsThe Future of PHP: Adaptations and InnovationsApr 11, 2025 am 12:01 AM

The future of PHP will be achieved by adapting to new technology trends and introducing innovative features: 1) Adapting to cloud computing, containerization and microservice architectures, supporting Docker and Kubernetes; 2) introducing JIT compilers and enumeration types to improve performance and data processing efficiency; 3) Continuously optimize performance and promote best practices.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.