What is the way to set up a Laravel website on Hestia? The required configurations for this are not clear. For example, in Hestia Web TemplateNGINX there is a setting for “Laravel”. And whatever it does, it seems to conflict with the Hestia Custom document root. So, what is the way to set up a Laravel website on Hestia?
Certainly not!
Under the “Custom document root”, there is a field called Directory. In this field, enter the “public” and save.
Then, the domain html will be served from this “public” directory. All other data, files, directories will remain outside of this “public” directory, which is excepted on every Laravel installation by default.
This is OK. The laravel non-exposed files need to be in the directory above public. So those go in public_html, and the only exposed files are in the public dir.
If you tried to put the public files in /home/user/web/domain.com/public then the laravel files would need to be in /home/user/web/domain.com and then you’d run into problems with file permissions, backups etc. @Deepak has given you sound advice.
This can be achieved by creating softlinks to link Laravel directories outside the Document root and modifying the conf files everywhere, in particular by adding all those directories under the openbase_dir restriction to use these directories, for e.g. vendors, etc.
Such a system existed til php 5x. I have used these techniques before 8-12 years in VestaCP and also in HestiaCP.
The sum total of the above mentioned approach is exactly the same as having all the directories under the Document root and changing the web access to public folder.
Earlier, most of the Frameworks were not developed under this consideration that there should be one directory level in the hierarchy between the Document root and public folder. Hence, we needed to use these tricks and that works.
But at a later date, most of the Frameworks I have used earlier, like Silverlite, Code Ignitor, ProcessWire, Laravel, Joomla, Drupal, etc. were developed such that there is one intermidiatory level made available between the public folder and the document root.
You are asking a solution because you want to create an intermidiatory level of hierarchy of diretories and achieve protection. The solution I suggested is not my own but very widely acceptedf in the entire industry and is very well settled since more than a decade.
Thus, I did not tell you anything subjective or very special based on my competence or experience. I merely informed you how all the Laravel projects are installed world wide.
Thanks for the replies, but there is very very much easier way:
Set the Web TemplateNGINX to “default” not “Laravel”.
cd /home/username/web/domain.com/public_html
composer create-project --prefer-dist laravel/laravel hello-world
cd hello-world
chmod -R 775 storage bootstrap/cache
nano .env
APP_URL=http://your-domain.com
php artisan key:generate
In Hestia, set the Custom document root to: /home/username/web/domain.com/public_html/hello-world/public
You do not need to change the public_html folder name. Just move the content of public folder to public_html and keep all the other files and folders inside the private folder at /home/user/web/domain/private then edit public_html/index.php change the three paths to match the private folder path, basically add …/private/ to each one of the three
This does not match with:
APP_URL=http://your-domain.com
If your installation is below the root dir called “/hello-world”, then in .env, you need to have:
APP_URL=http://your-domain.com/hello-world
Otherwise it can also work through a .htaccess redirection too.
However, you do not need that and if you try what I have suggested, you will have a much decent installation, although both have the same result of having Laravel serving public assets below the domain Document root.
In the above example, and this is how all Laravel should be installed, you will have to MOVE all contents under /hello-world to the document root of this domain:
/…/domain.com/public_html/public
/…/domain.com/public_html/storage
/…/domain.com/public_html/routes
Only then the public index.php will be served from the “public” dir under the Dolcument root. If not, you will neet to have in HestiaCP under Document root:
/hello-world/public
Got it?
No APP_URL=http://your-domain.com should be fine
Do this method allready for the last year works fine
Just clone “Laravel” project in the public_html folder
Erroneously, and with hubris, too many people only want to make things more complicated than they are. The solution I provided is the simplest and best one.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.