Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Host Laravel project in web hosting

I want to host my laravel project in my web hosting.

In my web hosting, there is Public_html folder. Before Laravel, I could call my website by using default.php or index.php in Public_html folder. But in laravel framework, index.php is in the public folder.

How can I access Laravel/public/index.php from my Public_html?

like image 524
Kingston Avatar asked Aug 09 '16 08:08

Kingston


3 Answers

Is it a shared hosting you're using if yes then :

Put the content of public (L5) directly on public_html (be aware of don't overwrite the .htaccess file accidentally) then modify your index.php and your bootstrap.php and it will work just fine

like image 82
Nour Avatar answered Oct 10 '22 22:10

Nour


2 Options:

  1. create index.php in Public_html which includes your original index.php
  2. if possible change the document root in your .htaccess or in your virtual host config

Either way you should be aware of the fact, that everything in your Public_html will be visible to every user. So putting your business logic there is not a good idea. Hidden files can be set with .htaccess or if you place them outside of your document root. If you have no possibility to change it you should probably think about a virtual server.

like image 42
oshell Avatar answered Oct 10 '22 22:10

oshell


When I do a fresh installation of Laravel project on my localhost, I cut the .htaccess file from a public directory and paste(replace) it in the root of Laravel directory.

And I rename the server.php file in the root of Laravel directory to index.php

This way I eliminate the need for entering public word from the website URL.

Now in public_html, I paste the all files and folders from Laravel directory. This way when you type in your domain name then your website is loaded directly without showing your public/index.php inside the URL.

like image 43
Vishal Shetty Avatar answered Oct 10 '22 22:10

Vishal Shetty