PHP is hanging only after server reboot - php

I recently upgraded from php 7.0 to 7.3, to finalise this I did the following
a2dismod php7.0
a2enmod php7.3
service apache2 restart
This works fine, and phpinfo() shows I am now using 7.3.
However after a system reboot any php function hangs, this includes CLI.
To "fix" this I can do "a2dismod php7.3" without restarting apache2 service which for some reason brings my php CLI functionality and websites back online and running 7.3 - though if I do "service apache2 restart" it does disable php as you would now expect
I am unsure why this is happening and can find nothing in logs.
(PHP 7.3.11-1+ubuntu16.04)
a2dismod php7.0
a2enmod php7.3
service apache2 restart
No error messages appear, if I try php -v it will hang indefinitely.

Related

Why does my website loads infinitely after I tried the sleep method?

So I was playing with the sleep method of php. I coded sleep(99999); Now my website won't load lol. Is it because of that? How can I fix it?
I think you can just restart apache, or php-fpm if you are using php-fpm. And why in the world would you try that!
You must restart your server if restarting your web server didn't work. Or, it will just be stuck in a delay until the sleep time ends.
I would advise you not to play with a production server. Use a test server for these tests. Because it is not as easy to reset these issues.
For example, when you are using shared hosting, you cannot restart apache yourself.
How do I setup a test server:
Install some software like XAMPP if you are using Windows in your home PC. Or, if you are using Linux, you can just install apache and php using the following commands on:
Ubuntu/Debian: sudo apt install apache2 php
CentOS/Fedora: sudo yum install epel-release, and sudo yum install httpd php or sudo dnf install httpd php
Arch Linux/Manjaro: sudo pacman -S apache php php-apache

apache2 This site can’t be reached when using php5.6

been working in ubuntu 16.04 and i have apache2 with php installed.
all is good and i can switch version from php 7.0 - 7.4 without any issues.
now i have to setup a project developed using php5.6.
installed it normally
sudo-apt install php5.6
switch php for cli using
sudo update-alternatives --config php
was able to switch successfully. but when i change the php for apache.
sudo a2dismod php7.1 ; sudo a2enmod php5.6 ; sudo service apache2 restart
I can no longer access my localhost. it only returns an error.
This site can’t be reached
localhost refused to connect.
switching back to other php version (7.x) will fix it. but i need to use php5.6.
also no errors in /var/log/apache2/error.log
did i do some mistakes on php5.6 installation or there are some apache configs missing?
Thank you in advance
found the cause of the error. you should make sure no other php7.x are enabled on your apache. ive been switching versions and didnt realize i left 7.4 enabled.
sudo a2dismod php7.0, sudo a2dismod php7.1, sudo a2dismod php7.2........
until i made sure that everything was disabled aside from php5.6

curl is not working in my ubuntu vps

I am using ubnutu server in atlantic vps. I have installed lamp stack and all the required configuration for php. I have installed curl and it is also enabled. in php.ini allow_url_fopen = On; ; but it still not working.
You need to install the php cURL extension by logging into the command line of your vps and entering the following command...
sudo apt-get install php5-curl
You then need to restart the server using the command
sudo service apache2 restart
If you are using php-fpm you will need to restart php5-fpm instead using the command
sudo service php5-ftp restart
cURL is the better option anyway as it isn't affected by security configurations in PHP such as forbidden fopen of remote URI's etc.

Change apache2 php path

I am using https://github.com/wilmoore/php-version to switch between php versions on my local machine, installed within ~/php/versions. Currently setting up separate VMs with different versions of php installed is not an option.
When I switch php version through the command line using the linked tool, I see it listed as php 7. This also works when using php -v. I have restarted terminal and the machine and it still says php 7.
I have updated composer.json to require php 7.0.2 and greater. Yet when I use phpinfo() in my laravel application, it always states the default PHP Version 5.5.9-1ubuntu4.14.
Where is laravel pointing to the php distribution in my Ubuntu 14.04.3 machine and where can I change this path?
EDIT: I am using Apache. I can see in the phpinfo() output that it is reading the ini file from /etc/php5/apache2/php.ini. I have looked in this file but cannot see where to point to the php distribution.
first make sure that php7.*.conf and php7.*.load files are exist in /etc/apache2/mods-available directory.
then use sudo a2enmod php7.* to enable the mod
use sudo a2dismod php5.* to disable the mod
after running the two commands restart your apache2 server
using sudo systemctl restart apache2
The Apache loads the php5_module library in /etc/apache2/mods-available/php5.load.
LoadModule php5_module /usr/lib/apache2/modules/libphp5.so
If you know the loactions of your alternative libraries you can change them in this file.
After editing you need to restart your apache. sudo service apache2 restart or sudo systemctl restart apache2.service
Had the same issue on ubuntu16.
ls -l /etc/apache2/mods-available/php7* ,
showed 2 versions -
/etc/apache2/mods-available/php7.0.conf
/etc/apache2/mods-available/php7.2.conf
Deleted the /etc/apache2/mods-available/php7.0.conf, restarted apache2, and phpinfo() via apache2 showed php7.2

How to resolve this error I got after PHP version upgrade “The apache2 configtest failed.”?

I'm using ubuntu Linux 12.04 LTS on my machine. I was using PHP 5.3.10 Now I upgraded to PHP 5.5.18 by using few commands on terminal. After I upgraded to latest PHP version I checked the version by using command php -v. It shown me the PHP version is 5.5.18.
But when I tried to access one directory from the folder "www" i.e. document root I'm getting error "Unable to connect" in browser. When I enter only localhost in address bar "It Works" is the message appearing.
So I tried to restart the apache server ny using following command :
sudo service apache2 restart
then I got following error :
* Restarting web server apache2 [fail]
* The apache2 configtest failed.
Output of config test was:
apache2: Syntax error on line 214 of /etc/apache2/apache2.conf: Could not open configuration file /etc/apache2/httpd.conf: No such file or directory
Action 'configtest' failed.
The Apache error log may have more information.
After reading this message I go to the file /etc/apache2/httpd.conf and checked line no. 214 there I got found following statement written :
Include httpd.conf
So can someone please help me in working the thing as it is like previous for me? Please suggest me the ways I can fix this issue.
Thanks on advance.
it also woked for me
sudo a2dismod php7.0
Module php7.0 disabled.
To activate the new configuration, you need to run:
service apache2 restart
mr#mr ~/Desktop $ sudo service apache2 restart
* Restarting web server apache2
just do this:
a2dismod php5
OR
a2dismod php7.0
Check if two symbolic link there for php same version [cd /etc/apache2/mods-enabled/]
php7.load -> ../mods-available/php7.load
php7.load -> ../mods-available/php7.0.load
I have removed one of them according to my requirement
Check available modes in [/etc/apache2/mods-available/]
Php7.0.load
Php7.load
I have removed one of them [php7.load] Enable on of the mode restart
apache server

Categories