ioanandrei's avatar

Upload a Laravel 5.7 project on webserver Cpanel

I just uploaded my laravel 5.7 project on a webserver that uses cpanel.

I put my project in a directory called "www.mydomain.ro" and the public directory in public_html directory.

Doing like this, the project worked(i had errors, but they were laravel errors).

After that, i moved the public content of the laravel project from public_html in public_html/some_dir_name.

This way, i get this error:

403 Forbidden You don't have permission to access / on this server. Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

I don't really understand how this should work.What do i need to do to make it work?

Edit: In Site Publisher area, i see this:

mydomain.ro(main domain)

Website Directory: /home/username/public_html

Do i need to edit something here?

0 likes
10 replies
ioanandrei's avatar

Thank you! I'' watch it. One more thing...If i want to put a laravel project to a subdomain, i still need to place the public folder in public_html, right?

tisuchi's avatar

@ioanandrei

I believe for the subdomain, you need to put public folder contents are into subdomain folder. I haven't tested it yet, but literally, it should work.

4 likes
ioanandrei's avatar

@jlrdw @tisuchi i did what the tutorial says, but the error is the same :/

maybe i need to clear the cache? if yes, well...i have a problem with that, beacuse i can't enter in SSH Access(i emailed to my hosting support team to help me with that)

ioanandrei's avatar

Sorry guys for making so much spam

After some more research, i found that the htaccess was not good, so i modified it and now, when i go to www.mydomain.ro i need to select the directory from public_html.

To understand, my structure is like this:

Root/my-website-directory(here i have the laravel app without public dir)

Root/public_html/some-dir-name(here i have the laravel public dir content)

My .htaccess from Root/public_html is this:

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

RewriteEngine On

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$public / [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

When i go to www.mydomain.ro i get an index of public_html directory where i can find the some-dir-name directory.

Edit:

My index.php is this:

require __DIR__.'/../../my-website-directory/vendor/autoload.php';

/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/

$app = require_once __DIR__.'/../../my-website-directory/bootstrap/app.php';
jlrdw's avatar

Use the htaccess file that came with laravel but below this line:

RewriteEngine On

add this line

RewriteBase /your_folder/

Change your_folder to what's needed.

The youtube video is basically the same instructions as the guide I gave link to.

You have to resolve the paths correctly in index.php with correct number of:

../

like

require __DIR__.'/../../laravel57up/vendor/autoload.php';

I have never had a problem with the guide.

1 like
ioanandrei's avatar

Another stupid question....Again, sorry for this problems

Where should i put the .htaccess file? In public_html directory or in public_html/laravel54?

Please or to participate in this conversation.