PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, September 21, 2022

[FIXED] how to set up 2 virtualhosts with the same root adress?

 September 21, 2022     apache2, virtualhost, wordpress     No comments   

Issue

I'd like to set up 2 wordpress sites on the same ip adress, that is ip_adress1/wordpress1 and ip_adress1/wordpress2.

I put these 2 files into /etc/apache2/sites-available (these are basically the same, only site's path changes)

<VirtualHost *:80>
DocumentRoot /usr/share/wordpress/MyFirstSite/
ServerName my.ip.adr.ess
ServerAlias my.ip.adr.ess/MyFirstSite/*
ServerAdmin myemail@adress.ext

Alias /MyFirstSite /usr/share/wordpress/FolderForMyFirstSite
<Directory /usr/share/wordpress/FolderForMyFirstSite>
Options FollowSymLinks MultiViews
Order allow,deny
AllowOverride All
Allow from all
</Directory>
<Directory /usr/share/wordpress/FolderForMyFirstSite/wp-content>
Options FollowSymLinks MultiViews
Order allow,deny
AllowOverride All
Allow from all
</Directory>
</VirtualHost>

and

<VirtualHost *:80>
DocumentRoot /usr/share/wordpress/MySecondSite/
ServerName my.ip.adr.ess
ServerAlias my.ip.adr.ess/MySecondSite/*
ServerAdmin myemail@adress.ext

Alias /MyFirstSite /usr/share/wordpress/FolderForMySecondSite
<Directory /usr/share/wordpress/FolderForMySecondSite>
Options FollowSymLinks MultiViews
Order allow,deny
AllowOverride All
Allow from all
</Directory>
<Directory /usr/share/wordpress/FolderForMySecondSite/wp-content>
Options FollowSymLinks MultiViews
Order allow,deny
AllowOverride All
Allow from all
</Directory>
</VirtualHost>

It seems that the 2 sites in sites-available can work separatly when I enable them.

When I enable both of them simultaneously though, only one works. I think it's overwriting the other... (no apache error, by the way)

One other thing : the sites works when I reach http://my.ip.adr.ess (without the path for the site). And that I'dont't want it to !

What do you think ?

Many thanks in advance

Stanislas


Solution

I made this,finally, which seems better, after reading a bit more docs (https://httpd.apache.org/docs/2.2/mod/mod_alias.html) about apache configuration :

<VirtualHost *:80>

DocumentRoot /usr/share/wordpress
ServerName my.ip.adr.ess
ServerAdmin my.email@adress.ext

Alias /Alias1 /usr/share/wordpress/Folder1
<Directory /usr/share/wordpress/Folder1>
Options FollowSymLinks MultiViews
Order allow,deny
AllowOverride All
Allow from all
</Directory>
<Directory /usr/share/wordpress/Folder1/wp-content>
Options FollowSymLinks MultiViews
Order allow,deny
AllowOverride All
Allow from all
</Directory>

Alias /Alias2 /usr/share/wordpress/Folder2
<Directory /usr/share/wordpress/Folder2>
Options FollowSymLinks MultiViews
Order allow,deny
AllowOverride All
Allow from all
</Directory>
<Directory /usr/share/wordpress/Folder2/wp-content>
Options FollowSymLinks MultiViews
Order allow,deny
AllowOverride All
Allow from all
</Directory>

</VirtualHost>


Answered By - St3an
Answer Checked By - Marilyn (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

1,207,102

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © 2025 PHPFixing