Of course, the idea is always to protect the archives of public access. The most advisable thing is to have a dedicated user of the server that manages your web page. When you create the user, the server generates the following structure:
/home/miUsuarioNuevo/
Well, when you now deposit your project in that folder, the following structure remains:
/home/miUsuarioNuevo/composer.json
/home/miUsuarioNuevo/app/
/home/miUsuarioNuevo/public/
The next step is to create a VirtualHost in your httpd.conf
that points to your folder Public of the project:
<VirtualHost *:80>
DocumentRoot /home/miUsuarioNuevo/public
ServerName www.mi-sitio-en-laravel.org
# Other directives here
</VirtualHost>
Please note that apache will now serve your laravel website in /home/miUsuarioNuevo/public
, and the rest of your project is protected from public access.
The other solution is to keep your work environment on /var/www/html
as it is by default. In this case you would have to put your project in /var/www/
leaving the following structure:
/var/www/composer.json
/var/www/app/
/var/www/public/
Finally you edit the file httpd.conf
so that the public access changes from /var/www/html
to /var/www/public/
. In this way apache will only show the public content in that folder.
Note! Make a httpd.conf
backup before editing the file cp httpd.conf httpd.conf.bk
. So edit the file with complete freedom and testing.