Apache2 serving multiple sites on one IP - apache2

I have two domains that point to the same IP, which is an Ubuntu VPS with apache2. I need to server both domains out of apache. I've read the config manual at http://httpd.apache.org/docs/2.0/vhosts/examples.html#purename and added the following two files:
1) webikenconsultants
<VirtualHost *:80>
ServerName www.webikenconsultants.com
DocumentRoot /var/www/coming_soon
<Directory /var/www/coming_soon>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
2) webikentrading
<VirtualHost *:80>
ServerName www.webikentrading.net
#WSGIScriptAlias / /opt/webikentrading/current/src/webikentrading/django.wsgi
DocumentRoot /var/www
<Directory /var/www >
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
As you can see, webikentrading is a Django project, but for the time being, just to get things working, I am serving it as a static site, until I figure out what's going on. The problem is that when I visit either domain, only the coming_soon content shows up, what am I doing wrong??

I figured out the problem. The vhost entry points to www.webikentrading.net however, the browser was using webikentrading.net so i added a separate entry for just webikentrading.net and all is fine
EDIT:
This is quite old, but I have a new and improved way of doing this now and I hope it can help someone else.
Use the mod_wsgi daemon directive which allows you to add the python path of your choice. Example config is:
<VirtualHost *:80>
ServerName qa.webiken.net
....
WSGIDaemonProcess qa.webiken.net processes=2 threads=15 python-path=/usr/local/pythonenv/QA-WEBIKEN-1/lib/python2.5/site-packages display-name=%{GROUP}
WSGIProcessGroup qa.webiken.net
</VirtualHost>
<VirtualHost *:80>
ServerName staging.webiken.net
....
WSGIDaemonProcess staging.webiken.net processes=2 threads=15 python-path=/usr/local/pythonenv/staging-WEBIKEN-1/lib/python2.5/site-packages display-name=%{GROUP}
WSGIProcessGroup staging.webiken.net
</VirtualHost>

Related

Can't access index.php after modifying the 000-default.conf to suit dms setup

So I've been trying to install Seeddms. I just re-flashed the os on my current samba server and wanted to add this DMS to just make life easier. I've flowed the steps mentioned on this website (Install Guide for old Seeddms). I am aware that this is for the old version of Seeddms and have changed all the version related code.
Question is...
What haven't I done to allow access to the index.php page after modifying the 000-default.conf ?
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory />
Require all granted
</Directory>
Alias /seeddms “/home/www-data/seeddms50x/seeddms-5.0.8/“
<Directory "/home/www-data/seeddms50x/seeddms-5.0.8/">
DirectoryIndex index.php
AllowOverride All
Order deny,allow
Deny from all
Allow from all
</Directory>
</VirtualHost>
Located in -> "/etc/apache2/sites-enabled/"
I try and access the install page using the web address of
http://steve/seeddms/install
(**steve being the name of the samba server)
However, no luck.
Any Ideas ?

Get Apache VHost to load index.html instead of web directory

I'm having no luck finding this question answered so I'm asking this myself.
To get my VHost working, I followed this answer. My (working) "httpd-vhosts.conf" file looks like this
<VirtualHost *:80>
ServerAdmin jesuscc1993#gmail.com
DocumentRoot "Z:/Projects/Web/MetalTxus Site"
ServerName metaltxus.test
ServerAlias www.metaltxus.test
<Directory "Z:/Projects/Web/MetalTxus Site">
#Options FollowSymLinks
Options Indexes FollowSymLinks
AllowOverride All
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
As far as I know, I should change "Indexes" with "-Indexes" to make the web load "index.html" instead of the web directory.
However, when I did that, my WAMPServer wouldn't start. It would if I removed "FollowSymLinks" option but then all I got was a "403 - Forbidden" page ("you don't have permission to access "/" on this server").
As looking for a solution got me nowhere, I used this as my last resource.
I'm using latest WampServer version in Windows 8.1. I want to test an AngularJS application.
If you need any more information, go ahead and ask.
Try this :-
<VirtualHost *:80>
ServerAdmin jesuscc1993#gmail.com
DocumentRoot "Z:/Projects/Web/MetalTxus Site"
ServerName metaltxus.test
ServerAlias www.metaltxus.test
<Directory "Z:/Projects/Web/MetalTxus Site">
AllowOverride All
Options Indexes FollowSymLinks
Require all granted
</Directory>
</VirtualHost>
The Require all granted is Apache 2.4 syntax where you were using Apache 2.2 syntax when using
Order deny,allow
Allow from all
Now all you need to do is place a file called index.html or index.php in the "Z:/Projects/Web/MetalTxus Site" folder.
I would suggest removing the space in the folder name MetalTxus Site its not absolutely necessary but it removes another possible complexity.
Also if you dont actually mean to give access to the site to The Universe try using
Require local
And if you want to be able to access the site just from other PC's on your internal network use
Require local
Require ip 192.168.1
ADDITIONAL SUGGESTION:
Also check httpd.con has thi sline uncommented
LoadModule dir_module modules/mod_dir.so
An has this
<IfModule dir_module>
DirectoryIndex index.php index.php3 index.html index.htm
</IfModule>

Unable to point my site on Domain_Name or IP_Address

I have completed following apache2 confirmation
<VirtualHost *:80>
ServerName start.example.com
DocumentRoot /var/www/start.example.com/public/
<Directory "/var/www/start.example.com/public/" >
AllowOverride all
Allow from all
Options -MultiViews
RailsBaseURI /rails
RailsEnv production
RewriteEngine On
</Directory>
</VirtualHost>
I set file in /etc/apache2/site_availables/start.example.com.conf
same file set in site_enables
service start succesfully but it's not point to my domain name or ip address.
I don't getting what's wrong with this.
Please Help Me. Thanks In Advance.
In Document Root or Directory, you need to give the path of your project.
<VirtualHost *:80>
ServerName start.example.com
DocumentRoot /var/www/projectName/public/
<Directory "/var/www/projectName/public/" >
AllowOverride all
Allow from all
Options -MultiViews
RailsBaseURI /rails
RailsEnv production
RewriteEngine On
</Directory>
</VirtualHost>
After this, need to restart apache2 server.
sudo service apache2 restart
Now, last step go to hosts file
Ubuntu : /etc/hosts
Windows: C:\Windows\System32\Drivers\etc\hosts
Add, your host here
127.0.0.1 start.example.com
Now, Browse!
It will work.

Virtual Host don't redirect properly with CakePHP and MAMP

I'm developing a web with cakePHP (using MAMP as localhost) and I just configured a virtual hosts to the root of my project.
My /etc/hosts is
127.0.0.1 localhost
127.0.0.1 altair.loc
And my httpd.conf
NameVirtualHost *
<VirtualHost *>
DocumentRoot "/Volumes/Macintosh HD/Users/robotThree/www/"
ServerName localhost
</VirtualHost>
<VirtualHost *>
DocumentRoot "/Volumes/Macintosh HD/Users/robotThree/www/ALTAIR/altair/"
ServerName altair.loc
</VirtualHost>
With this I can access to my project typing http://altair.loc and all controllers and actions works perfectly (i.e. http://altair.loc/controller/action).
The problem is that all files accessed statically fails. For example http://altair.loc/css/main.css fails, but it works if I type http://altair.loc/ALTAIR/altair/css/main.css, as if the virtual host wasn't configured.
Do you know what could be happening?
Thank you in advance
Solved. In httpd.conf is necessary to check that Override is for all, it was an .htaccess and mod_rewrite issue:
<Directory />
Options Indexes FollowSymLinks
AllowOverride All
</Directory>

Virtual host document root doesn't work

I created an A record for my subdomain.example.com which points x.x.x.x.
So my subdomain points the x.x.x.x IP address.
Also I want my subdomain to point a sub-directory. So, on x.x.x.x, I added these lines to httpd.vhosts.conf. This machine runs on xampp.
<VirtualHost *:80>
DocumentRoot /opt/lampp/htdocs/subdomain
ServerName subdomain.example.com
<Directory /opt/lampp/htdocs/subdomain>
allow from all
Options +Indexes
</Directory>
</VirtualHost>
But subdomain.example.com points x.x.x.x not x.x.x.x/subdomain. I don't understand what I'm doing wrong?
http://httpd.apache.org/docs/2.1/sections.html#mergin
Due to the merging order, some of the directives may override others. I found that <location> directive didn't let my <virtualhost> work properly.

Resources