WAMP Server takes another DocumentRoot than I prescribed - apache

I have WAMP Server installed, which works fine—normally.
I have changed some settings in httpd.conf, including the DocumentRoot directive. But when I start the server, and open localhost through a web browser, it gives a 403 Forbidden error. When I open the error log, I see the cause:
Warning: DocumentRoot [C:/Apache2/docs/dummy-host.example.com] does not exist
But wait... In the httpd.conf file, the DocumentRoot directive is properly set to A:/website/www/.
How is that possible?

Sounds like your editing the wrong DocumentRoot.
I use another WAMP (Wamp-Developer) but I'm guessing that your httpd.conf's DocumentRoot is the server's (non-VirtualHost) DocumentRoot.
You're looking to edit the website's (localhost's) VirtualHost block, which is either at the end of httpd.conf or in another file (that's included by httpd.conf).
Run Apache via the command line like this:
httpd -S
It will show you where the VirtualHost is.
You'll also need to make sure that your custom DocumentRoot has all the permissions set for access.
<Directory /xxxx>
order allow,deny
allow from all
...

Probably you've uncommented this line in httpd.conf:
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
httpd-vhosts.conf is the file where you can put your VirtualHost directives for having them separate from the rest, but it contains a sample VirtualHost (exactly your dummy-host.example) that is causing the error.
So you have to replace the sample host with your one(s).
But you can also comment the include line and write the VirtualHost directly in your httpd.conf.

It's important to read the error log properly:
Warning: DocumentRoot [C:/Apache2/docs/dummy-host.example.com] does not exist
So we have to find a directive in some file that is trying to define a virtual host. In my case (W7pro, WAMP) I found it in the following location:
C:\wamp\bin\apache\Apache2.2.21\conf\extra\httpd-vhosts.conf
Just edit the file and delete the corresponding virtual host directives.

try 127.0.0.1, if it works. go to C:\Windows\System32\drivers\etc and add (or uncomment) the following line:
127.0.0.1 localhost

For me it was MSSQL reporting service:
SQL Server Reporting Services (MSSQLSERVER)
disabled it and it works.

Related

Laravel Access forbidden on localhost xampp

I just got stuck in the very begining. I have installed laravel and when i run php artisan serv command then this(Laravel development server started on http://localhost:8000/) line appears but when i access it through browser(http://localhost:8000/) then the following error gets displayed.
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.18 (Win32) OpenSSL/1.0.2e PHP/7.0.2
Please help me out. Any help would be greatly appreciated. I am beginner in laravel.
Follow the steps below to create a virtual host:
Change to your XAMPP installation directory (typically, C:\xampp) and open the " httpd-vhosts.conf " and " httpd-xampp.conf " files in the apache\conf\extra\ subdirectory using your favourite text editor.
Add these lines into both files with the following directives:
<VirtualHost *:80>
DocumentRoot "C:\Users\Shivam\Desktop\laravel_project\blog"
ServerName blog.dev
<Directory "C:\Users\Shivam\Desktop\laravel_project\blog">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Allow from all
Require all granted
</Directory>
</VirtualHost>
This contains two virtual host configuration blocks:
The first block is the default or fallback virtual host, which is used for all requests that are not matched by subsequent blocks.
The second block sets up a virtual host named wordpress.localhost. The DocumentRoot directive specifies the directory to be used when serving requests for this virtual host (in this case, the WordPress installation directory), while the ServerName directive specifies the custom domain name for the virtual host.
To add more virtual hosts, simply duplicate the second virtual host block and modify the port number, DocumentRoot and ServerName directives as per your requirements. For example, if you want to use SSL with your custom domain name, you can add a new virtual host block for port 443.
If you plan to have a large number of virtual hosts with very similar configuration, consider using wildcard-based subdomains with your virtual hosts.
Restart Apache using the XAMPP control panel for your changes to take effect.
At this point, your virtual host is configured. However, if you try browsing to the wordpress.localhost domain, your browser will show a failure notice, since this domain does not exist in reality. To resolve this, it is necessary to map the custom domain to the local IP address. To do this, open the file C:\windows\system32\drivers\etc\hosts and add the following line to it:
127.0.0.1 blog.dev
This takes care of mapping the wordpress.localhost domain name to the local machine, which always has the IP address 127.0.0.1
It seems to me that you already have Apache running on port 8000.
Try running the serve command like this:
php artisan serve --port=9000
After it's running navigate to http://localhost:9000

How to establish a virtual host properly using WampServer?

I have a problem in creating my virtual using WampServer. In the office I can create and run a virtualhost properly. But when I tries to create in my laptop. I t redirects to the localhost page of my wampserver. It displays the default page of wampserver. Here's what I did.
First I move my project in this directory: - C:\Users\jerielle0214\Documents\Chelle\hallohalloalliance
Second is I add the virtual host in apache (C:\wamp\bin\apache\apache2.2.22\conf\extra\httpd-vhosts.conf)
<VirtualHost *:80>
ServerName chelle.hallohalloalliance.com
ServerAlias chelle.hallohalloalliance.com
DocumentRoot "C:/Users/jerielle0214/Documents/Chelle/hallohalloalliance/"
<Directory "C:/Users/jerielle0214/Documents/Chelle/hallohalloalliance/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
And I include my virtualhost in the Windows hosts file. I add this in the bottom of the hosts file
127.0.0.1 chelle.hallohalloalliance.com
Last I restarted the wampserver and I access my page using chelle.hallohalloalliance.com but it only redirect my page to default wamp page. I don't know where's the error. Please help me guys thanks.
Apache will fallback to the first host it was correctly told about when there is a problem with your VHOST definitions.
Did you uncomment this line in the httpd.conf file so Apache includes your vhost definition?
#Include conf/extra/httpd-vhosts.conf
just remove the #.
Also when you change the hosts file you need to reboot or refresh the DNS Cache for the changes to be visible to windows. To refresh the cache do this from a command window ( run as Administrator )
net stop "DNS Client"
net start "DNS Client"

NameVirtualHost Works on IP but not for ServerName?

I am a beginner to Apache and have been trying to create virtual hosts but I come across a very odd issue. When the site is requested using the IP defined in the configuration, the virtual host works perfectly but when the name of the server is used it does not work.
Here is the configuration file which is an included file:
Listen 80
NameVirtualHost 192.168.1.5
<VirtualHost 192.168.1.5>
ServerName host1.localhost
DocumentRoot "C:/Program Files (x86)/Apache Group/Apache2/virtualHost1"
</VirtualHost>
In the browser I go to 192.168.1.5 and the index file for the Virtual Host appears but when I go to host1.localhost it doesn't work.
Any help is very appreciated, good day to all.
First you should try to see if your computer resolve host1.localhost hostname.
May be just try to ping it in your console: ping host1.localhost
If your computer is unable to resolve host1.localhost, as I suppose, then try to add it in your hosts file.
Hint: you'll find hosts file in C:\Windows\System32\drivers\etc directory
What do you mean by "it doesn't work".
1)Check your DNS settings, do you have record for host1.localhost pointing to 192.168.1.5?
2)Try using ServerAlias also
3)Check if there is another declaration for hosts1.localhost (by another ServerAlias)
I guess the most likely reason is 1)

XAMPP server document root for specific website

I just installed XAMPP, and I've found how to change the document root in the Apache config file, but I only want to change it for a specific site. The reason I need this is because all of my links are absolute links (i.e. /url not just url).
I tried changing it with .htaccess, but that gave me errors saying the limited recursion had been exceeded. So I went and changed that to 200, and it too a really long time, and then said that the recursion had been exceeded.
I would use aliases, but that would mean saying that any request to / goes somewhere else.
So is there anyway for me to specify that files inside of directory dir should have their document root as dir?
Thanks.
I found the solution, but it's a bit involved. You have to change the Apace config file, and the hosts file.
In the Apache config file, I added this:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "/absolute path/from/C/drive"
ServerName site.local
</VirtualHost>
Then I had to add this in the hosts file:
127.0.0.1 site.local
You can read up more on the virtual host here: http://httpd.apache.org/docs/2.2/vhosts/examples.html

Error starting apache from terminal after removing MAMP

I removed MAMP recently.
When I try to start apache from Terminal using:
sudo apachectl -k restart
I am getting the message
Warning: DocumentRoot [usr/docs/dummy-host.example.com] does not exist.
First, make sure you're actually trying to execute the proper version of apachectl by issuing the following command:
which apachectl
(You don't want to see any MAMP references there).
Next, find your virtual hosts config (which is likely here if your MAMP references are gone)
/etc/apache2/extra/httpd-vhosts.conf
Make sure your virtual host definitions are good. (Sounds like you're referencing a bad one).
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot "/Users/yourusername/Sites/mysite"
ServerName mysite.local
ErrorLog "/private/var/log/apache2/mysite-error_log"
CustomLog "/private/var/log/apache2/mysite-access_log" common
</VirtualHost>
(If you're using a custom server name other than 'localhost' like I've defined above, just be sure your /etc/hosts file is up to date with that entry like this:
127.0.0.1 mysite.local
Don't forget to restart apache!
sudo apachectl restart
You probably need to go to apache config file (something like etc/apache2/apache2.conf) and set it an existing document root directory. That is usually done with DocumentRoot directive in this file, or one of the included virtual host config definitions.
Make sure you comment out all the lines inside the /etc/apache2/extra/httpd-vhosts.conf file otherwise you will get the errors.