3

I am trying to install and configure Laravel 5 on a CentOS brand new server.

But I am afraid I don't have enough knowledge to understand and fix what is wrong with my environment. So I will try to describe as accurate as I can my actual setup and problems.

Let's start with Apache 2.4.9

Everything in the httpd.conf is almost default. I just edited the document root path to point directly at the future laravel public folder:

#
# 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

And before you ask, yes the mod_rewrite module is enabled.

Then my PHP also has basic configuration and it's version is 5.6.15.

Then I installed composer and used it to create a new laravel project

composer create-project laravel/laravel {directory} "~5.0.0" --prefer-dist

Everything successfully ran with no issues.

But now I try to visit my freshly installed laravel app by entering my server IP address but it only displays a blank page and if I check the console it gives me an 500 error.

So here is in order what I did to try to fix the problem:

  1. I found a post on the laravel blog that said we should give full right to the /storage folder which I did and now I don't have a white page anymore but instead I have the: 'whoops something went wrong' error.

  2. I try the alternate .htaccess config file suggested on the official laravel doc - nothing changed

  3. I don't why exactly I did this but I ran the php artisan serve command and now I see the Laravel welcome page... even if I exit the serve mode it still runs ?!? I am not sure if I understand why but even if I did it actually doesn't work completely... I only get the welcome page but if I try http://my-ip-address/home it shows me a 404 not found.

I feel like I have searched everywhere but yet I couldn't find an answer and I am close to the depression. Does anyone here has any clues about my problem ?

Thanks to anyone who can help me with this !

@update

Sorry I forgot the server logs:

    [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()

This is the 2 errors I get.

Valentincognito
  • 379
  • 6
  • 21

4 Answers4

0

Sorry I couldn't add a comment.

I think you might be missing the php-mcrypt extension.

dino
  • 191
  • 1
  • 6
  • I checked and it seems installed: /usr/local/php/bin/php -i | grep mcrypt mcrypt mcrypt support => enabled mcrypt_filter support => enabled mcrypt.algorithms_dir => no value => no value mcrypt.modes_dir => no value => no value – Valentincognito Dec 17 '15 at 06:04
  • From doing some research it could be that your install has got it's wires crossed. Try `php artisan cache:clear`, if that fails just clear the cache manually but don't remove the .gitignore files. Hope this fixes your problem - good luck. – dino Dec 17 '15 at 23:19
0

First generate key for laravel 5.1 application using below command. e.g. $ php artisan key:generate Application key [Idgz1PE3zO9iNc0E3oeH3CHDPX9MzZe3] set successfully.

Now copy this key and paste it in yourproject/config/app.php

'key' => 'Idgz1PE3zO9iNc0E3oeH3CHDPX9MzZe3',
0

Try this:

sudo chmod 775 /usr/local/apache/htdocs/vendor/services.json
Vikas
  • 993
  • 1
  • 10
  • 16
  • Is this your latest log file entry which you've shared above. Try reloading the page with apache url and share the latest entries in your log files. – Vikas Dec 17 '15 at 10:13
  • I don't need to post the new log files they remain the same. – Valentincognito Dec 17 '15 at 10:15
  • Try changing 'AllowOverride None' to 'AllowOverride all' in httpd.conf – Vikas Dec 17 '15 at 10:28
  • I just did it and now I get a 403 Forbidden Error. I live in korea and its a korean server so my translation of the full error might not be perfect but it says something about the permission to execute the CGI files. Are we getting closer ? – Valentincognito Dec 17 '15 at 10:59
  • What are the permissions on /usr/local/apache/htdocs? Try this: ls -al /usr/local/apache/ – Vikas Dec 17 '15 at 11:08
  • drwxr-xr-x. 15 root root 4096 2015-12-03 10:14 apache – Valentincognito Dec 17 '15 at 11:16
  • 1
    Let's [continue this discussion in chat](http://chat.stackoverflow.com/rooms/98223/discussion-between-vikas-and-valentincognito). – Vikas Dec 17 '15 at 11:45
0

Sorry, I haven't replied during the weekend, I was a bit busy.

Everybody had a bit of right in their answers. It was definetlely directories permission problem. I haven't found yet the perfect level of permission because I am not an expert. But I can tell you if I chmod -R 777 /storage /vendor and /public it works.

I know chmod 777 is probably insecure but I am really not an expert in permissions..

But anyway I'll mark this answer as solved because I indeed solved my problem in a way :)

But if anybody has a better answer or would like to give a more detailled explanation I'll update this post or mark the best answer as solved.

Valentincognito
  • 379
  • 6
  • 21
  • Yes, `chmod 777` is insecure ;-) I wrote [an introduction of Unix permissions](http://stackoverflow.com/a/35895436/660921) which may be helpful. – Martin Tournoij Mar 13 '16 at 04:48