【问题标题】:How do i hide my .env in laravel and Deploy Laravel Applicatio我如何在 laravel 中隐藏我的 .env 并部署 Laravel 应用程序
【发布时间】:2017-07-26 13:47:47
【问题描述】:

我不希望我的根目录中的文件直接被隐藏,其中包括 laravel 的 .env 文件,可能使用 .htaccess 或我尝试托管的任何其他方式 bt 我不想让一些人去 mysite .com/.env

APP_ENV=local
APP_KEY=base64:w8nPcK6CVaazC/WEv42hf+QOs4zWg2izt1pubH0KnQE=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306

我的服务器收到此错误。

PHP Parse error:  syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /home/skycashs/public_html/public/index.php on line 50

【问题讨论】:

  • 您的服务器应配置为从“公共”文件夹提供服务,因此以上所有内容都无法访问,如果您愿意,您还可以在生产环境中设置实际环境变量
  • 顺便说一句,这个错误意味着你需要更新你的 php 版本

标签: php laravel .htaccess environment-variables


【解决方案1】:

您需要将网络服务器(Apache 或 nginx)指向the public directory which is inside Laravel project root

您使用了错误的网络服务器配置。将您的网络服务器指向一个公共目录并重新启动它。

Apache Web 服务器的示例:

DocumentRoot "/project_root/public"
<Directory "/project_root/public">

对于 nginx:

root /project_root/public;

不要忘记重新启动网络服务器以使更改生效。

【讨论】:

  • 是.htaccess
  • @dagogodboss 通常你会创建一个 VH,look here
  • Mezenim 如何访问此 VH
  • 根据您使用的(apache 或 nginx),您需要将虚拟主机配置为指向公用文件夹。
猜你喜欢
  • 2021-07-15
  • 1970-01-01
  • 2015-02-09
  • 2019-10-22
  • 1970-01-01
  • 1970-01-01
  • 2018-03-06
  • 2016-09-03
  • 2013-02-01
相关资源
最近更新 更多