To use Laravel on port 80 in Windows, you can follow these steps:
- 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.
- 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.
- 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.