0

I need to access my Laravel app that is served with Apache (wampserver) from other computers in the same LAN.

OS: Windows 8.1
Wampserver version: 3.0.6
Apache version: 2.4.23

I can access my app from other computers by the following URL:

http://192.168.12.13/scms/public/

The following URLs also work:

http://192.168.12.13/scms/public/categories/create

But it does not work when I submit POST request from the above URL. It redirects to the following -

http://192.168.12.13/categories

And shows "Not Found". So, it does not work.

To solve the issue, I have setup virtual host for my app which works perfectly in my own computer. But I cannot access it from other computers.

My setup:

In file:

C:\wamp64\bin\apache\apache2.4.23\conf\httpd.conf

Added this line:

Listen 192.168.12.13:80

In file:

C:\wamp64\bin\apache\apache2.4.23\conf\extra\httpd-vhosts.conf

Full code:

# Virtual Hosts

# wamp
<VirtualHost *:80>
    DocumentRoot "C:\wamp64\www"
    ServerName localhost
</VirtualHost>

# scms
<VirtualHost *:80>
    DocumentRoot "C:\wamp64\www\scms\public"
    ServerName local.scms-ananta.com

    <Directory "C:\wamp64\www\scms\public">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride all
        Require all granted
    </Directory>
</VirtualHost>

In file:

C:\Windows\System32\drivers\etc\hosts

Added the following lines:

127.0.0.1 local.scms-ananta.com
192.168.12.13 local.scms-ananta.com

With the above setup, I can perfectly work with my app using the following URL in my own computer:

http://local.scms-ananta.com

But I cannot access it from other computers on my network.

Kindly note, serving with php artisan serve will not serve my purpose. I need to serve it with Apache.

Any help is highly appreciated.

Placid
  • 1,400
  • 3
  • 22
  • 33

1 Answers1

1

First of all editing host file will not help you while accessing from other computer unless you also edit all of those PC's host file. So it would be best to access with IP.

Now problem with your configuration is that for serving/deploying laravel website in your server you have to put public folder as your document root. Follwoing is your configuration for localhost

# wamp
<VirtualHost *:80>
    DocumentRoot "C:\wamp64\www"
    ServerName localhost
</VirtualHost>

Change the documentroot to the following will solve your problem.

DocumentRoot "C:\wamp64\www\scms\public"
reza
  • 1,507
  • 2
  • 12
  • 17
  • Hi reza, thank you so much for your guidance. It works !! But I have other apps in my localhost and naturally their links are broken when I link my scms app to localhost. Is it possible to link the ServerName to a sub directory? – Placid Mar 15 '17 at 07:26
  • 1
    When you change your documentroot for your server other apps that you put in your previous document root will not work. as you need to access laravel from other network, i would recommend to put laravel as your document root. . now to access your other apps, i would recommend to create a virtual host and configure your previous document root here. Then you will be able to access other apps. but remember virtual host will only work in your own computer. unless you edit all other pc's host file. – reza Mar 15 '17 at 07:32
  • Thanks buddy. Much appreciate. – Placid Mar 15 '17 at 07:50
  • another approach that i wouldn't recommend, is to copy all other apps to the laravel public folder. it will work fine. But to me, this is a bad approach. – reza Mar 15 '17 at 07:55