skip to Main Content

Before Laravel, I have been using the MVC Web Framework and success to host in cPanel server.

Now, I decide to upgrade my Framework. So I find Laravel because it also included MVC patterns and easy to learn for me. Seeing some tutorials, I decided to host a simple project of Laravel on a subdomain of my main domain sites.

What I did:

On server:

  1. I create a subdomain and set the document root to /public_html/subdomain.maindomain.com/public.
  2. Inside the public_html folder, I created a folder and renamed as just like to subdomain name.

On My Computer

composer global require laravel/installer
laravel new website
php artisan serve

Now, I get the Laravel homepage on browser link http://127.0.0.1:8000.
Then, I added bootstrap.

composer require laravel/ui
php artisan ui bootstrap --auth
npm install && npm run dev

Then, I see the login and register link on the Laravel homepage.

Now, seeing https://laravel.com/docs/8.x/deployment documentation of Laravel:

composer install --optimize-autoloader --no-dev
php artisan config:cache
php artisan route:cache
php artisan view:cache

Now, I uploaded the zip file (all files inside the website folder) and extracted it to server document root /public_html/subdomain_name/. In the subdomain_name folder, I have all the files that were in my website folder on my computer.

I don’t change anything on the index.php file of the public folder, remain on default condition.

require __DIR__.'/../vendor/autoload.php;
$app = require_once __DIR__.'/../bootstrap/app.php';

Then, I check my URL but I faced This page isn’t working, subdomain.domain.com is currently unable to handle this request. HTTP ERROR 500

2

Answers


  1. Chosen as BEST ANSWER

    How did I solve this error:

    I re-create the Laravel new project just like the above command and put that file to my server path to /public_html/laravel/. Therefore, I didn't change anything on the index.php file on the public folder, remain to the default condition. By doing this still error remains same (HTTP ERROR 500).

    Then, I look at the error_log file at /public_html/laravel/public/, and see an error Parse error: syntax error, unexpected '?', expecting variable (T_VARIABLE) in public_htmllaravelvendorramseyuuidsrcfunctions.php line on 34.

    In cPanel MultiPHP Managers, I select my sites and set the PHP Version to the same version it has before [PHP 7.3 (ea-php73)]. Then, BOOM!! It worked. I see the homepage of my laravel project in the URL.

    In brief, selecting the same PHP Version in cPanel MultiPHP Managers, help me to solve this error.


  2. First of all upload the laravel to your domain root folder and not public_html and extract, then move the content of the public folder of your laravel to /public_html/subdomain.maindomain.com/public then edit the content of the index.php require __DIR__.'/../vendor/autoload.php'; equire_once __DIR__.'/../bootstrap/app.php'; to this require __DIR__.'/../../../laravelpackagename/vendor/autoload.php' and $app = require_once __DIR__.'/../../../laravelpackagename/bootstrap/app.php';
    Not tested but I believe this should work

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