服务器搭建2

Aug 08, 2016 am 09:18 AM
nginx pcre root zlib

<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>
Copier après la connexion

版权声明:本文为博主原创文章,未经博主允许不得转载。

以上就介绍了服务器搭建2,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn

Outils d'IA chauds

Undresser.AI Undress

Undresser.AI Undress

Application basée sur l'IA pour créer des photos de nu réalistes

AI Clothes Remover

AI Clothes Remover

Outil d'IA en ligne pour supprimer les vêtements des photos.

Undress AI Tool

Undress AI Tool

Images de déshabillage gratuites

Clothoff.io

Clothoff.io

Dissolvant de vêtements AI

Video Face Swap

Video Face Swap

Échangez les visages dans n'importe quelle vidéo sans effort grâce à notre outil d'échange de visage AI entièrement gratuit !

Outils chauds

Bloc-notes++7.3.1

Bloc-notes++7.3.1

Éditeur de code facile à utiliser et gratuit

SublimeText3 version chinoise

SublimeText3 version chinoise

Version chinoise, très simple à utiliser

Envoyer Studio 13.0.1

Envoyer Studio 13.0.1

Puissant environnement de développement intégré PHP

Dreamweaver CS6

Dreamweaver CS6

Outils de développement Web visuel

SublimeText3 version Mac

SublimeText3 version Mac

Logiciel d'édition de code au niveau de Dieu (SublimeText3)

Comment configurer le nom de domaine du serveur cloud dans nginx Comment configurer le nom de domaine du serveur cloud dans nginx Apr 14, 2025 pm 12:18 PM

Comment configurer un nom de domaine NGINX sur un serveur cloud: Créez un enregistrement A pointant vers l'adresse IP publique du serveur cloud. Ajoutez des blocs d'hôtes virtuels dans le fichier de configuration Nginx, en spécifiant le port d'écoute, le nom de domaine et le répertoire racine du site Web. Redémarrez Nginx pour appliquer les modifications. Accéder à la configuration du test de nom de domaine. Autres notes: Installez le certificat SSL pour activer HTTPS, assurez-vous que le pare-feu autorise le trafic Port 80 et attendez que la résolution DNS prenne effet.

Comment vérifier le nom du conteneur Docker Comment vérifier le nom du conteneur Docker Apr 15, 2025 pm 12:21 PM

Vous pouvez interroger le nom du conteneur Docker en suivant les étapes: répertorier tous les conteneurs (Docker PS). Filtrez la liste des conteneurs (à l'aide de la commande grep). Obtient le nom du conteneur (situé dans la colonne "Noms").

Comment vérifier si Nginx est démarré Comment vérifier si Nginx est démarré Apr 14, 2025 pm 01:03 PM

Comment confirmer si Nginx est démarré: 1. Utilisez la ligne de commande: SystemCTl Status Nginx (Linux / Unix), netStat -ano | Findstr 80 (Windows); 2. Vérifiez si le port 80 est ouvert; 3. Vérifiez le message de démarrage NGINX dans le journal système; 4. Utilisez des outils tiers, tels que Nagios, Zabbix et Icinga.

Comment configurer Nginx dans Windows Comment configurer Nginx dans Windows Apr 14, 2025 pm 12:57 PM

Comment configurer Nginx dans Windows? Installez Nginx et créez une configuration d'hôte virtuelle. Modifiez le fichier de configuration principale et incluez la configuration de l'hôte virtuel. Démarrer ou recharger nginx. Testez la configuration et affichez le site Web. Activer sélectivement SSL et configurer les certificats SSL. Définissez sélectivement le pare-feu pour permettre le trafic Port 80 et 443.

Comment vérifier la version nginx Comment vérifier la version nginx Apr 14, 2025 am 11:57 AM

Les méthodes qui peuvent interroger la version Nginx sont: utilisez la commande nginx -v; Afficher la directive de version dans le fichier nginx.conf; Ouvrez la page d'erreur Nginx et affichez le titre de la page.

Comment démarrer le serveur Nginx Comment démarrer le serveur Nginx Apr 14, 2025 pm 12:27 PM

Le démarrage d'un serveur Nginx nécessite différentes étapes en fonction des différents systèmes d'exploitation: Système Linux / Unix: Installez le package NGINX (par exemple, en utilisant Apt-Get ou Yum). Utilisez SystemCTL pour démarrer un service NGINX (par exemple, sudo systemctl start nginx). Système Windows: téléchargez et installez les fichiers binaires Windows. Démarrer Nginx à l'aide de l'exécutable Nginx.exe (par exemple, nginx.exe -c conf \ nginx.conf). Peu importe le système d'exploitation que vous utilisez, vous pouvez accéder au serveur IP

Comment démarrer un conteneur par Docker Comment démarrer un conteneur par Docker Apr 15, 2025 pm 12:27 PM

Étapes de démarrage du conteneur Docker: Tirez l'image du conteneur: Exécutez "Docker Pull [Mirror Name]". Créer un conteneur: utilisez "Docker Create [Options] [Mirror Name] [Commandes et paramètres]". Démarrez le conteneur: exécutez "docker start [nom de conteneur ou id]". Vérifiez l'état du conteneur: vérifiez que le conteneur s'exécute avec "Docker PS".

Comment créer des conteneurs pour Docker Comment créer des conteneurs pour Docker Apr 15, 2025 pm 12:18 PM

Créer un conteneur dans Docker: 1. Tirez l'image: docker pull [Nom du miroir] 2. Créer un conteneur: docker run [Options] [Nom du miroir] [Commande] 3. Démarrez le conteneur: docker start [Nom du conteneur]

See all articles