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
Related
I have a webserver with 2 domains (already attached to a folder), I want my global server configuration, which basically using "/var/www/html" as default document root, to have ANOTHER folder for ANOTHER user, based on just different port (I have read that it is possible in Apache site).
Follow is the cite from apache site:
Each Virtual Host must correspond to a different IP address, different port number, or a different host name for the server, in the former case the server machine must be configured to accept IP packets for multiple addresses. (If the machine does not have multiple network interfaces, then this can be accomplished with the ifconfig alias command -- if your OS supports it).
So my IP is XX.XX.XX.XX and server configuration has the line "listen 443" (I am running by default on https), I did the following:
listen 19758 https
<VirtualHost XX.XX.XX.XX:19785>
ServerName XX.XX.XX.XX:19785
DocumentRoot "/the/path/to/the/user/directory/public_html"
<Directory "/the/path/to/the/user/directory/public_html">
AllowOverride none
Options SymLinksIfOwnerMatch
Require all granted
</Directory>
<IfModule mpm_itk.c>
AssignUserID EFX EFX
</IfModule>
</VirtualHost>
I opened the port in the iptables, and made sure it is opened.
However: When I open the browser and typing "XX.XX.XX.XX:19785", it just timeouts without giving me the page (index.htm) that sits in the desired directory.
Note: This user has no associated domain, and will never has one.
The server is running with 2 other domains that have associated folders, I don't want to mix with them.
What I am doing wrong?
The main idea is to be able to enter from the browser to that directory as that user, and not as "nobody" (the default user of the server in the configuration file).
Thanks a lot for help.
I ve got a laravel app all set up and working when my virtual host is set as follows :
ServerName mylaravelproj.com
<Directory /var/www/mylaravelproj/public>
..rules here
So all i need to do is access mylaravelproj.com/api/whateverRouteHere
However, i wouldnt know how to access the api without a domain name as
DocumentRoot /var/www/mylaravelproj/public
<Directory /var/www/mylaravelproj/public>
..rules here
doesnt work when accessing 192.168.xxx.xxx/mylaravelproj/public/api/whateverRouteHere
Im quite new to configuring apache and a little confused as to why this doesnt work.
If your server is listening for the domain mylaravelproj.com, then why don't you add an entry to your hosts file like this:
192.168.xxx.xxx mylaravelproj.com
And then flush your DNS cache and then visit http://mylaravelproj.com and you should be able to access your app.
On windows, this is how I usually setup laravel apps. I use XAMPP, so I add the following entry to: C:\xampp\apache\conf\extra\httpd-vhosts.conf
<VirtualHost *:80>
ServerName mylaravelproj.com
DocumentRoot "C:/xampp/htdocs/mylaravelproj/public"
</VirtualHost>
and then get my LAN ip in windows using ipconfig /all in Command Prompt (say my LAN ip is 192.168.1.122) and then set it on the hosts file: C:\Windows\System32\drivers\etc\hosts
192.168.1.122 mylaravelproj.com
then in Command Prompt, flush the DNS Cache using ipconfig /flushdns
Note* it's not good idea to run your dev env using full domain, you should use something like mylaravelproj.dev or mylaravelproj.local
I have a virtual machine with Virtualbox in which I installed Ubuntu 14.04 and Apache. I am trying that only my host machine could access to this resource with Require directive.
I know that the connection between the virtual machine and the host machine it is correct because if I put on my host machine browser the url localhost:8080 I can see all the content of the root directory of Apache.
The problems comes when I try to use the directive Require on a directory inside the root directory. I only want that the host machine will have access to that resource so I add to the apache2.conf file these lines:
<Directory /var/www/example/>
Options Indexes FollowSymLinks
AllowOverride None
Require ip (Here the ipv4 of my host machine)
</Directory>
but I do not have access from my host machine to this resource.
What could be the problem?
Thanks in advance!
The VirtualBox NAT configuration you are using is causing the http request from your host machine to come into your virtual machine via an internal IP rather than the IP you are expecting. You'll need to update the Require directive to use this internal IP. To do this, check your Apache access logs to see the incoming IP when you access the resource. Use that IP in the require directive. You should see a line for each access request with the incoming IP & the resource accessed. You should see a line denying your access request when access is denied.
I am on Windows 8 and just now installed Wamp 2.5 (Apache 2.4.9) at C:/wamp to test my code locally. I have my source code repository at D:/workpace/project1 which I manage using GIT (GIT is one of the reasons I don't want to disturb its location).
After Installing Wamp, I just went on to enable virtual hosts by uncommenting the following line in httpd.conf.
#Include conf/extra/httpd-vhosts.conf
Then I headed to conf/extra/httpd-vhosts.conf created its backup and created the virtual host.
<VirtualHost *:80>
ServerAdmin admin#example.com
DocumentRoot "D:/workspace/project1/"
ServerName project1
ServerAlias p1
ErrorLog "logs/project1(local)-error.log"
CustomLog "logs/project1(local)-access.log" common
<Directory "D:/workspace/project1/">
Require all granted
</Directory>
</VirtualHost>
Also edited the hosts file and added the necessary lines.
127.0.0.1 project1
127.0.0.1 p1
The problem is that I get 403 Forbidden error not just when I access project1/ and p1/, but also when I access localhost/.
When I disable httpd-vhosts.conf in httpd.conf by commenting out,
Include conf/extra/httpd-vhosts.conf
I am able to access localhost/ but as expected, project1/ and p1/ too resolve to localhost/.
Surprisingly, when I re-enable httpd-vhosts.conf in httpd.conf and restore the backup of original(unchanged) httpd-vhosts.conf, I still get 403 (Forbidden) even on localhost/. But again when I disable httpd-vhosts.conf, localhost/ comes to normal.
It is furthermore surprising to note that If I change DocumentRoot to a dummy folder within c:/wamp/www, the story is the same. So this is not just happening when DocumentRoot is outside c:/wamp/www.
I feel that I have something extra to enable because there is no chance I have messed up anything as this is a fresh installation and I have made no changes except the ones above.
What may be the reason Apache is not getting along with virtual hosts?
There are a few things that you have not taken into account.
When you create Virtual Hosts Apache ignores the host defined in httpd.conf so you also need to create a Virtual Host for localhost. This explains why you cannot get to localhost when you have activated Virtual Hosts.
Apache is IPV4 and IPV6 aware, so when you create your domain names in the HOSTS file you need to do so for both the IPV4 and IPV6 stacks. So you would need to have a HOSTS file like this :-
#IPV4 Stack
127.0.0.1 localhost
127.0.0.1 project1
#IPV6 Stack
::1 localhost
::1 project1
The browser makes some arbitrary decision on whether to use the IPV4 stack or the IPV6 stack. Wish I understood why and for what reason it makes this decision better, but basically when you enter a domainname, the browser, or the networking stack, picks IPv4 or IPv6 for your first contact to a domain and then sticks to that decision, but it could use either.
Here is a post that should help you create Virtual Hosts
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.