XAMPP access forbidden issues - php

Having issues with XAMPP and access forbidden problems.
Started using laravel, complete noob to anything MVC but thought I'd give it a go.
Started having issues with page routing, index page works fine, yet non of my routes work, all come up with a 404 error.
Have a little search around the internet, find out it could be due to my xampp/Apache config.
Had a play with the
Allow from all
and
Require all granted
options, but no dice.
This is my vhosts entry:
<VirtualHost *:80>
DocumentRoot "C:\Users\xxx\Desktop\Projects\xxx\Website-3.0\Website\public"
ServerName gw3.dev
<Directory "C:\Users\xxx\Desktop\Projects\xxx\Website-3.0\Website\public">
Allow from all
Require all granted
Options Indexes
</Directory>
</VirtualHost>
and this is what I edited in the httpd.conf file.
<Directory />
Require all granted
Options FollowSymLinks
AllowOverride All
Allow from all
</Directory>
Made sure that the root directory is not read only.
Yet all I get are 403 - forbidden access errors.
Running Windows 10, fyi.
Not really sure where I'm going wrong here. Is there something I'm missing?

This section
<Directory />
Require all granted
Options FollowSymLinks
AllowOverride All
Allow from all
</Directory>
Provides the basic security for the disk that Apache is installed on. Basic practice is deny access to everything and then allow access to only those directories that Apache should have access to. Also you are using Pache 2.2. and 2.4 syntax together, bad.
So change that back to :-
<Directory />
AllowOverride none
Require all denied
</Directory>
In the definition of the virtual host you are using both Apache 2.2 and 2.4 syntax. Thats not a good idea it can cause Apache to get confused. Also you are using the DOS back slash and that should be the unix forward slash.
So try this
<VirtualHost *:80>
DocumentRoot "C:/Users/xxx/Desktop/Projects/xxx/Website-3.0/Website/public"
ServerName gw3.dev
<Directory "C:/Users/xxx/Desktop/Projects/xxx/Website-3.0/Website/public">
AllowOverride All
Options Indexes FollowSymLinks
Require all granted
</Directory>
</VirtualHost>
If you dont actually intend to allow anybody in the universe to access this site then you can use
Require local
Or if you want to access the site from another device in your local network you could try
Require ip 192.168.1
Note use of only 3 of the 4 quartiles of the IPV4 ip address. This allows access from any ip in that subnet.
Also make sure that you have added gw3.dev to your HOSTS file for both IPV4 and IPV6 addresses
127.0.0.1 gw3.dev
::1 gw3.dev
Retart Apache and try that.

You need
AllowOverride All
too in vhost
also dont forget to reboot the server

Related

How to set port for php project?

My php project by default has port:80, I need to make it any port above 1024.
I have multiple files in my project, when I try to make something like
"myproject/item/1" it responds with error 404 even if I have this URI in my routes.
On the other hand, when I start project by typing php -S localhost:8050, and do like "myproject:8050/item/1" everything works perfectly. I use method from some dude in github to create php projects, by default it copies /etc/apache2/sites-available/000-default.conf, where default port is *80.
I need to make first example "myproject/item/1" working properly
P.S. I don't want to change 000-default file, because I don't want all my projects to be broken.
For HTTP, browser by default is sending request to port 80, if you want run your project under another port you always need to specify that in request URI.
You need to create new configuration in /etc/apache2/sites-available eg. myproject.conf which may look like this:
Listen 8050
NameVirtualHost *:8050
<VirtualHost *:8050>
ServerName myproject
ServerAlias www.myproject
DocumentRoot /var/www/myproject
<Directory /var/www/myproject>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
</VirtualHost>
save, and enable your vhost by typing a2ensite myproject.conf, reload or restart apache and that's it.
Another way is create an alias in default configuration:
Alias /myproject "/var/www/myproject/"
<Directory /var/www/myproject>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
That way, your project will be accessible by requesting like http://{your_server_addr}/myproject without specifying port.

Website outside the htdocs

I am configuring website outside the htdocs and I did all changes what are describe here Virtual Host.
But partially it done but routes are not working. Only Home page showing. rest of page showing Object not found!.
like
<VirtualHost *:81>
DocumentRoot "C:\DevlopmentApps\VirtualMarket"
ServerName sjb.localhost
<Directory C:\DevlopmentApps\VirtualMarket>
Options Indexes
AllowOverride none
Require all granted
</Directory>
Now
http://sjb.localhost:81/sjb is working
http://sjb.localhost:81/sjb/find/ not working
Now i figure out some thing that other should be aware with.
If want to configure outside the htdocs the need to do following steps in the follwong link
Virtual host
Here is some thing Deprecated. https://stackoverflow.com/questions/9110179/adding-virtualhost-fails-access-forbidden-error-403-xampp-windows-7?answertab=votes#tab-top
<Directory ..........>
# AllowOverride All # Deprecated
# Order Allow,Deny # Deprecated
# Allow from all # Deprecated
# --New way of doing it
Require all granted
</Directory>
Now one thing which fixed my issue is
Options All
AllowOverride All
Require all granted

vhost showing default wamp page

I am using wamp to build my web application. So I had one vhost at mydomain.com but now I have changed my domain to dev.mydomain.com . For this changes to reflect I have edited etc\hosts file's entry from 127.0.0.1 mydomain.comto 127.0.0.1 dev.mydomain.com and in apache configuration file httpd-vhosts.conf -
<VirtualHost *:80>
DocumentRoot "D:/Software/Installed/wamp/www/myapp/public"
ServerName dev.mydomain.com
<Directory "D:/Software/Installed/wamp/www/myapp">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require local
</Directory>
When I open url dev.mydomain.com, I see the default wamp config page.
I have gone through many tutorials to find out what mistakes have been done but could find none. It would be helpful if someone throws some light on that. Thanks.
Why is your Directory different than DocumentRoot ??
I think you need to match those and restart your wamp and you are good to go.
Also, you must have index file in directory to see domain running properly.

How to resolve the Wampserver error?

I just installed WAP 2.2 d, on my local machine. It runs on Wndows 7 Starter. The installation was done smoothly. Then when I hit the URL localhost/phpmyadmin it gave me a message
**Forbidden**
You don't have permission to access /phpmyadmin/on this server.
Then after doing some research on this issue I found one solution as to make the change in file wamp/alias/phpmyadmin.conf
The initial lines were
<Directory "c:/wamp/apps/phpmyadmin3.4.10.1/">
Options Indexes FollowSymLinks MultiViews
Order Deny, Allow
Deny from all
Allow from 127.0.0.1
</Directory>
I changed these line to following lines:
<Directory "c:/wamp/apps/phpmyadmin3.4.10.1/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Allow, Deny
Allow from all
</Directory>
Then the phpMyadmin started working properly at URL localhost/phpmyadmin
After that I copied my directory 'XYZ' containing small project of PHP. Hit the URL localhost/XYZ, then it was expected to run the index.php file from the folder XYZ but it's still giving me the error
**Forbidden**
You don't have permission to access /XYZ on this server.
Can you help me to resolve this issue and run the system properly. Except above change to wamp/alias/phpmyadmin.conf I've not done any change to any of configuration file. Thanks in advance.
You must allow access to your XYZ directory in Apache configuration file httpd.conf:
<Directory "c:/wamp/apps/XYZ">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Allow, Deny
Allow from all
</Directory>
The reason for this problem is most likely because W7 has IPV4 and IPV6 enabled.
Apache is happy to listen to both ranges of port numbers, and by default does.
A better more secure solution would be:
<Directory "c:/wamp/apps/phpmyadmin3.4.10.1/">
Options Indexes FollowSymLinks MultiViews
Require local
</Directory>
Require local is like saying Allow from 127.0.0.1 localhost ::1 i.e. both IP Address ranges alias's for this PC.
Also if you do as you did and Allow from all when you decide to show a friend what you have done and open you router so the world can see your new site, they will also be given access to phpMyAdmin making a hackers life really easy
Secondly, you do not make the change suggested by #user4035, instead edit the httpd.conf and look for this section
<Directory "d:/wamp/www/">
Where is says,
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Change it in the same way as above, to
Require local
For the same security reason as above. When the time comes to show the world your site you can add the
<Directory "c:/wamp/apps/XYZ">
Options Indexes FollowSymLinks MultiViews
Require all granted
</Directory>
To allow anybody to see just that website but nothing else.

Django/mod_wsgi and PHP as Virtual Hosts on same Apache Server using MAMP

UPDATE: My original question is below, but the code I posted with the question has been edited to the final working solution.
I am trying to run multiple sites on my MAMP development server. Some of the sites are wordpress sites that live in the htdocs in MAMP and some of the sites are django apps that live in a folder titled djangoprojects.
I have been trying to implement the solutions from these stack questions:
multiple django sites with apache & mod_wsgi
How do I run Django and PHP together on one Apache server?
but I have not been successful. I was able to run the django site on apache with the code you see in the first VirtualHost brackets (from the daemon process line onward) but then none of the php sites could be visited.
Help is greatly appreciated. I am new with this and I can't work out the errors.
Here is the code from my httpd.conf:
UPDATE: The code below works. Both the Django App and the PHP applications exist on the localhost server. The PHP related VirtualHost stuff was copied from further up in the MAMP httpd.conf file.
<VirtualHost *:80>
ServerName localhost:80
UseCanonicalName Off
DocumentRoot "/Applications/MAMP/htdocs"
<Directory />
Options Indexes FollowSymLinks
AllowOverride None
</Directory>
<Directory "/Applications/MAMP/htdocs">
Options All
AllowOverride All
Order allow,deny
Allow from all
</Directory>
WSGIDaemonProcess site1 display-name=%{GROUP}
WSGIProcessGroup site1
Alias /media/ /Users/sequoia/djangoprojects/dynamics/media/
<Directory /Users/sequoia/djangoprojects/dynamics/media>
Options ExecCGI
Order deny,allow
Allow from all
</Directory>
WSGIScriptAlias /dynamics /Users/sequoia/djangoprojects/dynamics/apache/django.wsgi
<Directory /Users/sequoia/djangoprojects/dynamics/apache>
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
A couple of problems to start with:
ServerName is mean to specify the host name not a URL path.
You should never set DocumentRoot to be where your Django site source code is.

Categories