skip to Main Content

I currently new for deploying a project files to the godaddy hosting sites, so before i post this, I read some related question created already here in stackoverflow, I just confuse because there cpanel has public_html folder and my panel has no public html. so right now I experience

HTTP Error 404. The requested resource is not found.

The things only I do is to move the laravel files in the httpdocs.

My CPanel : Plesk Onyx 17.8.11

For the folder structure:

FTP Folder

So Inside of httpdocs are all of my laravel files

Laravel Files

Website shows like this..

Website Error

Hope someone help me for this problem.

2

Answers


  1. I think the reason your folder structure is like this is that your GoDaddy Hosting is a Windows Shared Hosting.

    What to basically need to do is create a folder for your app on the home directory and then on the httpdocs, put the public folder from your app.

    GoDaddy Plesk Folder List:

    • cgi-bin
    • error_docs
    • httpdocs
    • logs
    • <your laravel app folder minus the "Public" folder>

    Inside the httpdocs folder:

    • App_Data
    • .user.ini
    • Default.aspx
    • web.config
    • <+ contents of your Public folder>

    Once this is complete, you will need to edit a few files:

    From Public Folder: index.php

    Find:

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

    Change to:

    require __DIR__.'/../<laravel app folder>/vendor/autoload.php';
    

    Next Find:

    $app = require_once __DIR__.'/../bootstrap/app.php';
    

    Change to:

    $app = require_once __DIR__.'/../<laravel app folder>/bootstrap/app.php';
    

    After this, make sure the .env file is properly configured and all the tables from your local database is mirrored in you server database.

    Also, if you have open_dir problems, you can disable it on the PHP Settings from Plesk but I am not sure what are the issues this will cause in the long run.

    Login or Signup to reply.
  2. Well, there are two ways…

    1st in cpanel search for "Installatron Applications Installer" or somekind of app installer 🙂
    In installatron app installer screen on right top find "Applications Browser" from there search for Laravel and install it by choosing your domain(If you have more than one domain)

    After installation copy and replace your local files with the remote files.

    2nd second way, .zip your local laravel folder. And upload your files to your server, and then extract the files.

    NOW FROM HERE IT’S THE SAME FOR BOTH WAYS->

    1. "public" directory in laravel project will be in the root of your remote server(root folder for your domain, If you have addon domains for ex. public_html/example.com then "public" folder should be in that example.com)

    2. make another folder and put all other laravel files and folders in that folder.

    3. open and edit /public/index.php
      change these two lines->

      require DIR.’/../vendor/autoload.php’;
      app = require_once DIR.’/../bootstrap/app.php’;

    to reflect the file structure in your server.
    For ex. if "public" folder is in the same directory with "vendor" and "bootstrap" remove /..

    1. Edit your .env file pay attention to database credentials.
      PS: do not change database host address it should remain same.

    AND FINALLY the .htaccess files
    you need to have two .htaccess files
    one in "public" directory content like this->

    <IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>
    
    RewriteEngine On
    
    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    
    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]
    
    # Send Requests To Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
    

    Second .htaccess file will be in the root folder of the domain with content->

    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^public
    RewriteRule ^(.*)$ public/$1 [L]
    

    ONE PROBLEM YOU MIGHT COME ACCROSS if php version problem stating that composer dependencies version is php7.xx bla bla

    If this happens go to cpanel again and search for "Select PHP Version"
    From there change your current PHP version to suit with the PHP version you get in the error. And you need to click "Set as current"!

    That’s it 🙂

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search