0

Apache サーバーを使用して Linux マシンでホストしたい 2 つの Web サイトがあります。この時点ではドメイン名を取得できないため、まだドメイン名を取得する必要がないため、IP 経由でサーバーにアクセスします。最初のサイトはいくつかの HTML ページで構成され、 にあり、もう 1 つのサイトは にある/var/hostroot/lifeonearth/{all files here}いくつかの PHP ページで構成されてい/var/hostroot/webDarts/{all files here}ます。デフォルトでは、自分の IP アドレスにアクセスすると、デフォルトの「Your Apache server is working」ページに移動します。lifeonearth.(my IP)したがって、ここからは、またはまたはのような何らかのサブドメインを介して各サイトにアクセスできるようにするにはどうすればよいでしょうかwebDarts.(my IP)。異なるポートを介してそれらにアクセスすることになっています。後者の場合、どうすればいいですか?

4

1 に答える 1

0

2 つの Web サイト名があります。

1. example1.test.local  (/var/www/example1) 
2. example2.test.local (/var/www/example2)

example1example2in という名前の 2 つのファイルを作成します/etc/apache2/sites-available

example1ファイルは次のようになります

<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/example1
ServerName example1.test.local
<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>
<Directory /var/www/example1>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
</Directory>

ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

同様に、という別のファイルを作成しexample2、次の行を変更します

DocumentRoot /var/www/example2
ServerName example2.test.local

<Directory /var/www/example2>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
</Directory>

ファイルの残りの部分は次と同じになりますexample1.

次に、これら 2 つのサイトを有効にします

a2ensite example1
a2ensite example2

次に、Apache サービスの再起動を行います。

次に、DNS ポインティングを行う必要があります

Linux マシンがローカルの場合は、これらの Web サイトにアクセスする Windows マシンに移動し、次のファイルを開きます。C:\Windows\System32\drivers\etc\hosts

あなたのIPとウェブサイト名に言及してください

192.168.249.101 example1.test.local
192.168.249.101 example2.test.local

それでおしまい!問題が見つかった場合は、お知らせください。

私は最後にこのシナリオを複製しましたが、それは私にとってはうまくいきます。それがあなたのために働くことを願っています!

于 2016-04-09T14:34:53.100 に答える