简体   繁体   English

如何在子域上上传laravel项目?

[英]How to upload laravel project on subdomain?

I want to host a laravel project in a subdomain.. For that first First I create a subdomain name registraion.我想在子域中托管一个 Laravel 项目。首先,我创建一个子域名注册。

And inside the publicm_html/registraion i upload the project file.在 publicm_html/registraion 中,我上传了项目文件。 在此处输入图片说明 But when I see the project on url I saw only files not the project I stored.但是当我在 url 上看到项目时,我只看到了文件,而不是我存储的项目。

在此处输入图片说明

what's the problem of uploading the laravel project?上传laravel项目有什么问题? Can anyone help me to find it out?谁能帮我找出来?

Assuming you are using cPanel to create subdomain.假设您使用 cPanel 创建子域。 Below are the general steps that are required to setup sub-domain for laravel-project.以下是为 laravel-project 设置子域所需的一般步骤。

  1. Create your sub-domain创建您的子域
  2. Upload your laravel project to the sub-domain home directory.将您的 Laravel 项目上传到子域主目录。
  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 .更新您的子域文档根目录以指向public_html/registration/public/文件夹,您可以从 cPanel 中的子域管理器执行此操作,请参阅

After following 1-3 steps you should see your laravel project.执行 1-3 个步骤后,您应该会看到您的 Laravel 项目。 However you also need to setup proper file permissions on laravel's bootstrap , storage folder to get it up and running.但是,您还需要在 laravel 的bootstrapstorage文件夹上设置适当的文件权限以使其启动和运行。

Let us know if this helps you or not.让我们知道这是否对您有帮助。

Do as what @Samundra mentioned.按照@Samundra 提到的做。 If you have confusion this is the place where you need to put public_html/registration/public in your cPanel -> Sub-Domain如果您有困惑,这是您需要将public_html/registration/public放在 cPanel -> 子域中的地方

在此处输入图片说明

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).然后我在我的项目结构中搜索 .env 文件。(检查隐藏文件列表)。 In my project .env was not there by default only .env.example file was there.在我的项目中,默认情况下 .env 不存在,只有 .env.example 文件存在。

so i created one .env and added所以我创建了一个 .env 并添加了

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.我已经生成了一个 APP_KEY。 For this I used为此,我使用了

php artisan key:generate --show

Then I kept the key in the .env.然后我将密钥保存在 .env 中。 Then Its done.然后它完成了。 Hope it may help someone希望它可以帮助某人

I think laravel project can be installed either in domain or in subdomain.我认为 laravel 项目可以安装在域或子域中。

What need to pay attention when uploading your laravel project is, make sure there is nothing files (hidden) inside your subdomain directory.上传你的 Laravel 项目时需要注意的是,确保你的子域目录中没有任何文件(隐藏)。 Delete all and upload your laravel project file or zip全部删除并上传您的 Laravel 项目文件或 zip

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM