Pietro Coelho
Pietro Coelho

Reputation: 2072

How to make artisan serve work in virtual host?

I'm on Windows 8 and I'm using WAMP to run my laravel project. I have configured apache and I created a virtual host, to access my app through http://myapp.dev.

I would like to know if it's possible to use the built-in php server (to run the laravel aplication through artisan serve) to point to my virtualhost instead of http://localhost:8000.

I tried to change the app url in app.php but it didn't work.

Upvotes: 1

Views: 6871

Answers (2)

Jeremy Park
Jeremy Park

Reputation: 41

  1. You need change the hosts file (ubuntu => /etc/hosts, windows => $WINDIR/System32/drivers/etc/hosts).

    127.0.0.1 myapp.dev

  2. .env file also needs changing:

    APP_URL=tttp://myapp.dev:8000

  3. $ php artisan serve --host=myapp.dev

Upvotes: 3

ceejayoz
ceejayoz

Reputation: 179994

Point myapp.dev to 127.0.0.1 in your hosts file, and do php artisan serve --host 0.0.0.0 --port 80.

In Linux/OSX, this requires sudo privilege, I'm not sure what Windows will require. You'd want to stop Apache too, as it uses port 80 and will cause a conflict if both are trying to run on that port.

Upvotes: 10

Related Questions