Don's picture



I'm currently running the Joomla1.6 app "TurnKey Linux 11.2 / Ubuntu 10.04 Lucid LTS"

I would like to run more than one Joomla based site on this server. They would not be sharing the same database, or anything of that nature. Separate directories, separate databases, and the possibility of different Joomla versions on each site. (So, no upgrading all sites at once.)

In looking at the Apache config, I would have thought that it would be as "simple" as creating a new virtual server, and telling it to answer HTTP's for www.domain2.com and look to /var/www/fakenewdir for the files. Is there something I'm missing? In the virtual server details, wouldn't you just change the "Address" field to the new domain (in this example www.domain2.com)? I'm guessing I'd need to change the one that is currently pointing to "/var/www/joomla/" to the actual domain of the current website, versus the "Any" right?

Forum: 
Don's picture

Anyone?

Eric (tssgery)'s picture

You might get a better (more definitive) answer from the Joomla community than the TKL community, but I'll give it a go.

I haven't played with Joomla for a while, but I think you can:

  1. duplicate the joomla directory for the second site (if the default location is /var/www/joomla, you can copy it ands the contents to /var/www/secondsite)
  2. Modify the second sites configration to use a second database to store content
  3. Modify the apache configuration to create a second virtual host as you note above

There may be a few other gotchas but I think you have the right idea and have started down this path. Have you tried this to see what happens?

Don's picture

It's the step 3 that's throwing things for a loop.

I've set the site for ---

Handles the name-based server on address dev.secondsite.tld.

Address dev.secondsite.tld
Port 80
Server Name Automatic
Document Root
/var/www/secondsite

The default configuration is left in place....

Handles the name-based server on address *.

Address Any
Port 80
Server Name Automatic
Document Root /var/www/joomla/

However, any requests that come in will go to the default site associated with /var/www/joomla.

I know I would have tested by modifying my local hosts file (Vista) and can't recall if I tried with DNS modified or not.

Was there something more than the above I needed to do? I would have thought the above config would work.

Eric (tssgery)'s picture

I'm not sure, but...

 

I'll try this out a little later today and post back my results.

Eric (tssgery)'s picture

In order to test this, I just created a second site in my apache configuration and pointed it at a new directory containing just in index.html file.

Presumably, I could copy in the joomla files, create a second database in mysql, and change the configuration.php settings and have things working. I didn't got that far in this test

 

Here is what I did

  • As root, logged in and created an additional file in /etc/apache2/sites-available called "site2" to represent my second site. I actually just coped the "joomla" site file to "site2" and edited it as appropriate and added the "ServerName" directive.
  • Create a symlink in /etc/apache2/sites-enabled to the /etc/apache2/sites-available/site2 configuration
  • Restarted apache2

After doing that, http://site2 brought me to my new site and anything else showed joomla.

For reference, here is my /etc/apache2/sites-available/site file

NameVirtualHost *:80
NameVirtualHost *:443

<VirtualHost *:80>
    ServerName  site2
    UseCanonicalName Off
    ServerAdmin  webmaster@localhost
    DocumentRoot /var/www/site2/
</VirtualHost>

<VirtualHost *:443>
    SSLEngine on
    ServerName site2
    SSLCertificateFile /etc/ssl/certs/cert.pem
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/site2/
</VirtualHost>

<Directory /var/www/site2/>
    Options +FollowSymLinks
    AllowOverride All
    order allow,deny
    allow from all
</Directory>

Don's picture

I'll give it another test tonight (or this weekend.)

Eric (tssgery)'s picture

That should do what you need but please post back as to your success/failure.

Don's picture

Still routing to the main server. Copied are the two files from /etc/apache2/sites-available - If I've missed something simple, please let me know. (Restarted Apache2 many, many times, so didn't forget that.)

'joomla'

NameVirtualHost dev.thedisplayfinder.com:80
NameVirtualHost *:443

<Directory /var/www/joomla/>
    Options +FollowSymLinks
    AllowOverride All
    order allow,deny
    allow from all
</Directory>
 

site2 file

NameVirtualHost site2.thedisplayfinder.com:80
NameVirtualHost site2.thedisplayfinder.com:443

<VirtualHost *:80>
ServerName site2
    UseCanonicalName Off
    ServerAdmin  webmaster@localhost
DocumentRoot /var/www/site2/
<Directory "/var/www/site2/">
</Directory>
</VirtualHost>

<VirtualHost *:443>
    SSLEngine on
    ServerName site2
    SSLCertificateFile /etc/ssl/certs/cert.pem
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/site2/
</VirtualHost>

<Directory /var/www/site2/>
    Options +FollowSymLinks
    AllowOverride All
    order allow,deny
    allow from all
</Directory>
 

ls -alF of /etc/apache2/sites-enabled
site2 -> ../sites-available/site2

ls -alF of /var/www/site2/
   6 Sep 16 03:13 index.html
 

Eric (tssgery)'s picture

Here are my two files:

 

/etc/apache2/sites-available/joomla (I did not modify this at all)

NameVirtualHost *:80
NameVirtualHost *:443

<VirtualHost *:80>
    UseCanonicalName Off
    ServerAdmin  webmaster@localhost
    DocumentRoot /var/www/joomla/
</VirtualHost>

<VirtualHost *:443>
    SSLEngine on
    SSLCertificateFile /etc/ssl/certs/cert.pem
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/joomla/
</VirtualHost>

<Directory /var/www/joomla/>
    Options +FollowSymLinks
    AllowOverride All
    order allow,deny
    allow from all
</Directory>


 

/etc/apache2/sites-available/site2

NameVirtualHost *:80
NameVirtualHost *:443

<VirtualHost *:80>
    ServerName  site2
    UseCanonicalName Off
    ServerAdmin  webmaster@localhost
    DocumentRoot /var/www/site2/
</VirtualHost>

<VirtualHost *:443>
    ServerName  site2
    SSLEngine on
    SSLCertificateFile /etc/ssl/certs/cert.pem
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/site2/
</VirtualHost>

<Directory /var/www/site2/>
    Options +FollowSymLinks
    AllowOverride All
    order allow,deny
    allow from all
</Directory>


Don's picture

I guess it's not meant to be. I've got to be missing something so incredibly simple it's not even funny. However, I can't seem to figure out what it is. I duplicated your files ... still get directed to the main site.

Thanks for the help. It's appreciated.

Jeremy Davis's picture

Did you do that?

It's pretty easy:

service apache2 restart

Don's picture

Restarted Apache many times in the process.

Jeremy Davis's picture

...but just in case... Sorry I couldn't be more helpful :(

Adrian Moya's picture

Are you accessing your site with the site2 url? You need to write your client's host file to point to the appliance id and access with the ServerName url in order to get to the second site. 

You could also check if there's a .htaccess file rewriting url's to the first site, and last, check the DB of joomla which probably will need to update a value with the site's url (at least wordpress needs this). 

Just some ideas reading quickly your post.

Don's picture

Adrain,

Thank you. I think I've got it working.

This is what I had in place ...

<VirtualHost *:80>
    ServerName  site2
    UseCanonicalName Off
    ServerAdmin  webmaster@localhost
    DocumentRoot /var/www/site2/
</VirtualHost>

I changed it to this ...
<VirtualHost *:80>
    ServerName  site2.domainname.tld
    UseCanonicalName Off
    ServerAdmin  webmaster@localhost
    DocumentRoot /var/www/site2/
</VirtualHost>

And now it works.

Thank you all.

Add new comment