2017-08-13 7 views
0

私はこの名前を付ける用語を持っていませんが、私がやっていることは、専用のDNSなしで私のIPアドレスから別のWeb開発プロジェクトを実行しています。つまり11.11.11.11/site1,11.11.11.11/site2,11.11.11.11/site3から別のサイトにアクセスできます。Apache2、1つのIPアドレスに仮想ホストを作成する

私はいつもそのことができると思っていましたが、実際にはできません。毎回エラー404が出ます。

サイトに.confファイルを設定しました。サーバー名は1111.11.11/site#、DocumentRootは/var/www/html/example.com/public_htmlです。まだ運がありません。

誰かが間違っている可能性があることを知っていますか?

はここで私は404エラーを与える私の.confファイルの1の例です:

<VirtualHost *:80> 
     ServerName ###.###.###.###/example.html 
     #the hashes represent my actual ip. 

     ServerAdmin [email protected] 
     Alias /example.html /index.html 
     DocumentRoot /var/www/html/example.com/public_html 

     ErrorLog ${APACHE_LOG_DIR}/error.log 
     CustomLog ${APACHE_LOG_DIR}/access.log combined 
</VirtualHost> 

答えて

1

あなたがエイリアスを使用する必要があります:あなたの編集に基づいて、あなたを

Alias /site1 /home/site1/ 
Alias /site2 /home/site2/ 
Alias /site3 /home/site3/ 
# Don't add trailing slash at the end of the alias address ie. /site1/ is wrong . 

more inforamtion

をこれを試してみてください。コメントを書き留めてください。

<VirtualHost *:80> 
     ServerName 127.0.0.1 
     #don't put any file name just dns name so you may use localhost 
     #or your domain.com or an IP. 
     ServerAdmin [email protected] 
     Alias /site1 /var/www/html/folder/to/site1 
     Alias /site2 /var/www/html/folder/to/site2 

     #you will assign an alias folder name to real folder in your system 
     #so the first argument is /site1 and it can be anything you want 
     #you can make it /app and make it point to /path/to/site/2 
     #You don't need to specify file names like you did in your example   
     #you just put the folder name and inside that folder you can access any file 
     #defult to index.html 

     DocumentRoot /var/www/html/example.com/public_html 
     ErrorLog ${APACHE_LOG_DIR}/error.log 
     CustomLog ${APACHE_LOG_DIR}/access.log combined 
</VirtualHost> 
+0

良い点Karam。しかし、悲しいかな、私は成功を収めていません。あなたが私の.confファイルで見たように、私があなたが思ったことを試しました。私はまだ404エラーを取得しています。 .confファイルが問題を理解しやすくなることを願っています。 –

+0

更新された回答を確認してください。 –

関連する問題