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

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

Related

PHP is hanging only after server reboot

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.

phpmyadmin - extension mysqli is missing [duplicate]

I have a problem with phpmyadmin on ubuntu 12.04.
I have already installed apache2, php5, mysql and phpmyadmin.
The phpinfo(); script, don't show nothing about mysqli or mysql extension.
When I try start phpmyadmin this error appear:
----
**phpMyAdmin - Error**
-------
**The mysqli extension is missing. Please check your PHP configuration.**
----
In the php.ini file, I uncommented extension=mysql.so line, but doesn't work...
Anyone have another posible solution?
Latest phpMyAdmin versions require mysqli extension and will no longer work with mysql one (note the extra "i" at the end of its name).
For PHP 7.3
sudo apt-get install php7.3-mysqli
For PHP 8
sudo apt-get install php8.0-mysqli
Will install package containing both old one and the new one, so afterwards all you need to do is to add
extension=mysqli.so
in your php.ini, under the subject Dynamic Extensions.
Restart apache:
sudo systemctl restart apache2
Authenticate if needed and press enter.
Should be done! If problem still occurs remove the browser cache.
sudo apt-get install php5-mysql
sudo apt-get install php5-mysqlnd
try both of alternatively it works for me
If you run PHPMyAdmin on localhost uncomment in file /etc/php5/apache2/php.ini this line:
mysqli.allow_local_infile = On
Restart Apache:
sudo /etc/init.d/apache2 restart
Just restart the apache2 and mysql:
apache2: sudo /etc/init.d/apache2 restart
mysql: sudo /etc/init.d/mysql restart
then refresh your browser, enjoy phpmyadmin :)
I tried a lot of the answers and none of them seemed to work because php7.0 is not the default.
sudo apt-get upgrade
seemed to do the job for me but I had to reinstall php7.0 and phpmyadmin after that:
sudo apt-get install php7.0 php7.0-mysql
sudo apt-get install apache2 apache2-mod-php7.0
sudo apt-get install phpmyadmin
Hope it helps!
I faced same issue and resolved it by doing following steps:
First check PHP versions. If you have multiple PHP Versions. Suppose you have PHP versions like php7.0, php7.1 and php 7.2 then
run these commands
For PHP7.0
sudo apt-get install php7.0-mysql
sudo apt-get install php7.0-mysqlnd
For PHP7.1
sudo apt-get install php7.1-mysql
sudo apt-get install php7.1-mysqlnd
For PHP7.2
sudo apt-get install php7.2-mysql
sudo apt-get install php7.2-mysqlnd
For PHP7.3
sudo apt-get install php7.3-mysql
sudo apt-get install php7.3-mysqlnd
Edit the ini file and look for mysqli. Uncomment the line by removing ;
for all php versions
extension=mysqli.so
/etc/php/<php.version>/apache2/php.ini
For PHP7.0
sudo nano /etc/php/7.0/apache2/php.ini
For PHP7.1
sudo nano /etc/php/7.1/apache2/php.ini
For PHP7.2
sudo nano /etc/php/7.2/apache2/php.ini
For PHP7.3
sudo nano /etc/php/7.3/apache2/php.ini
and last restart apache server
sudo /etc/init.d/apache2 restart
I solved this problem by editing /usr/local/zend/etc/php.ini.
(found it by doing netstat -nlp ¦ grep apache, then strace -p somepid ¦ grep php.ini).
At the end of the file, I added:
extension=/usr/lib/php5/20090626+lfs/mysql.so
extension=/usr/lib/php5/20090626+lfs/mysqli.so
extension=/usr/lib/php5/20090626+lfs/mcrypt.so
Adding it without the path did not work.
Then after a restart it worked.
For ubuntu user open your terminal and type following command
sudo apt-get install mysql
After that just restart apache2 by typing this
sudo service apache2 restart
refresh you browser and enjoy phhmyadmin
For Ubuntu 20.04 users with php-fpm
I fixed the issue by adding the full path in the php conf:
edit /etc/php/7.4/fpm/conf.d/20-mysqli.ini
and replace
extension=mysqli.so
with:
extension=/usr/lib/php/20190902/mysqli.so
Checking the extension_dir is one of the thing you like to check from phpinfo().In my case it was extension_dir = "./" by default which was wrong. Change it to extension_dir = './ext/' or where all your extension dlls are currently residing.
Just add this line to your php.ini if you are using XAMPP etc. also check if it is already there just remove ; from front of it
extension= php_mysqli.dll
and stop and start apache and MySQL it will work.
You need the MySQLi module. This error usually occurs when manually installing phpMyAdmin.
sudo apt-get install php7.3-mysql
It will return you with.
[Creating config file /etc/php/7.3/mods-available/mysqlnd.ini with new version]
[Creating config file /etc/php/7.3/mods-available/mysqli.ini with new version]
Then.
sudo service apache2 restart.
Then.
Press F5 on your browser.
This worked for me , make a database with a php and mysql script and open up the mysql console and type in create user 'yourName'#'127.0.0.1' and then type in grant all privileges on . to 'yourName'#'127.0.0.1' then open up a browser go to localhost and a database should been made and then go to your phpmyadmin page and you will see it pop up there.
at ubuntu 12.04 i had to change mssql.compatability_mode = On.
put On and works
Since I had this problem following an upgrade, I just disable Apache2-php5
a2dismod php5
and activated php7
a2enmod php7
Hope it may help anybody!
I have encountered the same error on ubuntu and what worked for me was editing 2 lines in /etc/php/7.3/apache2/php.ini
;extension=mysqli to extension=mysqli
and gave the extension variable location to mysqli.so after uncommenting it
extension=/usr/lib/php/20170718/mysqli.so
then restart the service just to make sure
systemctl start mysql
For the record, my system is Ubuntu Server 20.04 and none of the solutions here worked. For me, I installed PHP 7.4 and I had to edit enter code here/etc/php/7.4/apache2/php.ini`.
Within this, search for ;extension=mysqli, uncomment and change mysqli to mysqlnd so it should look like this extension=mysqlnd. I tried using mysqli but I faced the same error as if I didn't enable it but mysqlnd worked for me.
Had the very same problem, but in my case the reason was update of Ubuntu and php version - from 18.04 and php-7.2 up to 20.04 and php-7.4.
The Nginx server was the same, so in my /etc/nginx/sites-available/default was old data:
server {
location /pma {
location ~ ^/pma/(.+\.php)$ {
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}
}
}
I could not get phpmyadmin to work with any of php.ini changes and all answers from this thread, but at some moment I had opened the /etc/nginx/sites-available/default and realised, that I still had old version of php. So I just changed it to
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
and the issue was gone, phpmyadmin magically started to work without any mysqli-file complaint. I even double checked it, but yeap, that's how it works - if you have wrong version for php-fpm.sock in your nginx config file, your phpmyadmin will not work, but the shown reason will be 'The mysqli extension is missing'
I hope my successful answer helps someone in recent times as I had to try many mix-and-matches and then found it:
This solution worked for me on Ubuntu 20.04 Desktop with PHP v7.4, PHP v8.0.7 and MySQL v8.0.25 setup.
What I did was edited /etc/php/7.4/apache2/php.ini and /etc/php/8.0/apache2/php.ini files and replaced
extension=mysqli.so
with
extension=/usr/lib/php/20190902/mysqli.so
in both the files.
Later, restarted both of these (PHP and MySQL) by sudo systemctl restart apache2 and sudo systemctl restart mysql. Refreshed Chrome, and phpMyAdmin responded with the login screen.
(UPDATE: Please check if you have /usr/lib/php/20200930/mysqli.so file as well. I tested this as it looked newer by directory date, and this too worked in both the PHP files as extension=/usr/lib/php/20200930/mysqli.so)

php-gettext installed but not available

I have the following packages installed on Ubuntu 16.04:
apache2 2.4.18-2ubuntu3.1
php-gettext 1.0.11-2build1
gettext 0.19.7-2ubuntu3
php7.0 7.0.15-0ubuntu0.16.04.4
The only mention of gettext when I call phpinfo() is in the module authors section ("GetText = Alex Plotnick"), so I would assume that support has been compiled in correctly.
It seems that gettext isn't loaded properly into PHP, because the following code:
<?php
if ( false === function_exists('gettext') ) {
echo "You do not have the gettext library installed with PHP.";
exit(1);
}
Does indeed print "You do not have the gettext library installed with PHP."
Apart from documentation, the only php-gettext files I have installed are:
/usr/share/php/php-gettext/gettext.inc
/usr/share/php/php-gettext/streams.php
/usr/share/php/php-gettext/gettext.php
I haven't really touched any php or apache config (apart from try and install icingaweb2)
Can anyone see what my issue could be?
Update
More debugging...
me#phoenix:~$ ls /etc/php/7.0/apache2/conf.d/
10-mysqlnd.ini 20-dom.ini 20-intl.ini 20-mbstring.ini 20-pdo_mysql.ini 20-wddx.ini 20-xmlwriter.ini
15-xml.ini 20-imagick.ini 20-ldap.ini 20-mysqli.ini 20-simplexml.ini 20-xmlreader.ini 20-xsl.ini
me#phoenix:~$ sudo a2dismod php5
ERROR: Module php5 does not exist!
me#phoenix:~$ sudo find / -name gettext.so
/usr/lib/php/20151012/gettext.so
/usr/lib/x86_64-linux-gnu/perl5/5.22/auto/Locale/gettext/gettext.so
It should work out of the box after installation. Have you restarted Apache? Try first sudo apache2ctl restart or sudo service apache2 restart on the terminal console. If both should not work on your system, try sudo /etc/init.d/apache2 restart.
Check if there does exist a file /etc/php/7.0/apache2/conf.d/20-gettext.ini (or similar path on your system) containing the line
extension=gettext.so
There must not be a semicolon prepended, otherwise it is commented out. Some installations may also configue that line within the basic php configuration file /etc/php/php/7.0/php.ini, however the debian derivate's way is to use extra files in the conf.d folder.
You can enable PHP modules (e.g. gettext) on the command line
sudo phpenmod -v 7.0 gettext
If this does not work, edit the configuration manually.
Finally restart your Apache service as described above.
Check also if Apache is running the expected PHP version 7.0 with the following line in your PHP page
echo phpversion();
You can enable / disable Apache2 modules from multiple installed PHP versions on the command line
sudo a2dismod php5
sudo a2enmod php7.0
sudo apache2ctl restart

phpmyadmin page shows source code, Ubuntu 16.04 installed with Vagrant and Puphpet

I installed virtualbox and vagrant, then went to https://puphpet.com and downloaded a package with Ubuntu 16.04. The relevant parts of that package are PHP, MySQL and Apache. It works now, I managed to connect to the server and PHP is running correctly (I installed magento on it).
Now I'm trying to install phpmyadmin, however after running the commands:
sudo apt-get install phpmyadmin
sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
sudo a2enconf phpmyadmin.conf
sudo service apache2 restart
When i go to http://{serverIP}/phpmyadmin/ I get the source code of the file that's supposed to be the phpmyadmin login page, like this:
Source
What could be causing this? It can't be that PHP isn't installed correclty, cause I managed to install Magento and it works fine, so what could be the problem?
Edit:
Also in the /etc/apache2/apache.conf file, I added this line at the end of the file:
Include "/etc/phpmyadmin/apache.conf"
Solved it, I needed to run:
sudo apt-get install libapache2-mod-php7.0
I was missing that extension. Also after I installed that extension I got an error saying:
AH00534: apache2: Configuration error: More than one MPM loaded.
I fixed that by runnning:
sudo a2dismod worker
Not sure why this happened.

Extension mysqli is missing, phpmyadmin doesn't work

I have a problem with phpmyadmin on ubuntu 12.04.
I have already installed apache2, php5, mysql and phpmyadmin.
The phpinfo(); script, don't show nothing about mysqli or mysql extension.
When I try start phpmyadmin this error appear:
----
**phpMyAdmin - Error**
-------
**The mysqli extension is missing. Please check your PHP configuration.**
----
In the php.ini file, I uncommented extension=mysql.so line, but doesn't work...
Anyone have another posible solution?
Latest phpMyAdmin versions require mysqli extension and will no longer work with mysql one (note the extra "i" at the end of its name).
For PHP 7.3
sudo apt-get install php7.3-mysqli
For PHP 8
sudo apt-get install php8.0-mysqli
Will install package containing both old one and the new one, so afterwards all you need to do is to add
extension=mysqli.so
in your php.ini, under the subject Dynamic Extensions.
Restart apache:
sudo systemctl restart apache2
Authenticate if needed and press enter.
Should be done! If problem still occurs remove the browser cache.
sudo apt-get install php5-mysql
sudo apt-get install php5-mysqlnd
try both of alternatively it works for me
If you run PHPMyAdmin on localhost uncomment in file /etc/php5/apache2/php.ini this line:
mysqli.allow_local_infile = On
Restart Apache:
sudo /etc/init.d/apache2 restart
Just restart the apache2 and mysql:
apache2: sudo /etc/init.d/apache2 restart
mysql: sudo /etc/init.d/mysql restart
then refresh your browser, enjoy phpmyadmin :)
I tried a lot of the answers and none of them seemed to work because php7.0 is not the default.
sudo apt-get upgrade
seemed to do the job for me but I had to reinstall php7.0 and phpmyadmin after that:
sudo apt-get install php7.0 php7.0-mysql
sudo apt-get install apache2 apache2-mod-php7.0
sudo apt-get install phpmyadmin
Hope it helps!
I faced same issue and resolved it by doing following steps:
First check PHP versions. If you have multiple PHP Versions. Suppose you have PHP versions like php7.0, php7.1 and php 7.2 then
run these commands
For PHP7.0
sudo apt-get install php7.0-mysql
sudo apt-get install php7.0-mysqlnd
For PHP7.1
sudo apt-get install php7.1-mysql
sudo apt-get install php7.1-mysqlnd
For PHP7.2
sudo apt-get install php7.2-mysql
sudo apt-get install php7.2-mysqlnd
For PHP7.3
sudo apt-get install php7.3-mysql
sudo apt-get install php7.3-mysqlnd
Edit the ini file and look for mysqli. Uncomment the line by removing ;
for all php versions
extension=mysqli.so
/etc/php/<php.version>/apache2/php.ini
For PHP7.0
sudo nano /etc/php/7.0/apache2/php.ini
For PHP7.1
sudo nano /etc/php/7.1/apache2/php.ini
For PHP7.2
sudo nano /etc/php/7.2/apache2/php.ini
For PHP7.3
sudo nano /etc/php/7.3/apache2/php.ini
and last restart apache server
sudo /etc/init.d/apache2 restart
I solved this problem by editing /usr/local/zend/etc/php.ini.
(found it by doing netstat -nlp ¦ grep apache, then strace -p somepid ¦ grep php.ini).
At the end of the file, I added:
extension=/usr/lib/php5/20090626+lfs/mysql.so
extension=/usr/lib/php5/20090626+lfs/mysqli.so
extension=/usr/lib/php5/20090626+lfs/mcrypt.so
Adding it without the path did not work.
Then after a restart it worked.
For ubuntu user open your terminal and type following command
sudo apt-get install mysql
After that just restart apache2 by typing this
sudo service apache2 restart
refresh you browser and enjoy phhmyadmin
For Ubuntu 20.04 users with php-fpm
I fixed the issue by adding the full path in the php conf:
edit /etc/php/7.4/fpm/conf.d/20-mysqli.ini
and replace
extension=mysqli.so
with:
extension=/usr/lib/php/20190902/mysqli.so
Checking the extension_dir is one of the thing you like to check from phpinfo().In my case it was extension_dir = "./" by default which was wrong. Change it to extension_dir = './ext/' or where all your extension dlls are currently residing.
Just add this line to your php.ini if you are using XAMPP etc. also check if it is already there just remove ; from front of it
extension= php_mysqli.dll
and stop and start apache and MySQL it will work.
You need the MySQLi module. This error usually occurs when manually installing phpMyAdmin.
sudo apt-get install php7.3-mysql
It will return you with.
[Creating config file /etc/php/7.3/mods-available/mysqlnd.ini with new version]
[Creating config file /etc/php/7.3/mods-available/mysqli.ini with new version]
Then.
sudo service apache2 restart.
Then.
Press F5 on your browser.
This worked for me , make a database with a php and mysql script and open up the mysql console and type in create user 'yourName'#'127.0.0.1' and then type in grant all privileges on . to 'yourName'#'127.0.0.1' then open up a browser go to localhost and a database should been made and then go to your phpmyadmin page and you will see it pop up there.
at ubuntu 12.04 i had to change mssql.compatability_mode = On.
put On and works
Since I had this problem following an upgrade, I just disable Apache2-php5
a2dismod php5
and activated php7
a2enmod php7
Hope it may help anybody!
I have encountered the same error on ubuntu and what worked for me was editing 2 lines in /etc/php/7.3/apache2/php.ini
;extension=mysqli to extension=mysqli
and gave the extension variable location to mysqli.so after uncommenting it
extension=/usr/lib/php/20170718/mysqli.so
then restart the service just to make sure
systemctl start mysql
For the record, my system is Ubuntu Server 20.04 and none of the solutions here worked. For me, I installed PHP 7.4 and I had to edit enter code here/etc/php/7.4/apache2/php.ini`.
Within this, search for ;extension=mysqli, uncomment and change mysqli to mysqlnd so it should look like this extension=mysqlnd. I tried using mysqli but I faced the same error as if I didn't enable it but mysqlnd worked for me.
Had the very same problem, but in my case the reason was update of Ubuntu and php version - from 18.04 and php-7.2 up to 20.04 and php-7.4.
The Nginx server was the same, so in my /etc/nginx/sites-available/default was old data:
server {
location /pma {
location ~ ^/pma/(.+\.php)$ {
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}
}
}
I could not get phpmyadmin to work with any of php.ini changes and all answers from this thread, but at some moment I had opened the /etc/nginx/sites-available/default and realised, that I still had old version of php. So I just changed it to
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
and the issue was gone, phpmyadmin magically started to work without any mysqli-file complaint. I even double checked it, but yeap, that's how it works - if you have wrong version for php-fpm.sock in your nginx config file, your phpmyadmin will not work, but the shown reason will be 'The mysqli extension is missing'
I hope my successful answer helps someone in recent times as I had to try many mix-and-matches and then found it:
This solution worked for me on Ubuntu 20.04 Desktop with PHP v7.4, PHP v8.0.7 and MySQL v8.0.25 setup.
What I did was edited /etc/php/7.4/apache2/php.ini and /etc/php/8.0/apache2/php.ini files and replaced
extension=mysqli.so
with
extension=/usr/lib/php/20190902/mysqli.so
in both the files.
Later, restarted both of these (PHP and MySQL) by sudo systemctl restart apache2 and sudo systemctl restart mysql. Refreshed Chrome, and phpMyAdmin responded with the login screen.
(UPDATE: Please check if you have /usr/lib/php/20200930/mysqli.so file as well. I tested this as it looked newer by directory date, and this too worked in both the PHP files as extension=/usr/lib/php/20200930/mysqli.so)

Categories