Prevent Laravel from showing the directory structure and instead show your application when using Apache.
/public directory.
Once you have downloaded/composer installed the Laravel project or app into /var/www/html
Navigate to the Apache virtual hosts configuration directory
cd /etc/apache2/sites-available
Create a new Apache virtual hosts file
sudo nano the_project.conf
Add (and edit) in the following and save it
<VirtualHost *:80>
ServerName domain.com
ServerAdmin webmaster@domain.com
DocumentRoot /var/www/html/public
<Directory /var/www/html>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost> Disable the default virtual hosts configuration file for Apache2
sudo a2dissite 000-default.conf
Now enable the one created above with
sudo a2ensite the_project
Enable the Apache rewrite module
sudo a2enmod rewrite
Restart Apache
sudo systemctl restart apache2
When you navigate to the domain or IP address instead of the Laravel files and folders showing it will be the app homepage.
A drained and empty Kennington reservoir images from a drone in early July 2024. The…
Merrimu Reservoir from drone. Click images to view larger.
Using FTP and PHP to get an array of file details such as size and…
Creating and using Laravel form requests to create cleaner code, separation and reusability for your…
Improving the default Laravel login and register views in such a simple manner but making…
Laravel validation for checking if a field value exists in the database. The validation rule…