I am trying to upload my project in laravel to my vps server. I don't know how to manage multiple projects on apache web server.
My directory structure is /var/www/html ...
According to what I read in the tutorials, it says that you have to leave the project before the folder that is public (in my case html) in this way it was left with /var/www/proyecto_laravel..
but I have no idea how to show the public part, in reality I am a little lost.
What I don't want is to leave my entire laravel project in the html folder as the configuration files are exposed.
Of course, the idea is always to protect the files from 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:
Well, now when you deposit your project inside that folder, the following structure remains:
The next step is to create a VirtualHost in your
httpd.conf
that points to your project's public folder:Notice how Apache will now serve your Laravel web page in
/home/miUsuarioNuevo/public
, and the rest of your project is protected from public access.The other solution is to keep your work environment
/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:Finally you edit the file
httpd.conf
so that public access changes from/var/www/html
to/var/www/public/
. This way Apache will only display the public content in that folder.Greetings, an easier version of mounting your laravel project on a server is to do it in the following way;
1) You place your Laravel project outside the /html_public folder of the server which would be /home/your_project .
2) Cut or copy the contents of the /yourproject_laravel/public folder that contains the folder where your laravel project is and paste it into the /home/html_public folder or whatever it is called on your server.
3) Configure the index.php file that you have pasted inside the /home/html_public folder , as can be seen in the following image, where it says you only have to put the name of the folder of your project that you placed outside the folder public of the server, and in the next line you also have to configure it in the same way, that is, in the done part it says the same again where it says /your_project you put the name of the folder of your laravel application again.
require DIR.'/../tu_proyecto/bootstrap/autoload.php';
/tu_proyecto
$app = require_once__DIR__.'/../tu_proyecto/bootstrap/app.php';