← Комьюнити

Могу ли я поставить два разных сайта на один апапчи local host и как это сделать?

student_CN3bg-EX5 ответов

могу ли я поставить два разных сайта на один апапчи local host и как это сделать ?

5 ответов

Можно хоть 100 локальный сайтов сделать. Просто нужно домены локальные делать в hosts и в настройках apache, типа такого:

Файл hosts:

127.0.0.1 site1.com
127.0.0.1 site2.com
127.0.0.1 site3.com
127.0.0.1 site4.com

И в настройках apache хосты:

<VirtualHost site1.com>
 DocumentRoot C:\xampp\htdocs\site1
 ServerName site1.com
 ServerAdmin admin@site1.com
 <Directory "C:\xampp\htdocs\site1">
  Options Indexes FollowSymLinks
  Allow from all
  Require all granted
  IndexIgnore /
  RewriteEngine on
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . index.php
 </Directory>
</VirtualHost>



<VirtualHost site2.com>
 DocumentRoot C:\xampp\htdocs\site2
 ServerName site2.com
 ServerAdmin admin@site2.com
 <Directory "C:\xampp\htdocs\site2">
  Options Indexes FollowSymLinks
  Allow from all
  Require all granted
  IndexIgnore /
  RewriteEngine on
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . index.php
 </Directory>
</VirtualHost>


<VirtualHost site3.com>
 DocumentRoot C:\xampp\htdocs\site3
 ServerName site3.com
 ServerAdmin admin@site3.com
 <Directory "C:\xampp\htdocs\site3">
  Options Indexes FollowSymLinks
  Allow from all
  Require all granted
  IndexIgnore /
  RewriteEngine on
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . index.php
 </Directory>
</VirtualHost>



<VirtualHost site4.com>
 DocumentRoot C:\xampp\htdocs\site4
 ServerName site4.com
 ServerAdmin admin@site4.com
 <Directory "C:\xampp\htdocs\site4">
  Options Indexes FollowSymLinks
  Allow from all
  Require all granted
  IndexIgnore /
  RewriteEngine on
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . index.php
 </Directory>
</VirtualHost>
student_cX4p_FA9

поставил, на втором сайте он показывает страницы первого ? как это исправить ?

student_CN3bg-EX

Может кеш браузера? В приватном режиме попробуй открыть и apache в xampp обязательно перезапусти после сохранения hosts + папки проверь в настройках apache и в C:\xampp\htdocs\ что есть site1, site2, site3 и site4

student_cX4p_FA9

spasibo

student_CN3bg-EX

проверил

неполучается

student_CN3bg-EX