我们先从Apache 2.4.9开始谈起。httpd.conf中的所有内容都几乎是默认的。我只编辑了文档根路径,以直接指向未来的 Laravel 公共文件夹:
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/usr/local/apache/htdocs/public"
<Directory "/usr/local/apache/htdocs/public">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options -Indexes -FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride None
#
# Controls who can get stuff from this server.
#
Require all granted
在你问之前,mod_rewrite模块已启用。
然后我的PHP也进行了基本配置,版本是5.6.15。
接着我安装了composer,并使用它创建了一个新的Laravel项目。
composer create-project laravel/laravel {directory} "~5.0.0" --prefer-dist
一切都成功运行,没有任何问题。
但是现在我尝试通过输入我的服务器IP地址来访问新安装的Laravel应用程序,但只显示一个空白页面,如果我检查控制台,它会给我一个500错误。
所以这里是我为了尝试解决问题而做的事情:
我在Laravel博客上找到了一篇文章,说我们应该给/storage文件夹完全权限,我已经这样做了,现在我不再有白屏问题,但是我得到了“糟糕,出了些问题”的错误。
我尝试使用官方Laravel文档建议的备用.htaccess配置文件 - 没有改变
我不知道为什么我要这样做,但我运行了
php artisan serve
命令,现在我看到了Laravel欢迎页面...即使我退出服务模式它仍然运行?!?我不确定我是否理解为什么,但即使我这样做了,它实际上并没有完全工作...我只获得欢迎页面,但如果我尝试http://my-ip-address/home,它会显示404未找到。
我感觉我已经到处搜寻了,但是我找不到答案,我接近沮丧。这里有人知道我的问题吗?
感谢任何能帮助我的人!
@更新
对不起,我忘记了服务器日志:
[2015-12-17 04:22:03] production.ERROR: exception 'ReflectionException' with message 'Class encrypter does not exist' in /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Container/Container.php:776
Stack trace:
#0 /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Container/Container.php(776): ReflectionClass->__construct('encrypter')
#1 /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Container/Container.php(656): Illuminate\Container\Container->build('encrypter', Array)
#2 /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(613): Illuminate\Container\Container->make('encrypter', Array)
#3 /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Container/Container.php(887): Illuminate\Foundation\Application->make('Illuminate\\Cont...')
#4 /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Container/Container.php(848): Illuminate\Container\Container->resolveClass(Object(ReflectionParameter))
#5 /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Container/Container.php(813): Illuminate\Container\Container->getDependencies(Array, Array)
#6 /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Container/Container.php(656): Illuminate\Container\Container->build('Illuminate\\Cook...', Array)
#7 /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(613): Illuminate\Container\Container->make('Illuminate\\Cook...', Array)
#8 /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(127): Illuminate\Foundation\Application->make('Illuminate\\Cook...')
#9 /usr/local/apache/htdocs/public/index.php(57): Illuminate\Foundation\Http\Kernel->terminate(Object(Illuminate\Http\Request), Object(Symfony\Component\HttpFoundation\Response))
#10 {main}
[2015-12-17 04:22:03] production.ERROR: exception 'ErrorException' with message 'file_put_contents(/usr/local/apache/htdocs/vendor/services.json): failed to open stream: Permission denied' in /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Filesystem/Fi$
Stack trace:
#0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'file_put_conten...', '/usr/local/apac...', 74, Array)
#1 /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php(74): file_put_contents('/usr/local/apac...', '{\n "provider...', 0)
#2 /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php(193): Illuminate\Filesystem\Filesystem->put('/usr/local/apac...', '{\n "provider...')
#3 /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php(139): Illuminate\Foundation\ProviderRepository->writeManifest(Array)
#4 /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php(59): Illuminate\Foundation\ProviderRepository->compileManifest(Array)
#5 /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(439): Illuminate\Foundation\ProviderRepository->load(Array)
#6 /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/RegisterProviders.php(15): Illuminate\Foundation\Application->registerConfiguredProviders()
#7 /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(167): Illuminate\Foundation\Bootstrap\RegisterProviders->bootstrap(Object(Illuminate\Foundation\Application))
#8 /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(195): Illuminate\Foundation\Application->bootstrapWith(Array)
#9 /usr/local/apache/htdocs/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(106): Illuminate\Foundation\Http\Kernel->bootstrap()
这是我遇到的两个错误。
chmod 775 index.php
- manix