How to change vhosts entry when document root is now a few folders further down - vhosts

Im using Ubuntu in a VM. I have a script that creates Drupal sites and sets the appropriate vhosts entry. Below is an example:
<VirtualHost *:80>
ServerName d7.dev
ServerAlias *.d7.dev
DocumentRoot /home/drupalpro/websites/d7.dev
<Directory /home/drupalpro/websites/d7.dev>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName d7.dev
ServerAlias *.d7.dev
DocumentRoot /home/drupalpro/websites/d7.dev
<Directory /home/drupalpro/websites/d7.dev>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
SSLEngine on
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
</VirtualHost>
</IfModule>
Ive checked out a site to work on however the web root is now a few folders down. So instead of something like this:
/home/drupalpro/websites/d7.dev
Its now
/home/drupalpro/websites/d7.dev/folder1/site-root
What do I need to change from the original vhosts file? Is it DocumentRoot and Directory but not ServerName and ServerAlias?

From experimentation this appears to be correct:
<VirtualHost *:80>
ServerName d7.dev
ServerAlias *.d7.dev
DocumentRoot /home/drupalpro/websites/d7.dev/folder1/site-root
<Directory /home/drupalpro/websites/d7.dev/folder1/site-root>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName d7.dev
ServerAlias *.d7.dev
DocumentRoot /home/drupalpro/websites/d7.dev/folder1/site-root
<Directory /home/drupalpro/websites/d7.dev/folder1/site-root>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
SSLEngine on
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
</VirtualHost>
</IfModule>

Related

Can't acces phpmyadmin after creating WAMP vHost

Today I've created a virtual host in WAMP but after that I couldn't access localhost/phpmyadmin and localhost anymore I've also tried to make a vhost for that aswell but it didn't work.
The file httpd-vhosts.conf is included correctly.
EDIT: I can access pao.dev
httpd-vhosts.conf
<VirtualHost *:80>
ServerName pao.dev
DocumentRoot C:/wamp/www/pao/PAO-zwabbertje/public
<Directory C:/wamp/www/pao/PAO-zwabbertje/public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName phpmyadmin.dev
DocumentRoot c:/wamp/apps/phpmyadmin4.1.14/
<Directory "c:/wamp/apps/phpmyadmin4.1.14/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Allow from all
</Directory>
</VirtualHost>
pc hosts
127.0.0.1 localhost
127.0.0.1 pao.dev
127.0.0.1 phpmyadmin.dev
Error:
Forbidden
You don't have permission to access /phpmyadmin on this server.
Apache/2.4.9 (Win32) PHP/5.5.12 Server at localhost Port 80

2 Virtual Hosts on Mac

Hi to everyone I have two different sites and I want to two different host:
movie.local
music.local
These are my files:
#
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
127.0.0.1 movie.local
127.0.0.1 music.local
And
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
ServerName movie.local
ServerAlias www.movie.local
DocumentRoot "/Users/Me/Sites/movie"
ErrorLog "/private/var/log/apache2/site-error_log"
CustomLog "/private/var/log/apache2/site-access_log" common
ServerAdmin neilgee#coolestguidesontheplanet.com
<Directory "/Users/Me/Sites/movie">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName music.local
ServerAlias www.music.local
DocumentRoot "/Users/Me/Sites/music"
ErrorLog "/private/var/log/apache2/site-error_log"
CustomLog "/private/var/log/apache2/site-access_log" common
ServerAdmin neilgee#coolestguidesontheplanet.com
<Directory "/Users/Me/Sites/music">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
But now if I go to movie.local that's ok, but if i go to music.local my browser will load the content of movie.local, why?
if i go to music.local my browser will load the content of movie.local, why?
You can create a subdomain on your localhost like this.
First create a virtual host:
<VirtualHost *:80>
ServerName music.localhost
DocumentRoot "C:/Users/Me/Sites/music"
<Directory "C:/Users/Me/Sites/music">
/....../
/....../
</Directory>
</VirtualHost>
And in your hosts file add this line:
127.0.0.1 music.localhost

Creating sub domain on webmin

Can anybody help me in creating subdoain through webmin. I want to create subdomain like test.xxxxx.com for this I tried with several reference site but no luck.
exp.
http://www.trickylinux.net/add-domain-virtualminwebmin.html
http://codeboxlabs.com/add-subdomain-webmin-linux/
My current httpd.conf look like:
<VirtualHost *:80>
SSLEngine off
DocumentRoot /var/www/html/******/web
DirectoryIndex index.php
<Directory "/var/www/html/*****/web">
AllowOverride All
Allow from All
</Directory>
ServerName www.******.com
ServerAlias ftp.*****.com
SSLEngine off
SSLVerifyClient optional
</VirtualHost>
Please help me to solve this issue.
I know its been a year and you must have found a path already but its for the future reference.
Just add another host:
<VirtualHost *:80>
DocumentRoot /var/www/html/******/subdomain
DirectoryIndex index.php
<Directory "/var/www/html/*****/subdomain">
AllowOverride All
Allow from All
</Directory>
ServerName www.subdomain.******.com
ServerAlias subdomain.******.com
SSLEngine off
SSLVerifyClient optional
</VirtualHost>
Of course restarting apache is needed in order to make it read the new VHost
What you need to do next is add an A record in you domain registrar (i.e, Godaddy). Record name will be your "subdomain" and it'll point to your server address:
A-----------------> # --------------------> ******.com
A-----------------> ******.com------------> ******.com
A-----------------> subdomian.******.com--> ******.com

WAMP: 'No such host is known' when trying to connect to mysql

I got this error :
Warning: PDO::__construct() [<a href='pdo.--construct'>pdo.--construct</a>]: [2002] php_network_getaddresses: getaddrinfo failed: No such host is known. (trying to connect via tcp://1:3306) in Z:\work\...
My localhost/phpmyadmin works fine but I can't access localhost or 127.0.0.1 , I get a blank page with "Forbidden : You don't have permission to access / on this server."
I have nothing else running on my port 80
I modified my httpd.conf
DocumentRoot "z:/work/"
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
<Directory "z:/work/">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from all
</Directory>
Also added in my httpd-vhosts.conf
<Directory C:/Users/Alex/Documents/GitHub>
Order Deny,Allow
Allow from all
AllowOverride All
</Directory>
<Directory Z:/work>
Order Deny,Allow
Allow from all
AllowOverride All
</Directory>
<VirtualHost *:80>
DocumentRoot "Z:\work\mysite"
ServerName bullseye.local
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:\Users\Alex\Documents\GitHub\Myproject"
ServerName framework.local
</VirtualHost>
And my phpmyadmin.conf is as follow
Alias /phpmyadmin "c:/wamp/apps/phpmyadmin3.5.1/"
<Directory "c:/wamp/apps/phpmyadmin3.5.1/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Deny from all
Allow from all
</Directory>
The code giving the error :
$host = 'localhost';
$user = 'root';
$pass = '';
$database = 'mydatabase';
$this->db = new PDO('mysql:dbname=' . $database . ';host=' .$host . ';charset=utf8', $user, $pass);
I get the same error using mysql or msqli instead of PDO
My suggestion would be to:
Undo all your changes to httpd.conf. Your changes have removed all knowledge Apache has of the WAMP homepage i.e. localhost.
Comment out the include of the virtual hosts config and check you can again access the WAMP homepage.
Make sure that WAMP is 'OffLine', this will keep the C:\ drive and c:\wamp folder secure.
Now to your Virtual hosts definitions:
In order to keep the wamp homepage working the first entry should be as below, note the Directory block should be part of the definition of the VirtualHost and the security definition makes sure you can only access the wamp homepage from 127.0.0.1(localhost)
###must be first so the the wamp menu page loads
<VirtualHost *:80>
ServerAdmin webmaster#homemail.net
DocumentRoot "D:/wamp/www"
ServerName localhost
ServerAlias localhost
<Directory "D:/wamp/www">
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
</VirtualHost>
Each VHOST you define should contain its own security settings like this
<VirtualHost *:80>
DocumentRoot "Z:\work\mysite"
ServerName bullseye.local
ServerAlias bullseye.local
AllowOverride All
<Directory "Z:\work\mysite">
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:\Users\Alex\Documents\GitHub\Myproject"
ServerName framework.local
ServerAlias www.framework.local
<Directory "C:\Users\Alex\Documents\GitHub\Myproject">
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
Uncomment the Include in https.conf for your vhosts definitions and try accessing you other projects again.
I assume you have made the required changes to your c:\windows\system32\drivers\etc\hosts file to include a reference to all you virtual hosts? If not the hosts file should look like this :-
127.0.0.1 localhost
127.0.0.1 framework.local
127.0.0.1 bullseye.local
My concern is this:
DocumentRoot "z:/work/"
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
<Directory "z:/work/">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from all
</Directory>
Unfortunately I don't have time to test this before I suggest it... but if DocumentRoot is z:/work/ then Directory / is also z:/work/ and you have set that to deny all and override none. Later trying to change the permission with Directory "z:/work/" would be considered an override and therefore not be applied? I suggest you try changing the AllowOverride to all or removing the deny all from / before you spend too much time hunting down other possible solutions.

Server Side Includes

I got the following error message in the Apache log:
unable to include potential exec "header.html" in parsed file /Users/sikusiku/Sites/ss-git/homepage.shtml
I basically tried to include header.html from homepage.shtml. I used the very basic directive in homepage.html (both header.html and homepage.shtml are located in the document root):
<!--#include virtual="header.html" -->
I think I have properly turned on the SSI in my httpd.conf:
Options Indexes FollowSymLinks ExecCGI Includes
...
AddType text/html .shtml
...
# XBitHack doesn't have anything to do with this, but I added it anyway.
XBitHack on
Did I miss anything? Does the included file i.e. header.html need to be configured differently?
I just fixed this problem myself on ubuntu sever 11.10 with apache2.
my /etc/apache2/sites-available/default file:
<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 ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/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>
</VirtualHost>
I changed AllowOverride None to All in /var/www directory directive.
my .htaccess file in /var/www/.htaccess:
Options +Includes
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
finally i made sure that include.load was in the mods-enabled folder this is to load the mod_includes.so module.
sudo ln -s /etc/apache2/mods-available/include.load /etc/apache2/mods-enabled/include.load
That creates a symbolic link to the include.load in mods-available.
finally restart apache
sudo service apache2 restart
That made it work for me, hope you get it working as well.
--
Thomas