Segfaults in Laravel 5.5 - php

I recently started a little project in Laravel 5.5. I updated my Homestead box to the latest version.
While writing a test, I came across a segfault if I spelt an assertion method incorrectly, and I created an issue on the github repo which can be found at https://github.com/laravel/framework/issues/20925
The issue has been closed now, as rightfully, it was my mistake (asertPushedOn() instead of assertPushedOn()).
However I've recently come across another segfault, again, it was my error (incorrectly named relationship when trying to eagerload), but the problem is, this never happened prior to 5.5. Now, it seems when I mess something up, I'm randomly getting segfaults. I cant find anything to help debug them in the logs (Laravel logfile or nginx error log.
The only error message I get is Segmentation fault (core dumped) which doesn't tell me anything.
On the issue report, it mentioned xdebug dumps out the error. I had a google for laravel homestead xdebug but could only find resources for phpstorm (I'm a sublime user).
TL;DR:
1) In Laravel 5.5 with an updated homestead box, I'm getting php segfaults now if I mess up somewhere. Is this a change in 5.5 / homestead?
2) How can I enable xdebug (will this actually help debug segfaults)?
3) If xdebug isn't the answer, how can I stop getting, or get more default debug info from segfaults?
As mentioned in the issue I created, I don't know much about segfaults.
If you need any further information, please let me know
EDIT
I managed to enable xdebug with:
sudo phpenmod xdebug
sudo service nginx restart
php -m
But I've been unable to reproduce the segfault (with and without xdebug enabled), which makes segfaults all the more confusing for me.

So while I wasn't able to reproduce the original segfault, another one did occur while xdebug wasn't enabled.
When I enabled xdebug with the following:
sudo phpenmod xdebug
sudo service nginx restart
and reran the script which gave me the segfault, I successfully got the recursion error with the filename and line number to resolve it.

Related

Laravel Deployment in CPanel return HTTP Error 500

I think this might be one cliche question but this really confusing me.
I have Laravel App (Ver 5.6) to be deployed in my CPanel. I have followed all the steps which mentioned in this tutorial,
https://medium.com/laravel-power-devs/deploy-laravel-projects-on-shared-hosting-2008be6f6f03
And then, when i try to running it, it showing me error as below,
First thing came up in my mind is PHP version issue. Yes, i found out that my PHP version is outdated which is v5.6. and i changed it.
But, when im refresh the site, the error still appear. and someone tell me this might be caused by code error and i check the error_log file, so here it is,
[12-Dec-2018 15:31:11 Asia/Country] PHP Parse error: syntax error, unexpected '?' in /home/root/laravelapp/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php on line 500
So, this part is really make me stressful because most of Laravel communities tell me this error happen because of PHP version in my CPanel. Like i said earlier, the version already changed to v7.1.
Did you guys have facing same situation like me? Please help me out. am really don't know what to do right now. Thank you!
Changing the php version is not enough. You actually need to change the php-fpm executable too.
[Client] --calls--> [Web server] --forwards to--> [PHP FPM] --asks--> [PHP]
So if your fpm instance is pointing at the old php version you'll still get your error. To check everything is setup correctly:
sudo php-fpm -i | grep "PHP Version"
>> should show you which version is being used
If the binary is not in the path you'll have to locate it:
sudo find / -type f -name php-fpm
Alternatively look for it in /usr/bin/php-fpm, /usr/sbin/php-fpm, /usr/local/bin/php-fpm, /usr/local/sbin/php-fpm. If you find more than one binary, try to call it with the -i option.
sudo /usr/local/sbin/php-fpm -i | grep "PHP Version"
Then in your webserver config you'll have to make sure you're using the correct fpm connection. Usually it's a socket, but could also be a fastCGI forward
sudo vim /etc/nginx/sites-enabled/your-site
Look for this line and make sure you're using the correct version.
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
(If you use apache it's similar, but you'll have to search for the correct steps there.)
If you're not using the correct version of fpm you'll have to start the process by executing the php-fpm binary for php7.1 and point the webserver to the correct socket.

PHP upgrade issues

I am running a MacBook Air with macOS Sierra 10.12.3. I upgraded my PHP from 5.x to 7.1.1 according to this site and now I am having two issues:
a) The PHP process startup takes around 7 seconds, even for a php -v to print PHP's version. edit: Solved.
b) Apache does not serve my pages anymore locally. Chrome just shows the generic error page with "ERR_CONNECTION_REFUSED". I have restarted the apache service but don't really know what else to do. The apache vhosts config file worked before and still looks good. edit: Also nothing in the apache error logs.
edit: The syslog shows
(org.apache.httpd[71685]): Service exited due to signal: Segmentation fault: 11 sent by exc handler[0]
(org.apache.httpd): Service only ran for 5 seconds. Pushing respawn out by 5 seconds
Does anyone know how to fix this?
Solved it now.
The issue with Apache was that an additional config file in /etc/apache2/other/+php-osx.conf was created that loaded the php7.1 module, but the module loading of php5 in /etc/apache2/httpd.conf was not disabled.
Loading both obviously crashed apache and commenting out the LoadModule in httpd.conf solved it. I have no idea why the installation routine didn't do that though.
Thank you all for helping me.
https://php-osx.liip.ch is a pretty good site, I used to use it before to upgrade my php installations. I found that time to time it would be untrust worthy and sometimes brick my installation. Edit The scripts used on that site usually compile PHP when ran and this can lead to some interesting quirks and inconsistencies. So I switched to using brew.
Brew is a handy tool for Mac that works a lot like apt-get or yum. I would recommend you try this, it adds libraries in a way that allow you to purge them from your machine and reverting to older versions.
$ brew search php71
# lists all the matches for php71, you will find "homebrew/php/php71"
$ brew install homebrew/php/php71
# installs php71, it will give you some good instructions if there are errors
# typically some permission errors, but it gives commands to run too
$ brew link homebrew/php/php71
# overrides the local php command with "homebrew/php/php71"
$ php -v
PHP 7.1.1 (cli) ...
Then I would suggest looking at PHP Local Server that is built in if its still not working. Although I am 99% sure your issues will be resolved.
In future upgrading your php version is as simple as doing the above again where php71 is your new version (example php72 for 7.2). Removing your old version is easy, although does no harm and does allow you to quickly switch your versions around with a single command line option.

503 Service Unavailable after brew install and restarting apache2

I'm working in framework Phalcon, which uses PHP. I wasn't able to connect my application with Postgresql. I discovered this webpage: Enabling PostgreSQL support in PHP on Mac OS X, which basically says I should download something like "php_pdo_pgsql.so" and following a well voted solution I did:
brew install php56-pdo-pgsql
and then I restarted my apache with:
sudo /usr/sbin/apachectl restart
When I reloaded my web page, which was working perfectly, appears the error:
Service Unavailable
The server is temporarily unable to service your request due to
maintenance downtime or capacity problems. Please try again later.
Looking for the error log of the webpage it seems that after the restart there are not more errors, also no more accesses in the access log. I'm using version 5.6 of PHP. My server is OSX Sierra.
I accept solutions, ideas and new question to solve my problem. Thank you very much.
I solved it!
There were no more errors in apache log. Why? When I installed the PDO of php-postgresql with brew, it automatically installed apache of brew and change the configuration of the server. So, I had 2 "apache" in my server, what screw up everything.
I used this tutorial:
https://getgrav.org/blog/macos-sierra-apache-multiple-php-versions.
In general terms, What I did was uninstallig everything I could and installing apache from brew. Then I made the configuration of the tutorial and finally my webpage is running again.
Thanks.
Please check apache2 logs file, and look for an error. If You will not be able to resolve the problem by yourself, then provide us with error message given in error.log.

I installed symfony 3, ran the server and got a connection refused when I ran the webserver

I auto-generated a Symfony 3 application with the CLI they provide and I put it inside my www/html folder, which my apache2 server serves its files from:
Then I tried to do:
$ php bin/console server:start -vvv
$ sudo php bin/console server:start -vvv
$ php bin/console server:start 127.0.0.1:2040
but I keep getting the following error:
[2016-03-18 00:06:14] php.DEBUG: fsockopen(): unable to connect to 127.0.0.1:8000 (Connection refused) {"type":2,"file":"/var/www/html/sample_symfony_blog/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/ServerCommand.php","line":59,"level":28928}
I can't find any concrete answer on what this could be, other than it could be that the port is busy, which is why I tried with port 2040 as well.
Symfony official's documentation talks about some user rights running the webserver and that the PHP CLI should have the same permissions or something? I'm not that used to configure Apache/Ubuntu so I don't know what to do to test it out in that regard. Any hints?
At the risk of resurrecting a really old question, I'd like to add a note from recent experience. I had a working Symfony 3 installation using PHP 5.6 that stopped working when I upgraded to PHP 7.1. Trying to start the built-in server gave me the same connection refused error, which led me here.
Ultimately, I solved the problem by running php bin/symfony_requirements. The output told me that I had xdebug.scream turned on in my php.ini and it had to be turned off. Fixing that made the problem go away.
I hope this helps someone.
Okay, so i realized putting a error early in my /etc/php5/cli/php.ini file, made it work, obviously because my php.ini file ran a configuration that made it not work, i did not find out which file option that caused it to happen. The reason i even tried to fix this problem was because i couldn't get it to work by accessing it via my apache2 webserver on localhost:80/my_project, but instead had to access localhost:80/my_project/web which works just fine, so im doing that instead of running my own builtin php server - because thats the way i have to run it in production anyway so. Thanks to anyone who sat down and tried to figure it out :)

Instaling composer for laravel framework

I have a problem with instaling composer for laravel framework:
I have this error:
Some settings on your machine make Composer unable to work properly.
Make sure that you fix the issues listed below and run this script again:
The openssl extension is missing, which means that secure HTTPS transfers are impossible.
If possible you should enable it or recompile php with --with-openssl
I try everything I find on net - change php.ini, instal via CMD but nothing work...
I really dont understand what can be a problem here. Please help.
Here is a image of what I try:
You have the wrong PHP Version.
Personally, I wouldn't bother to fix it. Use Homestead to create a virtual ubuntu instance. Everything will be up and running in minutes

Categories