ホームページ  >  記事  >  運用・保守  >  Apacheで複数のhttpポートを設定する方法

Apacheで複数のhttpポートを設定する方法

王林
王林転載
2020-11-03 17:03:214549ブラウズ

Apacheで複数のhttpポートを設定する方法

方法 1: httpd-vhosts を使用する

(関連する推奨事項: apache)

Apache 構成ディレクトリを入力します。 as / usr/local/apache/conf/

httpd.conf ファイルを開きます

複数のリスニング ウィンドウを構成します 81、82

ServerName localhost:81  
# Listen 80
Listen 81  
Listen 82

#Include conf/extra/httpd を見つけます-vhosts .conf、# 記号を削除し、コメントを解除します。

/usr/local/apache/conf/extra ディレクトリに入り、httpd-vhosts.conf ファイルを開きます。

NameVirtualHost を構成します *:81

<VirtualHost *:81>
    ServerAdmin host1.example.com
    DocumentRoot "/home/public/web/host1"
    ServerName localhost:81
    ServerAlias localhost:81
    ErrorLog "logs/host1.example.com-error_log"
   #CustomLog "logs/host1.example.com-access_log common"
</VirtualHost>
    
<VirtualHost *:82>
    ServerAdmin host2.example.com
    DocumentRoot "/home/public/web/host2"
    ServerName localhost:82
    ErrorLog "logs/host1.example.com-error_log"
   #CustomLog "logs/host1.example.com-access_log common"
</VirtualHost>

方法 2: httpd.conf のみを変更する

Apache 構成ディレクトリ (/usr/local/apache/conf/

など) を入力して httpd.conf ファイルを開きます

設定 複数のリスニング ウィンドウ、81、82

Listen   81
Listen   82

を設定し、ファイルの最後に次の内容を追加します:

<VirtualHost *:81>
DocumentRoot /home/public/web/host1
ServerName localhost:81
</VirtualHost>

<Directory /home/public/web/host1>
 Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>

<VirtualHost *:82>
DocumentRoot /home/public/web/host2
ServerName localhost:82
</VirtualHost>

<Directory /home/public/web/host2>
 Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>

さまざまなバージョンの Apache ディレクトリのアクセス許可設定

1、古い使用例

Order allow,deny
Allow from all

2、新しい使用例

Require all granted

3、新しい例

#add for WWW
Listen 91
<VirtualHost *:91>
DocumentRoot  "D:/IDE/WWW"
ServerName localhost:91
</VirtualHost>

<Directory "D:/IDE/WWW">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

以上がApacheで複数のhttpポートを設定する方法の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

声明:
この記事はcsdn.netで複製されています。侵害がある場合は、admin@php.cn までご連絡ください。