12

For previous versions of Laravel, you can simply download laravel with composer in the root folder of your apache server and type in http://localhost/public/ to see the "You've arrived" homepage.

I know I can use php artisan serve to view the Laravel5 default home page, but it is run on localhost:8000 and I heard that php artisan serve command should not be used in production due to the limit of connection and the bad performance. Is there a way I can see the default home page without using the php artisan serve command?

And it is really frustrating that Laravel is not including such simple thing in their installation documentation....

Constant
  • 574
  • 1
  • 5
  • 22
cytsunny
  • 4,838
  • 15
  • 62
  • 129

3 Answers3

19

To run the service on another port you need to pass the port parameter with port numberusing this code on the cmd:

php artisan serve --port=80

To run on port 80, you might need administrator permission.

Constant
  • 574
  • 1
  • 5
  • 22
mininoz
  • 5,908
  • 4
  • 23
  • 23
5

You may have to use sudo command for admin rights.

sudo php artisan serve --port=80 
0

To use Laravel on port 80 in Windows, you can follow these steps:

  1. Set Up Virtual Host: To use Laravel on port 80, you can set up a virtual host in Apache. Here's how you can do it:

Open the Apache configuration file. The file is usually located at C:\xampp\apache\conf\httpd.conf if you are using XAMPP. If you are using a different setup, the location may vary. Look for the section in the configuration file. Uncomment the line #Include conf/extra/httpd-vhosts.conf by removing the # symbol at the beginning of the line. Save the changes and close the file. Configure Virtual Host: Now, you need to configure the virtual host for Laravel.

Open the virtual hosts configuration file. In XAMPP, it is usually located at C:\xampp\apache\conf\extra\httpd-vhosts.conf.

Add the following code to the file to create a virtual host for Laravel, assuming your Laravel project's directory is located at C:\xampp\htdocs\laravel-project:

<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/laravel-project/public/"
    ServerName laravel.local
    <Directory "C:/xampp/htdocs/laravel-project/public/">
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

This configuration sets the document root to the public directory of your Laravel project and assigns the ServerName as laravel.local. You can modify these values according to your project setup and preferences.

Save the changes and close the file.

  1. Edit the Hosts File: To access the Laravel project using a specific domain name, you need to edit the hosts file.

Open Notepad or any text editor with administrative privileges. Open the hosts file located at C:\Windows\System32\drivers\etc\hosts. Add the following line at the end of the file:

127.0.0.1 laravel.local

Save the changes and close the file. Restart Apache: Restart the Apache server to apply the changes you made in the configuration files.

  1. Access Laravel on Port 80: You should now be able to access your Laravel project by visiting http://laravel.local in your web browser. It will use port 80 by default.