Adding a directory to Apache Server - apache

I have a Windows XP system running XAMPP/Apache. I already have files on an external hard drive that I would like to serve up without moving them to the same drive as the Apache installation.
Here is what I've tried so far:
In the main HTTPD.conf file:
Alias /client_files D:/clients/files
<Directory D:/clients/files>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Allow,Deny
Allow from all
</Directory>
But the only result I got was :
Access forbidden!
You don't have permission to access the requested object. It is either read-protected or not readable by the server.
If you think this is a server error, please contact the webmaster.
Error 403
localhost
Apache/2.4.7 (Win32) OpenSSL/1.0.1e PHP/5.5.6
I also tried adding to the HTTPD-VHOSTS.conf file:
ServerName client_files
ServerAlias client_files
DocumentRoot "D:/clients/files"
And also:
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot "D:/clients/files"
ServerName client_files
ServerAlias client_files
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
But neither of these worked either. How in the world can I add another directory to an Apache installation and have it accesible via something like "localhost/client_files"?
Any suggestions?
UPDATE: [SOLVED]
As per #Pedro Nunes's answer below, I now have my httpd.conf file with this section at the end of the file and which includes the line "Require all granted" which Pedro answered with and which now solves the issue:
Alias /client_files D:/clients/files
<Directory D:/clients/files>
Require all granted
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Allow,Deny
Allow from all
</Directory>

Have you tried Require all granted inside the directory section?
This will grant access to all requests.

This guide explains exactly how I have it setup on my windows xampp machine. http://www.delanomaloney.com/2013/07/10/how-to-set-up-virtual-hosts-using-xampp/
remember to give an absolute documentroot path as well as adding the 127.0.0.1 servername line to hosts in C:/Windows/System32/drivers/etc/hosts

Related

PHP virtualhost's settings issue

I have a functional virtualhost set us
Listen 1234
<VirtualHost *:1234>
DocumentRoot "/Users/localuser/sites/testphp"
ServerName localhost
ErrorLog "/private/var/log/apache2/testphp-error_log"
CustomLog "/private/var/log/apache2/testphp-access_log" common
</VirtualHost>
<Directory "/Users/localuser/sites/">
AllowOverride All
Options Indexes MultiViews FollowSymLinks
Require all granted
</Directory>
PHP page is accessible by url localhost:1234.
Now I need to add another project, but I want to put it to different folder instead sites.
So I add another virtualhost settings as
Listen 1235
<VirtualHost *:1235>
DocumentRoot "/Users/localuser/Desktop/PE_RS/Projekty/php/hello-slim/public"
ServerName localhost
ErrorLog "/private/var/log/apache2/hello-slim-error_log"
CustomLog "/private/var/log/apache2/hello-slim-access_log" common
</VirtualHost>
<Directory "/Users/localuser/Desktop/PE_RS/Projekty/php/">
AllowOverride All
Options Indexes MultiViews FollowSymLinks
Require all granted
</Directory>
But in this case I'm getting for localhost:1235
Forbidden
You don't have permission to access / on this server.
I don't know if it does matter, but I have set in httpd-userdir.conf UserDir sites.
Thank you for any help.
In general, settings are all right. The issue is related to the folder/file permissions. I think that it was wrong to have PHP projects folder on Desktop. After move it into ~ and fix permissions by command sudo chmod -R 777 php (what is essential of this solution) all works!
Inspiration came from
askubuntu.com...

HTTP ERROR 500?

I'm trying to set up my project on xampp.
<VirtualHost *:80>
ServerAdmin test#test.biz
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/test/public"
ServerName testproject.dev
ErrorLog "logs/dummy-host2.example.com-error_log"
CustomLog "logs/dummy-host2.example.com-access_log" common
<Directory "/Applications/XAMPP/xamppfiles/htdocs/test/public">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
I uncomment line in httpd.conf for virtual hosts, but stil im getting error 500. Any suggestion? I m using MAC OS.
Also in hosts i added:
127.0.0.1 testproject.dev
Any suggestion?
It's impossible to help you without checking the log. You should enable Apache HTTP Server's logging and check the events. I guess that the log in your case is dummy-host2.example.com-error_log. Look through the events and find out what's wrong with this configuration.

Virtual host not displaying correct files

Centos 7.1 and apache 2.4 - We have installed a new drive in our server and want to move all of our sites to that drive (mounted as /data) and sites are located in /data/vhosts
When trying to access the site we are presented with the apache welcome screen. I can confirm that the vhost is loaded as trying changing the permissions of the dir above results in a forbidden access. There is also an index.php file located in /data/vhosts/test.mydomain.com/public_html
# IP has been changed for example:
<VirtualHost 91.91.91.91:80>
DocumentRoot "/data/vhosts/test.mydomain.com/public_html"
ServerName test.mydomain.com
<Directory /data/vhosts/test.mydomain.com>
Options All
AllowOverride All
order allow,deny
allow from all
</Directory>
</VirtualHost>
UPDATE 1:
I have deleted the welcome.conf file in /etc/httpd/conf.d/ and I am not given a forbidden 403. It is important to note that this is a new drive and no permissions has been set on /data (or sub folders) for apache. I am not entirely sure if that makes a difference?
I have also made some slight alternations to the vhost conf file but no difference:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "/data/vhosts/test.mydomain.com/public_html"
ServerName test.mydomain.com
<Directory "/data/vhosts/test.mydomain.com">
AllowOverride None
# Allow open access:
Require all granted
</Directory>
<Directory /data/vhosts/test.mydomain.com/public_html>
Options Indexes FollowSymLinks Includes ExecCGI
DirectoryIndex index.php
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

Adding VirtualHost fails: Access Forbidden Error 403 (XAMPP) (Windows 7)

I've got a XAMPP installation running on Windows 7.
As soon as I add a VirtualHost to httpd-vhosts.conf, BOTH the 'regular' http://localhost AND the new dropbox.local aren't working.
This is what I added to my httpd-vhosts.conf:
<VirtualHost *:80>
ServerAdmin postmaster#dummy-host.localhost
DocumentRoot "E:/Documenten/Dropbox/Dropbox/dummy-htdocs"
ServerName dropbox.local
ServerAlias www.dropbox.local
ErrorLog "logs/dropbox.local-error.log"
CustomLog "logs/dropbox.local-access.log" combined
</VirtualHost>
So I looked up my dropbox.local-error.log for any information:
[Thu Feb 02 10:41:57 2012] [error] [client 127.0.0.1] client denied by server configuration: E:/Documenten/Dropbox/Dropbox/dummy-htdocs/
This error seems to be solved by adding
<directory "E:/Documenten/Dropbox/Dropbox/dummy-htdocs">
Allow from all
</directory>
But now I get this error in dropbox.local-error.log:
[Thu Feb 02 10:45:56 2012] [error] [client ::1] Directory index forbidden by Options directive: E:/Documenten/Dropbox/Dropbox/dummy-htdocs/
Furthermore when I try to access http://localhost, I dont get any error in the regular error.log, although I get the error 403 when I try to access it.
Can anybody help... It's driving me mad :S
EDIT:
Also in httpd.conf there is the following (I've seen it mentioned multiple times, so before anyone says it):
<IfModule dir_module>
DirectoryIndex index.php index.pl index.cgi index.asp index.shtml index.html index.htm \
default.php default.pl default.cgi default.asp default.shtml default.html default.htm \
home.php home.pl home.cgi home.asp home.shtml home.html home.htm
</IfModule>
Okay: This is what I did now and it's solved:
My httpd-vhosts.conf looks like this now:
<VirtualHost dropbox.local:80>
DocumentRoot "E:/Documenten/Dropbox/Dropbox/dummy-htdocs"
ServerName dropbox.local
ErrorLog "logs/dropbox.local-error.log"
CustomLog "logs/dropbox.local-access.log" combined
<Directory "E:/Documenten/Dropbox/Dropbox/dummy-htdocs">
# AllowOverride All # Deprecated
# Order Allow,Deny # Deprecated
# Allow from all # Deprecated
# --New way of doing it
Require all granted
</Directory>
</VirtualHost>
First, I saw that it's necessary to have set the <Directory xx:xx> options. So I put the <Directory > [..] </Directory>-part INSIDE the <VirtualHost > [..] </VirtualHost>.
After that, I added AllowOverride AuthConfig Indexes to the <Directory> options.
Now http://localhost also points to the dropbox-virtualhost. So I added dropbox.local to <VirtualHost *:80> which makes it as <VirtualHost dropbox.local:80>
FINALLY it works :D!
I'm a happy man! :) :)
I hope someone else can use this information.
For me worked when I changed "directory" content into this:
<Directory "*YourLocation*">
Options All
AllowOverride All
Require all granted
</Directory>
For me (also XAMPP on Windows 7), this is what worked:
<Directory "C:\projects\myfolder\htdocs">`
AllowOverride All
Require all granted
Options Indexes FollowSymLinks
</Directory>`
It is this line that would cause the 403:
Order allow,deny
I'm using XAMPP 1.6.7 on Windows 7. This article worked for me.
I added the following lines in the file httpd-vhosts.conf at C:/xampp/apache/conf/extra.
I had also uncommented the line # NameVirtualHost *:80
<VirtualHost mysite.dev:80>
DocumentRoot "C:/xampp/htdocs/mysite"
ServerName mysite.dev
ServerAlias mysite.dev
<Directory "C:/xampp/htdocs/mysite">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
After restarting the apache, it were still not working.
Then I had to follow the step 9 mentioned in the article by editing the file C:/Windows/System32/drivers/etc/hosts.
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
::1 localhost
127.0.0.1 mysite.dev
Then I got working http://mysite.dev
Thank you, that worked! But I replaced this
AllowOverride AuthConfig Indexes
with that
AllowOverride All
Otherwise, the .htaccess didn't work: I got problems with the RewriteEngine and the error message "RewriteEngine not allowed here".
Above suggestions didn't worked for me. I got it running on my windows, using inspiration from
http://butlerccwebdev.net/support/testingserver/vhosts-setup-win.html
For Http inside httpd-vhosts.conf
<Directory "D:/Projects">
AllowOverride All
Require all granted
</Directory>
##Letzgrow
<VirtualHost *:80>
DocumentRoot "D:/Projects/letzgrow"
ServerName letz.dev
ServerAlias letz.dev
</VirtualHost>
For using Https (Open SSL) inside httpd-ssl.conf
<Directory "D:/Projects">
AllowOverride All
Require all granted
</Directory>
##Letzgrow
<VirtualHost *:443>
DocumentRoot "D:/Projects/letzgrow"
ServerName letz.dev
ServerAlias letz.dev
</VirtualHost>
Hope it helps someone !!
After so many changes and tries and answers.
For
SOs: Windows 7 / Windows 10
Xampp Version: Xampp or Xampp portable 7.1.18 / 7.3.7 (control panel v3.2.4)
Installers: win32-7.1.18-0-VC14-installer / xampp-windows-x64-7.3.7-0-VC15-installer
Do not edit other files like httpd-xampp
Stop Apache
Open httpd-vhosts.conf located in **your_xampp_directory**\apache\conf\extra\ (your XAMPP directory might be by default: C:/xampp/htdocs)
Remove hash before the following line (aprox. line 20): NameVirtualHost *:80 (this might be optional)
Add the following virtual hosts at the end of the file, considering your directories paths:
##127.0.0.1
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
</VirtualHost>
##127.0.0.2
<VirtualHost *:80>
DocumentRoot "F:/myapp/htdocs/"
ServerName test1.localhost
ServerAlias www.test1.localhost
ErrorLog "logs/myapp-error.log"
CustomLog "logs/myapp-access.log" common
<Directory "F:/myapp/htdocs/">
#Options All # Deprecated
#AllowOverride All # Deprecated
Require all granted
</Directory>
</VirtualHost>
Edit (with admin access) your host file (located at Windows\System32\drivers\etc, but with the following tip, only one loopback ip for every domain:
127.0.0.1 localhost
127.0.0.2 test1.localhost
127.0.0.2 www.test1.localhost
For every instance, repeat the second block, the first one is the main block only for "default" purposes.
I am using xampp 1.7.3. Using inspiration from here: xampp 1.7.3 upgrade broken virtual hosts access forbidden
INSTEAD OF add <Directory> .. </Directory> in httpd-vhosts.conf, I add it in httpd.conf right after <Directory "D:/xampplite/cgi-bin"> .. </Directory>.
Here is what I add in httpd.conf:
<Directory "D:/CofeeShop">
AllowOverride All
Options All
Order allow,deny
Allow from all
</Directory>
And here is what I add in httpd-vhosts.conf
<VirtualHost *:8001>
ServerAdmin postmaster#dummy-host2.localhost
DocumentRoot "D:/CofeeShop"
ServerName localhost:8001
</VirtualHost>
I also add Listen 8001 in httpd.conf to complete my setting.
Hope it helps
For many it's a permission issue, but for me it turns out the error was brought about by a mistake in the form I was trying to submit. To be specific i had accidentally put a "greater than" sign after the value of "action". So I would suggest you take a second look at your code.

WAMP 403 Forbidden message on Windows 7

I have installed WAMP version 2.1 on my windows 7 machine. When i browse to localhost in my browser, the WAMP server page is visible.
But when I browse to my IP in my browser, I get the message
403 Forbidden: You don't have permission to access / on this server.
Any suggestions?
The access to your Apache server is forbidden from addresses other than 127.0.0.1 in httpd.conf (Apache's config file) :
<Directory "c:/wamp/www/">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
The same goes for your PHPMyAdmin access, the config file is phpmyadmin.conf :
<Directory "c:/wamp/apps/phpmyadmin3.4.5/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
You can set them to allow connections from all IP addresses like follows :
AllowOverride All
Order allow,deny
Allow from all
I found a simpler fix...
Although the icon was green WAMP still needs to be "Put Online" (last item of menu when left-clicking icon).
After that I had access as normal.
For me the inclusion of "Require local" helped to solve Error 403. The alias config file looks like this:
Alias /mytest/ "C:/mytest/"
<Directory "C:/mytest/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
Allow from all
Require local
</Directory>
The solution for changing the permissions in the httpd.conf will work if you are OK with providing access to the WAMP server from outside.
If you do not want to do that then all you have to do is tell windows that the "localhost" domain points to 127.0.0.1. You can do that by editing the hosts file in your system directory.
The file is placed at : C:\Windows\System32\drivers\etc\hosts
by default windows 7 ships with :
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
You have to un-comment the mapping for localhost:
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
# ::1 localhost
Note: you will not be able to edit the hosts file as its a read-only file. To edit, you have to be the administrator, copy the file to some other location, edit it and then copy it back to the etc directory.
I do not recommend the change of the hosts file. Use the permissions of httpd.conf file. use the hosts file approach only if you do not want the server accessed from outside.
Try adding the following lines of code to the file httpd-vhosts.conf:
<VirtualHost *:80>
ServerAdmin serveradmin#host.com
DocumentRoot "C:\wamp\www"
ServerName localhost
</VirtualHost>
Another thing I found out is that if your network adapter uses IPV6, it will not show as 127.0.0.1 but ::1
What I ended up doing is this:
<Directory "c:/wamp/www/">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from ::1
</Directory>
The same goes for your PHPMyAdmin access, the config file is phpmyadmin.conf :
<Directory "c:/wamp/apps/phpmyadmin3.4.5/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from ::1
</Directory>
For Wamp 3.1.3 and Apache 2.4 I simply had to change 1 line in my httpd-vhosts.conf file.
Open httpd-vhosts.conf
Change "Require local" to "Require all granted"
Restart all services
I was then able to get to my apache server from other computers.
Give credit to this video: https://www.youtube.com/watch?v=Sy_f6wBGnjI
if you have used localhost/phpmyadmin/
simply use
127.0.0.1/phpmyadmin/ for PHPMyAdmin
127.0.0.1/sqlbuddy/ for SQLBuddy
or if you have used localhost:8080/phpmyadmin/ then
127.0.0.1:8080/phpmyadmin/ for PHPMyAdmin
127.0.0.1:8080/sqlbuddy/ for SQLBuddy
Remember to remove dummy elements in httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot "c:/Apache24/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host2.example.com
DocumentRoot "c:/Apache24/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
For Apache version 2.4.x simply replace Require local with Require all granted in httpd.conf file inside <Directory "c:/wamp/www/"> tag then Restart all services
There could many causes to this problems
What I have experienced are:
1) 127.0.0.1 localhost entry was duplicated in hosts file
2) Apache mod_rewrite was not enabled
Regardless of the cause, backing up your www folder, vhost configuration file (and httpd configuration file) will help.
And such process takes a few minutes.
Good luck
I read & tried All Fixes But Not one worked. At last i Found that the Wamp Server Logo Is Green But Need to Be "PUT ONLINE".
So simple & a Quick Fix After Checking Your PHPMyAdmin.Cofg & HttPD.cofg Just Click on PUT ONLINE
I tried the configs above and only this worked for my WAMP Apache 2.4.2 config. For multiple root site without named domains in your Windows hosts file, use http://locahost:8080, http://localhost:8081, http://localhost:8082 and this configuration:
#ServerName localhost:80
ServerName localhost
Listen 8080
Listen 8081
Listen 8082
#.....
<VirtualHost *:8080>
DocumentRoot "c:\www"
ServerName localhost
<Directory "c:/www/">
Options Indexes FollowSymLinks
AllowOverride all
Require local
</Directory>
</VirtualHost>
<VirtualHost *:8081>
DocumentRoot "C:\www\directory abc\svn_abc\trunk\httpdocs"
ServerName localhost
<Directory "C:\www\directory abc\svn_abc\trunk\httpdocs">
Options Indexes FollowSymLinks
AllowOverride all
Require local
</Directory>
</VirtualHost>
#<VirtualHost *:8082></VirtualHost>.......
I faced this issue with wamp on windows 7. Adding following code to httpd-vhosts.conf solved the issue for me.
<VirtualHost *:80>
DocumentRoot "F:/wamp_server/www/"
ServerName localhost
</VirtualHost>
Thanks for your question.
I'am using wamp 3 now.
And I find an simple answer to do this under your question.
But that answer should change a little on wamp 3.
The steps are as following:
Right click wamp icon
Choose Wamp Setting
Click the Menu item:online/offline
Left click wamp icon
You will find there is a new item called "Put online"
It took me forever to figure this out.
C:\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhosts.conf
In this file you will notice several example virtual host files, that look like:
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot "c:/Apache24/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host2.example.com
DocumentRoot "c:/Apache24/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
Simply delete these entries and replace with:
<VirtualHost *:80>
ServerAdmin serveradmin#host.com
DocumentRoot "C:\wamp\www"
ServerName localhost
</VirtualHost>
You definitely need to make sure your other ducks are in a row but this for me with the solution that worked.
hi there are 2 solutions :
change the port 80 to 81 in the text file (httpd.conf)
and click 127.0.0.1:81
change setting the network
go to control panel--network and internet--network and sharing center
click-->local area connection
select-->propertis
check true in the -allow other .....
and --- allo other .....
I had this problem too. The route of my problem was I had made a mistake in my vhosts.conf file. If you are using vhosts this is another thing to check
This configuration in httpd.conf work fine for me.
<Directory "c:/wamp/www/">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 ::1
</Directory>
Make sure you aren't using a Windows' directory separator character (backslash) in your path names in your .conf file, even if you are on Windows. Apache doesn't understand them but will still start up and then output a 403 Forbidden Message.
wrong:
<Directory "c:\websites\my-website\">
right:
<Directory "c:/websites/my-website/">
Surprisingly, square brackets in DocumentRoot (and related, like <Directory>) paths can also cause error 403:
DocumentRoot "P:/TRY/web/fatfree/from_github/fatfree-master[bang]" failed with 403, while
DocumentRoot "P:/TRY/web/fatfree/from_github/fatfree-master" worked fine.
(I didn't bother figuring out the Apache path escaping, if any, just renamed the path instead. If anyone knows, comments are welcome.)
My solution was to disable encoding for encoded files (these files are green in windows). Ive got these files from MAC computer and it was encrypted by default.
Ive select these files > right click > properities > general tab > andvanced > uncheck encrypt files...
And voila it works.
I have tried all the stuff except clearing the mess in .htaccess file.
Go to www/ directory and make a copy of .htaccess file in another folder. Then clear all the lines in .htaccess original file.
And add this line,
RewriteEngine On
Then restart the server.
This has solved my problem and got access to all my localhost sites.
Hope it would solve yours too.
Also on Apache 2,4 you may need to add this to the directory directive in conf,
in case you decided to include httpd-vhosts.conf.
By default you can install wamp in C:\ but still choose to deploy your web development in another location.
To do this inside the vhosts.conf you can add this directive:
<Directory "e:/websites">
Options Indexes FollowSymLinks MultiViews
DirectoryIndex index.php
AllowOverride All
<IfDefine APACHE24>
Require local
</IfDefine>
<IfDefine !APACHE24>
Order Deny,Allow
Allow from all
Allow from localhost ::1 127.0.0.1
</IfDefine>
</Directory>
make sure that, the name of the file in the directory c:/wamp/apps/phpmyadmin3.1.3.1/, match the name (or version) in the phpMyAdmin.conf (Alias /phpmyadmin "c:/wamp/apps/phpmyadmin3.1.3.1/" )
I have found that if you are using ammps that for some reason its always forbidden when its in your root folder so i put it in the directory above my root folder and made a alias in the httpd.conf using this
Alias /phpmyadmin "C:/Program Files (x86)/Ampps/phpMyAdmin"
please note i am using ammps and i dont know for sure if it will work for others but its worth a try ;)