I have looked at many similar questions on SO such as this one and I can even solve my problem by making the changes in the global directory. However, I want to do the changes inside of the httpd-vhosts.conf file. Here is what I currently have:
<VirtualHost *:80>
ServerAdmin someEmail#gmail.com
DocumentRoot "c:/www/firstSite.dev"
<Directory "c:/www/firstSite.dev/">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order deny,allow
Allow from all
</Directory>
ServerName firstSite.dev
</VirtualHost>
However, I am still getting the error:
Forbidden
You don't have permission to access / on this server.
Any help would be appreciated.
You need to add your users explicitly in the httpd.conf file. The following line will do the trick
User daemon
Group daemon
User *user here*
If you happen to be on a linux distro that includes SELinux such as CentOS, you need to make sure SELinux permissions are set correctly for your document root files or you will get this error. On RedHat / CentOS / Scientific Linux this can be done by editing /etc/sysconfig/selinux - find the parameter "selinux" and change the option "enforcing" to "disabled":
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
Then reboot the server and test it out. If that solves it, you can either leave SELinux disabled, or configure SELinux so you can access your sites. Here is a good tutorial for configuring SELinux: http://beginlinux.com/server_training/web-server/976-apache-and-selinux
Related
Im trying to set up my local environment on my new mac OSX 10.9. I know it has apache already installed, so i've been using that. No matter how I set up my httpd-vhosts.conf/hosts/httpd.conf files, I continuously get a 403 forbidden error when visiting localhost OR "test.com" on my browser. The error / files / other information is listed below.
This is the error I'm getting when visiting either web page
Forbidden
You don't have permission to access / on this server.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
My /private/etc/hosts file
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
127.0.0.1 test.com
127.0.0.1 www.test.com
My /private/etc/apache2/httpd.conf file
This file is in its original form besides the following changes:
Uncommented Include /private/etc/apache2/extra/httpd-vhosts.conf
My /private/etc/apache2/extra/httpd-vhosts file
<VirtualHost *:80>
ServerName localhost
DocumentRoot /Library/WebServer/Documents/
</VirtualHost>
<VirtualHost *:80>
ServerName test.com
ServerAlias www.test.com
DocumentRoot "/Users/[my_name]/Sites/test"
<Directory "/Users/[my_name]/Sites/test">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Other notes
I've created a config file my user account in /private/etc/apache/users/
I've given that file read and write permissions to "everyone"
I've restarted apache after every save to any config file
I've reset the cache on my browser every time I make a change to these files
I have an index.html file set up in my /Users/[my_name]/Sites/test/ folder
When using the command sudo apachectl -t
Warning: DocumentRoot [/usr/\xe2\x80\x9c/Users/joshwoelfel/Sites/test\xe2\x80\x9d] does not exist
httpd: Could not reliably determine the server's fully qualified domain name, using Joshs-MacBook-Air.local for ServerName
Syntax OK
I don't know what to try at this point. I've spent several hours looking at tutorials and other questions people have posted. It looks like my files and permissions are correct!
I just resolved this issue. Try adding 'Require all granted' instead of 'Allow from all'.
<VirtualHost *:80>
ServerName test.com
ServerAlias www.test.com
DocumentRoot "/Users/[my_name]/Sites/test"
<Directory "/Users/[my_name]/Sites/test">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
when you set DocuemntRoot "/Users/xxx/xxx" on mac os, your must ensure your httpd User && Group have permission to read the directory.By default, /Users/xxx/xxx owner is root and group is admin, so you don't have the permission. If your directory group is wheel it maybe work.
Verify every directory in the path to your DocumentRoot, not just the DocumentRoot itself, is searchable (+x permissions) for Apache. Upgrading my Mac OS reset my home directory to 700 permissions. Changing this to 755 fixed the issue for me.
After the last upgrade to MacOS HighSierra 10.13.4 I had the same message. I've tried different solutions posted around but the what really tipped me was an article mentioning that when you get this message it's usually just a matter of permissions. So in the end I just needed to make sure that the group and the owner of both the document root, that I don't keep under my profile path, and the children directory are owned by the same user and group specified in httpd.conf, are set to my group and username. The default values in httpd.conf are: _www and wheel respectively. If you're unsure about your user name use
whoami
on a terminal window.
If you're interested in keeping your files under your profile directory this guide may help you.
I have just been trying to setup a local apache server on osx. Everything was going well until I enabled vhosts.
When I navigate to a site setup in vhosts (local.dev) all I get is a 403 forbidden error saying you do not have permission to access / on this server.
The route of the site in question is '/www/local/public/'. The folder path exists and running apachectl -S and the syntax of the vhosts file was correct.
I have looked at the permissions of the folder and have even tried setting everyone to read and write, but no luck. I have set my permissions on the folder to read/write as well as permissions for the _www group.
If you have any ideas on where I am going wrong that would be much appreciated!
I have looked for a few answers on here but not been able to find anything that has worked for me.
Looking at the default document root for apache, the only permission I have missing on the /www/ folder is for an account called 'system'. I am unable to add this system account to the permissions of the folder as it does not appear in the get info option on the folder.
Thanks,
Joe
As with all of my questions it seems, I have found an answer!
I managed to get everything working smoothly by adding the following to my /private/etc/apache2/extra/httpd-vhosts.conf file inside of the <VirtualHost *:80> that was setup for local.dev
<Directory "/www/local/public">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
So the overall vhosts config for local.dev would look like the following:
<VirtualHost *:80>
DocumentRoot "/www/local/public"
ServerName local.dev
<Directory "/www/local/public">
... Above code here ...
</Directory>
</VirtualHost>
I added this, then restarted apache, and everything worked smoothly.
I am posting this because I recently had a lot of trouble setting up a Virtual Host with a MAMP stack, due to Apple's throttling of the useable PHP version on Mac OS 10.8's default Apache2 installation.
This is a very quick guide on what to do and I owe the solution to this question on Stack Overflow:
Information Source
You can think of this as a compilation of what worked for me, as the accepted answers had no effect, but rather those with a significantly lower score.
Similarly, every guide I have seen fails to mention some points which users answered with on the sourced question.
Step 1: Install and configure Apache.
Make sure you specify what port you want to listen on, for me I specified 8080. This will be the case for this series of instructions.
Listen 8080 - Default is 80
Step 2: Edit your /etc/hosts file to spoof your loopback address, 127.0.0.1
127.0.0.1 localhost
127.0.0.1 some.example # domain-name.domain-TLD
127.0.0.1 www.some.example # The same as the above line, but with www. prefixed
You should really add a handle for subdomains on your web server, Apache or Nginx (or whatever else you use. Something that routes www to non-www.
Step 3: Enable the Virtual Hosts import on Apache.
Open your httpd.conf file located within Apache2's subdirectories. Usually within /conf
Uncomment the line that resembles this: Include conf/extra/httpd-vhosts.conf
Also uncomment this module import: LoadModule log_config_module modules/mod_log_config.so
Step 4: Configure your Virtual Hosts file
Find your Virtual Hosts config, httpd-vhosts.conf, you can comment out the two example Virtual Hosts in the file. Usually within /conf/extra
Copy your own Virtual Host into the file from this template:
<VirtualHost *:80> # Change the 80 to the number Apache2 "Listen"s on. In my case, 8080
ServerName SERVER-ADDRESS # E.g. mywebsite.local
ServerAlias WWW.SERVER-ADDRESS # E.g. www.mywebsite.local
DocumentRoot " SERVER-FILE-ROOT " # E.g. "Users/user-name/Sites"
<Directory /> # This should be a full path, though
Require all granted # Required for permission errors
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride none
</Directory>
</VirtualHost>
You're Done!
Once your Virtual Host has been edited to your liking you are done, just restart Apache and enjoy.
This guide already includes the fixes implemented, but in-case you still get permission errors:
You MUST make sure that your DocumentRoot is not inside any documents your user explicitly owns. If it needs to be, give "Read Only" access to "Everyone" on Mac for that particular folder, E.g. "Documents" or "Movies" etc....
Although the above answer is much explanatory, the following 2 things are most important when you are migrating virtual hosts to apache 2.4
Go to wamp/bin/apache/apache2.4.x/conf/httpd.conf find #Include conf/extra/httpd-vhosts.conf and uncomment to Include conf/extra/httpd-vhosts.conf
Add the virtual hosts in wamp/bin/apache/apache2.4.x/conf/extra/httpd-vhosts.conf as
<VirtualHost *:80>
ServerAdmin admin#localhost.com
DocumentRoot "H:/Wamp/www/mysite"
ServerName mysite
ServerAlias mysite
<Directory />
Require all granted
</Directory>
</VirtualHost>
Note: <Directory **/**> the / is important
So i have a public network VM set up with Vagrant and PuPHPet to get an apache web server up and running. I'm using Laravel as my framework of choice. I can access my site in my browser by visiting the following:
http://192.168.1.14/public/index.php/
Using PuPHPet i configured my vhost to use "phptest.dev" as the Server Name.
I'm a little stuck on how i should set a vhost to prettify my url. I'm not sure where the "phptest.dev" server name comes into play. I can't ping phptest.dev and get anything back.
What is the proper way to set this up? I'd like to visit "phptest.dev" in my browser to see my site. I think i need to add an .htaccess file to route all requests through the 'public/index.php` file so i can get that out of the url but i'm not sure.
Don't know PuPHPet but I can answer in a generic way.
You can use /etc/hosts file to do name resolution, as long as you haven't changed /etc/nsswitch.conf.
For example in /etc/hosts, add
192.168.1.14 phptest.dev
You should be able to ping the hostname from within the VM.
Suppose you are using Debian/Ubuntu, the sites configuration file is in /etc/apache2/sites-available/phptest.dev.conf
NOTE: don't forget to create a symbolic link in sites-enabled
<VirtualHost *:80>
ServerAdmin EMAIL
DocumentRoot /path/to/php
ServerName phptest.dev
ServerAlias www.phptest.dev
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /path/to/php>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/phptest.dev-error_log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/phptest.dev-access_log combined
</VirtualHost>
Do a service apache2 reload or restart and see if you can access by using phptest.dev
I can't respond directly to Terry Wang, but he's mostly right.
Ignore everything past his 4th line, though, because PuPHPet takes care of setting up the vhost in your VM for you.
You simply need to tell your local machine (your Mac or your Windows or maybe your Linux machine) that the domain phptest.dev is located at ip address 192.168.1.14.
That's why you need to edit your hosts file.
I'm running a XAMPP server on my laptop and I'm trying to setup a virtual host.
My hosts-file looks like this:
127.0.0.1 localhost
127.0.0.1 localhost.com
127.0.0.1 ehc.local
127.0.0.1 bal.local
The httpd-vhosts.conf file looks like this:
NameVirtualHost *:80
<VirtualHost ehc.local:80>
DocumentRoot "C:/wamp/EHC/src/main/php/www"
ServerName ehc.local
SetEnv APPLICATION_ENV "local"
<Directory "C:/wamp/EHC/src/main/php/www">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ErrorLog "logs/ehc.dev-error_log"
CustomLog "logs/ehc.dev-access_log" common
</VirtualHost>
When I browse to 'ehc.local', I only get the default 403-error page.
How can I fix this?
Thanks!
This is for osx but must be the same (or similar) in windows:
Because Apache runs as the ‘nobody’ user by default, it may not have adequate permission to browse your [OSX/Win] user directory or some of its subdirectories, in which case you’ll see a 403 ‘access forbidden’ error when you try and view your development site. Similarly, you may find that although you can view your dev site, PHP throws errors when you attempt to write files or make directories on the filesystem.
To fix this you can configure Apache to run as your [OSX/Win] user. Open httpd.conf and look for the following lines:
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User nobody
Group nogroup
Change User to your [OSX/Win] username, and save the file:
User yourusername
Restart Apache and you should now be able to navigate your site without any issues, including manipulating files and folders using PHP.
Source
I Hope it will be helpful, Greetings!
Changing user didn't work.
For me it was this answer that did the trick:
Adding VirtualHost fails: Access Forbidden Error 403 (XAMPP) (Windows 7)
Just add Require all granted to your <Directory> setup and it should work as expected.
you should try this:
-> go to XAMPP folder,
-> open apache-conf-extra folder
-> open httpd-xampp.conf with the text-editor of your choice
Scroll all the way down until you find Deny from all and change that too Allow from all