Have several projects in laravel on a server?

0

I am trying to upload my project in laravel to my vps server. I do not know how to manage several projects on the apache web server.

My directory structure is /var/www/html ... As I read in tutorials, it says that you have to leave the project before the folder that is public (in my case html) in this way was with /var/www/proyecto_laravel.. but I have no idea how show the public part, actually I'm a little lost.

What I do not want is to leave all my laravel project in the html folder, since the configuration files are exposed.

    
asked by Luis Alberto Aguilera Clarke 11.02.2016 в 16:39
source

2 answers

3

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.

    
answered by 11.02.2016 / 18:08
source
2

Greetings, an easier version to mount your laravel project on a server is doing it in the following way;

1) Place your laravel project outside the / html_public folder on the server that would be / home / your_project .

2) Cut or copy the contents of the / tuproyecto_laravel / public folder that contains the folder where your laravel project is and paste it into the / home folder / html_public or whatever it's called on your server.

3) Configure the index.php file that you have pasted inside the / home / html_public folder, as well as it can be seen in the following image, require DIR.'/../tu_proyecto/bootstrap/autoload.php'; where it says /tu_proyecto you just have to put the name of the folder of your project that you placed outside the public folder of the server, and in the next line you also have to configure it in the same way, that is, in the part where it says $app = require_once__DIR__.'/../tu_proyecto/bootstrap/app.php'; same again where it says / your_project you re-enter the name of the folder of your laravel application.

    
answered by 12.02.2016 в 05:21