My Problem
I've tried many methods, I've researched a ton of questions on StackOverflow and none of them work! Some info:
I'm running Snow Leopard OS X (10.6.8)
I'm using XAMPP
Apache is loading the default (backup) directory. (See bottom of question for what I mean)
Attempt of solving
Here are the websites I've tried:
Adding VirtualHost fails: Access Forbidden Error 403 (XAMPP) (SO)
Xampp vhosts do not work (SO)
Apache Virtual Host is not working right (SO)
Apache VirtualHost not working (SO)
virtual host not working - Apache Web Server forum at WebmasterWorld
Additional Info
My VirtualHosts File:
<VirtualHost wrks.tk:80>
DocumentRoot "/Apps/XAMPP/htdocs/DNS"
ServerName wrks.tk
ErrorLog "/Logs/wrks.tk-error.log"
CustomLog "/Logs/wrks.tk-access.log" common
<Directory "/Apps/XAMPP/htdocs/DNS">
AllowOverride All
Order Allow,Deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
What it's actually loading (This is the defualt directory in the httpd.conf file, the "backup" directory):
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"
<Directory "/Applications/XAMPP/xamppfiles/htdocs">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/trunk/mod/core.html#options
# for more information.
#
#Options Indexes FollowSymLinks
# XAMPP
Options Indexes FollowSymLinks ExecCGI Includes
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
#AllowOverride None
# since XAMPP 1.4:
AllowOverride All
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
Couple of things I'd check are:
Making sure you include the httpd-vhosts.conf
# Virtual hosts
Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf
Set up hosts:
navigate to Macintosh HD/private/etc/hosts, in a text editor and click Open. Then add this line:
127.0.0.1 wrks.tk
And maybe try:
<VirtualHost *:80>
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/DNS"
ServerName wrks.tk
ErrorLog "/logs/wrks.tk-error_log"
CustomLog "/logs/wrks.tk-access_log" common
</VirtualHost>
You may also want to set up localhost again.
<VirtualHost *:80>
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"
ServerName localhost
</VirtualHost>
Sorry if some of these paths aren't accurate, you will need to check them against your xamp folder structure.
The simplest implementation I found is this:
http://iwearshorts.com/blog/adding-a-virtual-host-vhost-in-xampp-on-a-mac/
Related
I'm using Google VM instances on Google Cloud Platform for running my live server. I'm also using CodeIgniter to build of my server. It can load the default route when entering the page but when going to other routes, it shows Apache 404 error:
Not Found
The requested URL was not found on this server.
Apache/2.4.29 (Ubuntu) Server at 35.186.147.249 Port 80
My Apache config file at /etc/apache2/sites-available:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
<Directory /var/www/html>
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 All
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>
</VirtualHost>
I looked up online and most people say it is an Apache problem but I'm not too sure. I'll share any of the files in order to fix this issue.
The line DocumentRoot /var/www/html determinate the base of your files, I reviewed the IP that you put and i can see the next folder and access correctly:
j/
medical-survey/
temp/
Here is the link to understand more about DocumentRoot, so you can define where you require the default folder route for your web files. In case you require to have different links of your web development you can follow this link to configure the virtual hosts. Hope this is what you were looking for.
I am currently developing a SaaS web based project using PHP which requires users to have unique sub-domains to use the application.
I am done configuring the server with wildcards: Eg. user.example.com ==> *.example.com. The application creates a subfolder for the user under /var/www/html/ with the name of the user Eg. user.example.com would be in /var/www/html/user/.
I am stuck on getting the user's link without the base folder such as user.example.com to point to /var/www/html/user/ without having to include http://user.example.com/user.
I have tried virtual host and aliases but it seems like I have to manually assign the variable which is not applicable for the project.
I just need the subdomains to point to their respective subfolders.
My apache config file
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin admin#xxxxxxx.tdl
DocumentRoot /var/www/html/%1/
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
ErrorDocument 404 /error_404.html
</VirtualHost>
Finally after researching I got a solution. I realised that I had not activate the alias module and so I activated as follows:
sudo a2enmod vhost_alias
I also noted that serving each sub-domain to its respective sub-folder required a dynamic config script to auto-pick the VirtualDocumentRoot through Directory Name Interpolation as follows:
<VirtualHost *:80>
ServerAdmin admin#vspace.ke
DocumentRoot /var/www/html/
VirtualDocumentRoot /var/www/html/%1/
<Directory "/var/www/html/">
Options FollowSymLinks
Order allow,deny
Allow from all
AllowOverride All
</Directory>
</VirtualHost>
I also noted that you have to declare all sub-domains and non sub domain in the host configurations:
I.E
Alias for www
<VirtualHost *:80>
ServerName www.vspace.ke
ServerAlias www
DocumentRoot /var/www/html/
<Directory /var/www/html/>
Options +FollowSymLinks
</Directory>
</VirtualHost>
Alias for no sub-domain
<VirtualHost *:80>
ServerName vspace.ke
ServerAlias
DocumentRoot /var/www/html/
<Directory /var/www/html/>
Options +FollowSymLinks
</Directory>
</VirtualHost>
And * (wild card) sub-domain
<VirtualHost *:80>
ServerAdmin admin#vspace.ke
DocumentRoot /var/www/html/
VirtualDocumentRoot /var/www/html/%1/
<Directory "/var/www/html/">
Options FollowSymLinks
Order allow,deny
Allow from all
AllowOverride All
</Directory>
</VirtualHost>
Thank you so much for contributing.
Checked almost stackoverflow answers but getting same error, using windows server 2012 installed XAMPP( Apache/2.4.33 (Win32) OpenSSL/1.0.2o PHP/5.6.36 ).
xampp does not access any project from htdocs other than xampp dashboard.
Error :
httpd-vhost.conf :
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/mysite"
ServerName local.yourdomain.com
<Directory "C:/xampp/htdocs/mysite">
Require all granted
</Directory>
</VirtualHost>
hosts :
127.0.0.1 localhost
127.0.0.1 local.yourdomain.com
httpd.conf :
DocumentRoot "C:/xampp/htdocs/mysite"
<Directory "C:/xampp/htdocs/mysite">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks Includes ExecCGI
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
I have found that these 403 errors are (almost) always Apache configuration errors. Unfortunately there is not a lot of diagnostics in the logs for this.
Try this in your httpd-vhosts.conf file:
<VirtualHost *:80>
ServerName example.local
DocumentRoot "C:\Users\shipl\htdocs\example"
<Directory "C:\Users\shipl\htdocs\example">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Your hosts then would have:
127.0.0.1 localhost
127.0.0.1 example.local
Note that 'example.local' and '\htdocs\example' must be consistent in all the references.
Hope this helps.
When I try to change the web root path to any other folder it give me a 403 error (Forbidden), The default path is /Library/WebServer/Documents, but since this rather annoying for me, I changed it too /Users/Xero/WebServer
Permissions I got the permissions from /Library/WebServer/Documents by right clicking and selecting Get info (http://i.imgur.com/f21D7z0.png What it looks like)
So I changed it to be the exact same for /Users/Xero/WebServer. But it give me a 403 error still.
Attempt to fix
So, I looked it up on Google, and I tried these solutions to fix my problem:
http://www.cyberciti.biz/faq/apache-403-forbidden-error-and-solution/
Error message "Forbidden You don't have permission to access / on this server" (Stack Overflow)
But they didn't help.
Other Notes
Remember I'm using the preinstalled Apache on OS X Snow leopard. And, my virtual host isn't local, so it's not part or the hosts file issue (It's hosted off my DNS, and my IP as a backup, neither work)
My Virtual Hosts:
<VirtualHost *:80> ( Edited 2 )
DocumentRoot "/Users/Xero/WebServer"
</VirtualHost>
<VirtualHost *:80>
Options Indexes FollowSymLinks Includes ExecCGI
DocumentRoot "/Users/Xero/WebServer"
ServerName wrks.tk
ErrorLog "/Logs/Workarea/wrks-err"
CustomLog "/Logs/Workarea/wrks-acc" common
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml
<Directory "/Users/Xero/WebServer">
Options +Indexes FollowSymLinks +ExecCGI
AllowOverride AuthConfig FileInfo
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/Xero/WebServer"
ServerName 209.169.203.53
ErrorLog "/Logs/Workarea/ip"
CustomLog "/Logs/Workarea/ip-acc" common
<Directory "/Users/Xero/WebServer">
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Also, I have my httpd.conf User and Group setup like this:
User _www
Group _www
Responses to Answers
Edits
So, I fixed the path's to the document's, but it still giving me the same error, 403.
I checked my FireWall settings and it's off. I also checked my `Sharing Preferences`, `File Sharing` and `Web Sharing` are on.
I edited the duplicate of `DirectoryIndex Home.php Home.html` in the `wrks.tk` VirtualHost, but still, I'm getting the same error. (See Other Notes)
Added more too Other Notes.
Fixed directory, but still didn't fix problem.
Added another to Answer Responses.
Tried a computer restart, did not work.
I put a `index.html` in the folder, still got the same 403 error, I tried accessing `/index.html`, still, 403.
What file exactly are you getting all of this from?
<VirtualHost *:80> ( Edited 2 )
DocumentRoot "/Users/Xero/WebServer"
</VirtualHost>
<VirtualHost *:80>
Options Indexes FollowSymLinks Includes ExecCGI
DocumentRoot "/Users/Xero/WebServer"
ServerName wrks.tk
ErrorLog "/Logs/Workarea/wrks-err"
CustomLog "/Logs/Workarea/wrks-acc" common
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml
<Directory "/Users/Xero/WebServer">
Options +Indexes FollowSymLinks +ExecCGI
AllowOverride AuthConfig FileInfo
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/Xero/WebServer"
ServerName 209.169.203.53
ErrorLog "/Logs/Workarea/ip"
CustomLog "/Logs/Workarea/ip-acc" common
<Directory "/Users/Xero/WebServer">
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
There are more than one file for those settings. If you have apache, then take a look in the sites-enabled and sites-available folders.
Change the bottom part of your httpd.conf file to:
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Require all granted
Make a new file index.html and put the following in it:
<!DOCTYPE html>
<html>
<body>
<h1>It works!</h1>
<p>This is the default web page for this server.</p>
<p>The web server software is running but no content has been added, yet.</p>
</body>
</html>
Then place the index.html file into the empty directory.
create a file in /etc/apache2/users/ called yourusername.conf (yourusername being the account short name, e.g. hulu – it's usually the name of your home folder in /Users) with the following contents:
<Directory "/Users/yourusername/Sites/">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
I'm trying to setup apache virtual host on Mint linux. It kinda works, but some images are not available. For example http://test.local/icons/world.png returns 404 even if image exist. When I check log it says it's looking for image at /usr/share/apache2/icons/world.png even if I setup my DocumentRoot to /var/www/test.local/public_html
This is how I did this. copy /etc/apache2/sites-available/default to test.local and edit like this:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName test.local
DocumentRoot /var/www/test.local/public_html
<Directory /var/www/test.local/public_html/>
<Directory />
Options FollowSymLinks
AllowOverride All
</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
</VirtualHost>
Then I edit /etc/hosts and include 127.0.0.1 test.local in it. Run a2ensite test.local and restart apache.
What I try to do is map folder in my /var/www/test.local/public_html to http://test.local is there anything I'm missing, or easier way to do this.
Also to mention there is no .htaccess file in root directory of project, or in icons directory.
RESOLVED :)
This is 2nd time I'm answering my own questions here on SO. I actually was researching 2 days and found answer few hours after posting here.
Answer was that this is default Apache alias
Alias /icons/ "/usr/share/apache2/icons/"
Even if I couldn't find it in apache2.conf or in conf.d directory, it looks like it's there in /etc/apache2/mods-available/alias.conf under my Mint distribution (I guess all Debian distro will have similar path). All I needed to do is to comment out this alias and it works.