When my code have error (even syntax errors) browser show 500 - Internal Server Error,
In .env I set the APP_DEBUG to true and APP_LOG_LEVEL is debug
How can I enable error messages?
UPDATE:
I use Laravel 5.3
UPDATE 2:
I use Apache and defined VirtualHost to access this app :
<VirtualHost *:80>
ServerAdmin myemail#domain.com
DocumentRoot "/Dev/Web/site/public"
ServerName site.local
ServerAlias www.site.local
ErrorLog "/private/var/log/apache2/site.local-error_log"
CustomLog "/private/var/log/apache2/site.local-access_log" common
<Directory "/Dev/Web/site/public/">
Require all granted
AllowOverride All
</Directory>
</VirtualHost>
UPDATE 3:
My /etc/hosts records:
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost gat.local www.gat.local site.local www.site.local shop.local www.shop.local
Short answer you can't. Why?
Simply because 500 - Internal Server Error is exactly what it says Internal Server Error, it has nothing to do with Laravel. Server software (Apache in your case) causes error 500. Most likely permissions problem. (server software can not read / write to certain files etc.)
From Laravel documentation:
After installing Laravel, you may need to configure some permissions. Directories within the storage and the bootstrap/cache directories should be writable by your web server or Laravel will not run.
You have to check Apache logs
Default on OSX machine /private/var/log/apache2
You want to see more errors? Follow up this SO thread.
Neat trick, make sure to have one entry per project in your hosts file.
#127.0.0.1 project1.dev www.project1.dev
#127.0.0.1 project2.dev www.project2.dev
.
.
.
Why? You can just comment out / delete line, searchable, easier to read.
#MajAfy You can use barryvdh/laravel-debugbar. This will give you in depth knowledge of every error. What query you are running and lot more.
Here is the link https://github.com/barryvdh/laravel-debugbar .
Its easy to install due to its well documentation.
After many tries, I found problem,
Everything return to file permissions,
I changed the permission of laravel.log in storage/logs to 777 and everything work fine !
Related
I'm using Xdebug/PhpStorm for a long time and never saw this problem:
PhpStorm 2019.1.3
Docker 18.09.2
image mattrayner/lamp:latest-1804
Ubuntu 16.04.6
PHP v7.3.3-1+ubuntu16.04.1+deb.sury.org+1
When I run debugger in PhpStorm, the debugger breaks on the correct line but when I step through the code, it jumps to random places in the code, and the browser receive empty response, with no errors in the log.
More info:
I have a similar setup on the same machine with image mattrayner/lamp:latest-1604 - in this setup the problem does not reproduce
If I set "stop at first line" I can step through the code on the first, but subsequent run will not step though the code
, difference: PHP Version 5.5.9-1ubuntu4.27, Ubuntu 14.04.6
when the debugger breaks, any operation will fail - e.g. clicking on run will finish the execution but the browser display empty response and no action executed after the break.
Content of /etc/php/7.3/apache2/conf.d/20-xdebug.ini
zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_port=9000
xdebug.remote_connect_back=0
xdebug.remote_host=host.docker.internal
Any idea how to solve it?
Tried with different version (7.2, 7.3 , 7.4) - same results:
here is my path mapping
and my Apache conf
<VirtualHost *:443>
ServerAdmin webmaster#localhost
ServerName dev.usaddress.com
CustomLog /var/log/apache2/access.log vhost_combined
SSLEngine on
SSLCertificateFile /app/dev.usaddress.com.crt
SSLCertificateKeyFile /app/dev.usaddress.com.key
DocumentRoot /app/usaddress
<Directory /app/usaddress>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
You should check your path mapping. That's usually a case for me. It can be mapped correctly in the place where your script firstly enter but can be mapped wrong in some other place. Make sure that you mapped only the root of your project or that you have correct mapping at all possible routes.
Server setting can be found at Languages & Frameworks > PHP > Servers
If you will look on my screenshot you can see that only folder public is mapped with absolute path on the server (which is /srv/sylius/public here). That means that other folders will be mapped relatively to this public folder.
If you think that it's not a case than I can advise you only to try manually go through code starting from that place where debugger breaks on the correct line step by step until unexpected behavior occurs. And from that point try to understand why it happening.
close your project
go to the project directory
delete .idea folder
create a new project with the project directory
go to 'Edit configuration' and recreate your debug configurations
run debuger
Notes:
I was not able to reproduce this bug with a similar env
I was not able to reproduce this bug with a different project running on the same env
therefore, I tried to recreate the project and it solved the problem
For me this issue was due to a watch expression that was causing an error during evaluation when the first breakpoint was hit. Removing the offending watch resolved it.
I've created two independent symfony projects and I've moved them to my prod server, for example:
project1.example.com [/var/www/project1/web]
project2.example.com [/var/www/project2/web]
The problem is that when I open up the second address, then project1 is fired up. I checked /var/www/project2/web/app.php and seems it's properly executed, but for some reason, symfony loaders use /var/www/project1/ path. Of course the cache folders were cleared.
Any ideas how to diagnose the problem?
UPDATE
Apache config files:
/etc/apache2/apache2.conf
/etc/apache2/sites-enabled/project1.conf + /etc/apache2/sites-enabled/project2.conf
UPDATE 2
Strange thing, this morning the situation has reversed. Both addresses show site from project2 now. No config nor project files were modified.
You'll need to enable Virtual Hosting in Apache.
Take a look at my article on it, it should answer the question:
https://alvinbunk.wordpress.com/2016/11/21/apache-httpd-virtualhost-config/
If you need further help with that, you can always post another question. I use this all the time.
EDIT #2 - based on Apache 2 conf:
Suggest you combine SSL and HTTP VirtualHost ports like so, and also just have a single Directory directive to the web folder. There are other redundancies in the conf file. Please read some documents first about the Apache config files before asking questions.
<VirtualHost *:443 *:80>
...
<Directory /var/www/project1/web>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
...
</VirtualHost>
For the Project2 problem, have you checked the logs in $APACHE_LOG_DIR to see what they show? I think logs are usually in /var/log; there's probably an httpd subdirectory with the httpd logs. You need to make sure there is an incoming GET request for project1.example.com.pl. If not, you'll need to check all your hosts files to see they are setup correctly.
I just installed Laravel 5 in my local environment on Mac Yosemite. I've set up Laravel in a directory and then created an Apache Virtual Host to point to that directory.
The root of the project can now successfully be accessed by visiting http://myproject.localhost.com. However, I don't see the Laravel welcome screen. Instead, I just see a blank white page, and I can't figure out why.
Chrome is showing a 500 Internal Server error when it tries to load the domain. The same thing happens if I try to access the index.php file directly: http://myproject.localhost.com/index.php.
I wanted to look in the Laravel error log to see what the issue is, but that left me even more confused because the store/logs directory is empty.
I know the virtual host setup is correct because when I point the virtual host to another project, that does not use Laravel, it works correctly. Also, I was previously receiving permission errors from the vendor directory, which I resolved. I thought that was the last issue that needed to be fixed before the welcome page would load correctly, but to my surprise, I only see a blank screen.
Has anyone experienced this before? Is there any more information I can provide to help solve this?
Here is my virtual host configuration:
<VirtualHost *:80>
ServerAdmin webmaster#slopes.localhost.com
DocumentRoot "/Users/myusername/dev/slopes/public"
ServerName slopes.localhost.com
ErrorLog "/private/var/log/apache2/slopes.localhost.com-error_log"
CustomLog "/private/var/log/apache2/slopes.localhost.com-access_log" common
<Directory "/Users/myusername/dev/slopes/public">
Require all granted
AllowOverride All
</Directory>
</VirtualHost>
When I try to access index.php in the browser, I see the request in /private/var/log/apache2/slopes.localhost.com-access_log, and it shows a 500 response. It produces no entries in /private/var/log/apache2/slopes.localhost.com-error_log.
I just did the same thing (also Yosemite) and here's the solution to my issue, maybe it is yours too.
Edit the public/.htaccess, comment the following lines:
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
to
#<IfModule mod_negotiation.c>
# Options -MultiViews
#</IfModule>
Check if it works.
Edit: Check your httpd-vhosts.conf file, does it looks something like this?
<VirtualHost *:80>
ServerAdmin you
ServerName www.myproject.localhost.com
ServerAlias myproject.localhost.com
DocumentRoot "/path/to/webfolder/laravel/public"
ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log"
CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common
</VirtualHost>
Check your ErrorLog, if you don't have it, add it, something must be there since the 500 is being throwed by Apache. Also, double check you're pointing the root to the public/ folder
EDIT: After chatting (https://chat.stackoverflow.com/rooms/73694), #Kyslik figured out it was the lack of the mcrypt extension, guided a new php and mcrypt install through brew. Then permission to storage/ and it worked.
I have the following problem.
I have two domains: www.domain1.de and www.domain2.de
I also have path is on Jelastic server where to find my PHP page
myphpsite.jelastic.dogado.eu.
Now I wanted to do the following.
1) If I go to www.domain1.de, then should address bar of the Web Browser
www.domain1.de be displayed, but the page is fetched from myphpsite.jelastic.dogado.eu.
2) When I go to www.domain2.de, then should address bar of the Web Browser
www.domain2.de be displayed, but the page is fetched from myphpsite.jelastic.dogado.eu / admin /.
so
1) www.domain1.de -> myphpsite.jelastic.dogado.eu
2) www.domain2.de -> myphpsite.jelastic.dogado.eu / admin /
The first one I can do by CNAM Record
But we can I solve the second problem without frames?
thank you
This is just a matter of configuring Apache VirtualHosts (assuming that you're using Apache), or Nginx Server Blocks (if you're using Nginx). Leo's link can help you with either of them, within a Jelastic context (where to find those config files etc.): http://docs.jelastic.com/multiple-domains-php
Here's a quick example for Apache:
<VirtualHost *:80>
DocumentRoot /var/www/webroot/ROOT
ServerName domain1.de
ServerAlias www.domain1.de
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/webroot/ROOT/admin
ServerName domain2.de
ServerAlias www.domain2.de
</VirtualHost>
You might also wish to define different log files for each domain etc.
There are many possibilities, and since Jelastic gives you direct access to the server config. files you can configure almost anything that you could want here. It's just a matter of reviewing the Apache (or Nginx) docs and trying it out.
Notes:
Beware that the Jelastic default configuration defines a wildcard to catch all requests. You need to place your custom configuration before that (either literally, or via an include), or else overwrite the default VirtualHost configuration block - otherwise your config. will not have any effect.
The above example handles HTTP only. If you need to handle HTTPS, you need to configure this separately. (e.g. :443 instead of :80)
Remember that you need to restart Apache (or Nginx) for config. changes to take effect.
See also:
Apache VirtualHost Documentation
Nginx Server Blocks Documentation
After much faffing about I got laravel to work with XAMPP. However, I can't seem to access directories in the htdocs folder via localhost now. Attempt to access a file returns Object not found! along with The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
The changes I made to get laravel working seems like a blur now. The only thing I remember doing is editing the hosts file to enable the virtual host to work by adding 127.0.0.1 laravel.dev in the hosts file (using a mac btw). I also added a virtual host to the httpd-vhost.conf file.
I did undo the above changes but it didn't make a difference.
Any thoughts on whats gone wrong?
Thanks.
Dispelling Confusion
Just thought I'd clarify what my experience is. Before installing laravel 4 I could access all my projects with localhost/someProjectName but now it fails.
I'm trying to identify what change caused this behaviour. Btw, I have no problems accessing my laravel project (my mapping allows me access to it via laravel.dev)
Look into your /etc/httpd.conf file and see if you have Virtual hosts activated.
If so, check your etc/extra/httpd-vhosts.conf file. You might have set up a VirtualHost already.
EDIT: I have found that once you turn on Virtual Hosts, XAMPP needs a default VirtualHost for your basic htdocs files
Try adding a default VirtualHost (at the bottom of the file) like so:
<VirtualHost *:80>
ServerName localhost
DocumentRoot "/Applications/XAMPP/htdocs"
<Directory "/Applications/XAMPP/htdocs">
Options Indexes FollowSymLinks Includes execCGI
AllowOverride All
Order Allow,Deny
Allow From All
</Directory>
</VirtualHost>
It sounds to me like it is a problem with the way your directories are configured. Be sure to create a Virtual Host (if you're using Apache) that points to the public folder within your application directory.
For example, if your Laravel project is under /Applications/XAMPP/htdocs/Laravel then set up a Virtual Host like this:
<VirtualHost *:80>
DocumentRoot /Applications/XAMPP/htdocs/Laravel/public
# Other directives here
</VirtualHost>
Additionaly, if you're working with PHP >= 5.4, SSH into the application folder and run
./artisan serve
(Be sure that your PHP executable is in your PATH variable). Then go localhost:8000 and you should have your application running.
Running this command runs the PHP built-in webserver and saves you the trouble of configuring virtual hosts.
In your Apache's http.conf, find the DocumentRoot line and add the subdirectory /public on the end.
Once that is done and you've restarted Apache, you'll be able to access everything which is contained within your htdocs/public folder (including subdirectories of that folder), along with any routes you've defined in Laravel.
Laravel is designed to be set up this way as to protect the code and files by not having them in the folder which is served out to the web.
I have same issue and found that there are miss configuration in vhost. So that's are correct configuration.
in etc/extra/httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "D:/xampp/htdocs/laravel-master/public"
ServerName laravel.local
ErrorLog "logs/laravel-master-error.log"
<Directory D:/xampp/htdocs/laravel-master/public>
AllowOverride All
Order Allow,Deny
Allow From All
</Directory>
</VirtualHost>
In the hosts file
127.0.0.1 laravel.local
I don't know if you're running L4 or L3. However, launch CLI and
$ cd ./path/to/project
Then for L4:
$ php artisan serve
For L3:
$ php -S localhost:8000 -t public
Now you can go to localhost:8000 and see your application.
You're having problem because the object really doesn't exist in your htdocs directory. You don't have to append xampp after localhost or 127.0.0.1 because xampp will treat it as an object or a folder under htdocs.
if you want to access your blog, make sure you have a blog folder under htdocs and put in your URL localhost/blog