503 Service Unavailable after brew install and restarting apache2 - php

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.

Related

How to properly install Xampp on Mac in order to run PHP code

I downloaded the installer version of Xampp version 8.1.6-0 for Mac and went to the manager-osx widget to start the Apache and MySQL servers but neither would start.
I then tried using the command sudo apachectl start and then created an index.php file and put it in htdocs, and then tried to open it using http://localhost/index.php as well as http://localhost:8080/index.php and both times it said the server could not be reached.
I've actually downloaded Xamp in the past and was able to reach the server but wasn't able to get php scripts to run, but now for some reason I can't even get the server to run.
I made sure to download the installer and not the virtual machine version. I'm running Monterey version 12.4.
I tried the solutions here but they didn't seem to work. I checked my activity monitor and nothing is running on port 80.
I also installed MAMP from here and tried to start Apache but it displayed the error:
"Apache couldn't be started. Please check your MAMP installation and
configuration."
Any help would be appreciated as I just want to run PHP.

Segfaults in Laravel 5.5

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.

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.

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 :)

Homebrew Yosemite Apache issue

I installed a Homebrew Apache setup as explained here.
For me, it doesn't work at the moment.
When running httpd -DFOREGROUND, I'm getting the next error:
httpd: Syntax error on line 117 of /usr/local/etc/apache2/2.2/httpd.conf: Cannot load /usr/local/Cellar/php55/5.5.27_2/libexec/apache2/libphp5.so into server: dlopen(/usr/local/Cellar/php55/5.5.27_2/libexec/apache2/libphp5.so, 10): Symbol not found: _ap_unixd_config\n Referenced from: /usr/local/Cellar/php55/5.5.27_2/libexec/apache2/libphp5.so\n Expected in: /usr/local/bin/httpd\n in /usr/local/Cellar/php55/5.5.27_2/libexec/apache2/libphp5.so.
The file (/usr/local/Cellar/php55/5.5.27_2/libexec/apache2/libphp5.so) does exist though.
Running dnsmasq --keep-in-foreground then, it fails with dnsmasq: failed to create listening socket for 127.0.0.1: Address already in use.
All error logs in troubleshooting are empty.
Important to know is, that I installed another setup earlier, before upgrading to 10.10 that did work for a while, stopped working suddenly. After that, I decided to upgrade my OS and removed everything as explained in the Troubleshooting section. I restarted from the beginning.
Thanks!
Try to brew reinstall php55 --homebrew-apxs.
As mentioned here, this should solve this problem.

Categories