Changing DocumentRoot in Apache2 on Mac Sierra - apache

I want to change the DocumentRoot for my Apache Server as I keep my files for Web Development in another location. The default Document Root is
DocumentRoot "/Library/WebServer/Documents"
I changed that to :
DocumentRoot "/Users/blah/Documents/project"
I also changed :
<Directory "/Library/WebServer/Documents">
#
# 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 FollowSymLinks Multiviews
MultiviewsMatch Any
#
# 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 None
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
to this:
<Directory "/Users/blah/Documents/project">
#
# 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 +ExecCGI
AddHandler cgi-script .cgi .py
MultiviewsMatch Any
Options Indexes FollowSymLinks MultiViews
Order allow,deny
Allow from all
#
# 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 None
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
However when i run localhost on my terminal I get the error:
Forbidden
You don't have permission to access / on this server.
I read through many previous posts regarding similar errors and saw that it was necessary to change permission of the folder. So I did that too. I can't seem to find out what is wrong. This is what comes up when I run ls -la in my project folder:
total 24
drwxrwxrwx 5 raveen staff 170 Oct 16 13:37 .
drwxr-xr-x 6 raveen staff 204 Oct 15 20:09 ..
-rwxrwxrwx# 1 raveen staff 438 Oct 16 15:17 index.cgi
-rwxrwxrwx 1 raveen staff 90 Oct 15 22:56 mongo1.php
-rwxrwxrwx# 1 raveen staff 372 Oct 16 13:37 mongo1.py

Related

Disable directory browsing apache isn't working

I want to disable directory browsing in WordPress. But it's not working.
Please help me. I've already edit htaccess (Options -Indexes)
This is folder httpd
<Directory "${INSTALL_DIR}/www/">
#
# 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 +Multiviews
#
# 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.
#
# onlineoffline tag - don't remove
Require all granted
</Directory>
<Directory ${INSTALL_DIR}/www/wp-includes>
Options -Indexes
AllowOverride None
Order allow,deny
</Directory>
There is some inconsistency in your config file. I'm thinking that
<Directory ${INSTALL_DIR}/www/wp-includes>
Should actually be
<Directory "${INSTALL_DIR}/www/wp-includes/">
Notice the missing " quotes and /
Also
AllowOverride all
should be
AllowOverride All
Notice the capital A on All
If that doesn't fix your problem let me know what version of Apache and is this Windows or Linux.

wamp64 error 403 access forbidden from another computer

i trying to reach my webpages out from may local network. but i got error message "forbidden You don't have permission to access /test/ on this server.
Apache/2.4.17 (Win64) PHP/5.6.16 Server at 192.168.1.139 Port 3388"
my httpd.conf:
<Directory "C:/wamp64/www/">
#
# 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
#
# 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.
#
# onlineoffline tag - don't remove
Require all granted
allow from all
</Directory>
what can i do, i am desperate :(
thanks for the help
Comment line:
# Require local
That's work for me

Changed Apache configurations, now localhost/~username/index.php throws 403 Error

I have been struggling to get laravel php framework up and running on my mac with yosemite. I have made changes to both the httpd.conf file in /etc/apache2 as well as my user config file username.conf. Now after changing it back I get a 403 "Forbidden You don't have permission to access /~username/my_phpinfo.php on this server." Also I should not that I am using Apache/2.4.9. This is the user conf file I currently have:
<Directory "/Users/<username>/Sites/">
AllowOverride All
Options Indexes FollowSymLinks
Require all granted
</Directory>
I also feel like possible errors could be in this section (line number~=238) of the httpd.conf file:
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/Library/WebServer/Documents"
<Directory "/Library/WebServer/Documents">
#
# 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 FollowSymLinks Multiviews
MultiviewsMatch Any
#
# 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
Order allow,deny
Allow from all
</Directory>

Forbidden: You don't have permission to access / on this server

I keep having this access denied error. I'm using apache 2.2.15 on CentOs 6.4.
The server is running with user apache and group apache.
In home, I have a user staging. I added him to the apache group.
Permissions on the docs folder are:
drwxrwx--- 2 staging staging 4096 Oct 4 14:33 docs
I'm testing with an index.html file:
-rw-r--r-- 1 staging staging 13 Oct 4 14:28 index.html
SELinux is disabled. The address I'm using is staging.mysite.com
My httpd.conf looks like this:
<Directory "/home/*/docs">
#
# 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.2/mod/core.html#options
# for more information.
#
Options FollowSymLinks
#
# 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 All
#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
</Directory>
I also have a virtual host set to my staging address:
<VirtualHost SERVERIP:80>
ServerName staging.mysite.com
DocumentRoot /home/staging/docs
ServerAdmin staging#mysite.com
CustomLog /home/staging/logs/access_log combined
</VirtualHost>
If you need more info let me know but any idea why it's giving me this error?
Well, as you stated it, the docs folder is only readable by the staging user and the staging group. So the apache user may not read it.
One solution would be to add the apache user to the staging group.
I can fixed the same error:
To Modify at your nagios configuration the options parameter +Indexes and add DirectoryIndex index.php
Maybe show be:
<Directory "/home/*/docs">
#
# 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.2/mod/core.html#options
# for more information.
#
Options FollowSymLinks +Indexes
DirectoryIndex index.php
#
# 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 All
#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
</Directory>
And, finally restart your apache service.
Check the permission /home/ can be +x and +r, like chmod +rx /home/.

Share localhost on LAN, WAMP

I have a simple PHP project just php and apache, and i want to share this project on my localnetwork, how i can figure this out?
I've try some solutions founded here but can't make it work.
Someone have any ideia?
I've already change my httpd.conf from apache folder to:
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
</Directory>
And changed:
Listen 80
to:
Listen 192.168.50.1:80
But don't work either.
Well change it all back.
This change allows access to the root directory of the drive you installed wamp onto. NOT A GOOD IDEA. S change it back to :
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
and also back to
Listen 80
Assuming you website is in c:\wamp\www and if your subnet is in fact 192.168.50 like you have used above the simple way to allow access to your site over the local network only is to change this part of httpd.conf
Look for
<Directory "c:/wamp/www/">
#
# 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.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# 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 all
#
# Controls who can get stuff from this server.
#
# onlineoffline tag - don't remove
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
And change this part of that section
# onlineoffline tag - don't remove
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 ::1 localhost
Allow from 192.168.50
the line Allow from 192.168.50 will allow access from any ip on that subnet i.e. 192.168.50.1 -> 192.168.255
If you put your site into a subfolder then do this:
<Directory "c:/wamp/www/">
#
# 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.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# 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 all
#
# Controls who can get stuff from this server.
#
# onlineoffline tag - don't remove
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 ::1 localhost
</Directory>
<Directory "c:\wamp\www\sitefolder">
Options Indexes FollowSymLinks
AllowOverride all
Allow from 192.168.50
</Directory>
This will keep your wampserver homepage secure but allow access to the site in sitefolder to everyone in the local network.