11

I want to host a laravel project in a subdomain.. For that first First I create a subdomain name registraion.

And inside the publicm_html/registraion i upload the project file. enter image description here But when I see the project on url I saw only files not the project I stored.

enter image description here

what's the problem of uploading the laravel project? Can anyone help me to find it out?

Hola
  • 2,163
  • 8
  • 39
  • 87
  • move index.php file from publc folder to your root project folder.and change require __DIR__.'/../bootstrap/autoload.php'; to require __DIR__.'/bootstrap/autoload.php'; – Pradyut Manna Oct 06 '16 at 03:18
  • 1
    moving `index.php` is not the solution to this. There could be other sites running on the root folder. – Samundra Oct 06 '16 at 03:21
  • i mean the root folder of laravel folder.@Samundra – Pradyut Manna Oct 06 '16 at 03:23
  • 1
    I think you are complicating things. Simply pointing the sub-domain root folder to `project-root/public/` is enough. We don't need to update `DIR.'/../bootstrap/autoload.php`. This is something which Laravel takes care of and we don't need to worry about it. – Samundra Oct 06 '16 at 03:28
  • I followed your steps but couldn't solve it @PradyutManna – Hola Oct 06 '16 at 03:48
  • From laravel docs: `Laravel should always be served out of the root of the "web directory" configured for your web server. You should not attempt to serve a Laravel application out of a subdirectory of the "web directory". Attempting to do so could expose sensitive files present within your application.` – HomeIsWhereThePcIs Jun 10 '20 at 16:44

4 Answers4

22

Assuming you are using cPanel to create subdomain. Below are the general steps that are required to setup sub-domain for laravel-project.

  1. Create your sub-domain
  2. Upload your laravel project to the sub-domain home directory.
  3. After you have uploaded all the files. Update your sub-domain document-root to point to public_html/registration/public/ folder, you can do this from sub-domain manager inside cPanel see.

After following 1-3 steps you should see your laravel project. However you also need to setup proper file permissions on laravel's bootstrap, storage folder to get it up and running.

Let us know if this helps you or not.

Samundra
  • 1,869
  • 17
  • 28
  • 1
    See My Subdomain name is `registraion`. So I point to Document root to .. ` /public_html/registration/public` but when I try to acess the url r`egistraion.abc.com` I saw the following Error : `Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /home/esbbd/public_html/registration/public/index.php on line 50` – Hola Oct 06 '16 at 04:06
  • Inside control panel. Under `domains` click on `subdomains`. In the newly opened page, below you will see `Modify a subdomain`. Click on `pencil` icon next to `Document Root` link for your subdomain and change it to '/public_html/registration/public`. Simply enter `public_html/registration/public` and click on `Change`. Retry to visit your sub-domain. It must be working now. – Samundra Oct 06 '16 at 04:11
  • You said it's a laravel project and we usually don't tinker with its `index.php`. What is the laravel version, PHP version in your server? – Samundra Oct 06 '16 at 04:14
  • I got the error "No input file specified." Any idea? The app was running okay when visited sub/public but now not working – Delowar Hossain May 18 '20 at 12:23
  • This page isn’t working //subdomainURL// is currently unable to handle this request. HTTP ERROR 500 – Buchi Jan 17 '21 at 22:56
6

Do as what @Samundra mentioned. If you have confusion this is the place where you need to put public_html/registration/public in your cPanel -> Sub-Domain

enter image description here

Mahfuzul Alam
  • 3,057
  • 14
  • 15
  • See My Subdomain name is `registraion`. So I point to Document root to .. ` /public_html/registration/public` but when I try toacess the url `registraion.abc.com` I saw the following Error : `Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /home/esbbd/public_html/registration/public/index.php on line 50` – Hola Oct 06 '16 at 04:04
  • Then it's versioning and disabled modules issue. What version of PHP you're using ? So that I can tell you what configuration do you need. – Mahfuzul Alam Oct 06 '16 at 04:07
  • PHP7 I'm using? – Hola Oct 06 '16 at 04:07
  • Got it..I didn't update the PHP version...Thanks for help. – Hola Oct 06 '16 at 04:09
0

In my case i tried each and every solution available. But when I checked the log I found one error:

 production.ERROR: No application encryption key has been specified. {"exception":"[object] (RuntimeException(code: 0): No application encryption key has been specified. at /home/******/public_html/**subdomain name*/vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php:44)
[stacktrace]

Then I searched for .env file in my project structure.(Check the hidden files list). In my project .env was not there by default only .env.example file was there.

so i created one .env and added

APP_NAME=Laravel
APP_ENV=local
APP_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=xxxxxxxxxxxxxxxxxxx
DB_USERNAME=xxxxxxxxxxxxxxxxxxx
DB_PASSWORD=xxxxxxxxxxxxxxxxxxx

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

I have generated one APP_KEY. For this I used

php artisan key:generate --show

Then I kept the key in the .env. Then Its done. Hope it may help someone

0

I think laravel project can be installed either in domain or in subdomain.

What need to pay attention when uploading your laravel project is, make sure there is nothing files (hidden) inside your subdomain directory. Delete all and upload your laravel project file or zip