How to upload laravel project on subdomain?
Asked Answered
S

4

12

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?

Skit answered 6/10, 2016 at 3:12 Comment(6)
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';Marlenmarlena
moving index.php is not the solution to this. There could be other sites running on the root folder.Lapidate
i mean the root folder of laravel folder.@LapidateMarlenmarlena
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.Lapidate
I followed your steps but couldn't solve it @PradyutMannaSkit
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.Nugget
L
24

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.

Lapidate answered 6/10, 2016 at 3:20 Comment(5)
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 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 50Skit
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.Lapidate
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?Lapidate
I got the error "No input file specified." Any idea? The app was running okay when visited sub/public but now not workingKeeper
This page isn’t working //subdomainURL// is currently unable to handle this request. HTTP ERROR 500Mangan
P
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

Profanatory answered 6/10, 2016 at 3:58 Comment(4)
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 50Skit
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.Profanatory
PHP7 I'm using?Skit
Got it..I didn't update the PHP version...Thanks for help.Skit
D
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

Deft answered 23/3, 2019 at 16:50 Comment(0)
M
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

Mandimandible answered 13/6, 2021 at 1:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.