Available Apache 2 configuration

I am trying to write about 5 sites on one Apache server, which is on the same IP address.

For example:

  • / var / www / site1
  • / var / www / site2
  • / var / www / site3
  • / var / www / site4
  • / var / www / site5

However, if I create a link on site 2, simply using, for example. /index.php, you expect it to look in / var / www / site 2 / index.php ... but it actually resolves /var/www/index.php.

Is there a way to configure Apache to know that individual site folders should behave and allow separate folders?

This is my available file at the moment. I suppose a pretty standard setup:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride all
            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>

Any help would be appreciated.

Thank you.

Andrew Barlow

+5
source share
2

ServerName <VirtualHost>. , ( http://site1.example.com http://site2.example.com, IP-, , URL- ). <VirtualHost>, . ServerName DocumentRoot . "apache2ctl -S", , apache .

:

<VirtualHost *:80>
  ServerName site1.myserver.com
  DocumentRoot /var/www/site1
  ...
</VirtualHost>

<VirtualHost *:80>
  ServerName site2.myserver.com
  DocumentRoot /var/www/site2
  ...
</VirtualHost>

<VirtualHost *:80>
  ServerName site3.myserver.com
  DocumentRoot /var/www/site3
  ...
</VirtualHost>

<VirtualHost *:80>
  ServerName site4.myserver.com
  DocumentRoot /var/www/site4
  ...
</VirtualHost>

<VirtualHost *:80>
  ServerName site5.myserver.com
  DocumentRoot /var/www/site5
  ...
</VirtualHost>

, , , dns IP-. , ip-, ServerName . , "ServerAlias ​​secondname.myserver.com thirdname.myserver.com" ServerName

+11

@Zeograd , , , , , , a2enmod.

, Ubuntu:

sudo a2enmod rewrite
sudo service apache2 restart

sudo service apache2 restart , :

sudo /etc/init.d/apache2 restart
+3

All Articles