Error while trying to install php module for apache2 - php

Initially the problem was PHP files on my server were displayed as plain text(the whole code was shown). So I found out by investigating that the MIME type has to be added to the /etc/mime.types , so I did that and also restarted my server but that didn't help solve the issue so on further investigation, I found out from here that we needed php5 module enabled and on running the apachectl -M, I couldn't find the php5 module listed. So I tried installing it and this was the outcome of it :
admin#vm:~$ sudo apt-get install php5
...
php5_invoke pdo: already enabled for apache2 SAPI
dpkg: error processing package libapache2-mod-php5 (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
libapache2-mod-php5
E: Sub-process /usr/bin/dpkg returned an error code (1)
admin#vm:~$ sudo apt-get install libapache2-mod-php5
...
dpkg: error processing package libapache2-mod-php5 (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
libapache2-mod-php5
E: Sub-process /usr/bin/dpkg returned an error code (1)
I also need to mention that I created 2 virtual hosts for the sites. I am not sure what is wrong. Could some one help me on this?

This is not a proper solution but I re-installed Apache and it worked fine:
$ sudo apt-get purge apache2
$ sudo apt-get purge php5 libapache2-mod-php5
$ sudo apt-get purge autoremove
$ sudo apt-get install apache2 libapache2-mod-php5 php5

the package libapache2-mod-php5 comprise libphp5.so which locates at /usr/lib/apache2/modules, and php5.conf/php5.load which locate at /etc/apache2/mods-availables.
thus you could get the three files, and copy to corresponding position.
And, you should link, using ln -s, php5.conf/load to /etc/apache2/mods-enables, thus apached could find the configuration file and load the libphp5.so.
I got the same problem and resolve it

Related

Why is showes error processing package mysql-server-8.0 (--configure)?

I'm new at PHP Laravel and I'm setting up Laravel by downloading the packages and Xampp in Lubuntu. When I download mysql by runing the command: sudo apt install mysql-server it shows me an error:
^[ORdpkg: error processing package mysql-server-8.0 (--configure):
installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-server-8.0; however:
Package mysql-server-8.0 is not configured yet.
dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
Processing triggers for systemd (245.4-4ubuntu3.11) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
Errors were encountered while processing:
mysql-server-8.0
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
I have also tried to remove the mysql, upgrade and update sudo apt install and to install it again but still shows the same error.
Hope to help you
sudo apt-get clean
sudo apt-get purge 'mysql*'
sudo apt-get update
sudo apt-get install -f
sudo apt-get install mysql-server-8.0
sudo apt-get dist-upgrade

Issue installing mysql-server-5.6 on Ubuntu 16.04

I am getting this error message when I try to install mysql-server-5.6: sudo apt-get install mysql-server-5.6:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
mailx tinyca
The following NEW packages will be installed:
mysql-server-5.6
0 upgraded, 1 newly installed, 0 to remove and 25 not upgraded.
Need to get 0 B/6,004 kB of archives.
After this operation, 52.7 MB of additional disk space will be used.
Preconfiguring packages ...
(Reading database ... 75769 files and directories currently installed.)
Preparing to unpack .../mysql-server-5.6_5.6.35-1+deb.sury.org~xenial+0.1_amd64.deb ...
Aborting downgrade from (at least) 5.7 to 5.6.
If are sure you want to downgrade to 5.6, remove the file
/var/lib/mysql/debian-*.flag and try installing again.
dpkg: error processing archive /var/cache/apt/archives/mysql-server-5.6_5.6.35-1+deb.sury.org~xenial+0.1_amd64.deb (--unpack):
subprocess new pre-installation script returned error exit status 1
Errors were encountered while processing:
/var/cache/apt/archives/mysql-server-5.6_5.6.35-1+deb.sury.org~xenial+0.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
mysql-client-5.6 were installed normally.
I first, uninstalled mysql-server-5.7:
sudo apt-get remove dbconfig-mysql
sudo apt-get remove --purge mysql*
sudo apt-get purge mysql*
sudo apt-get autoremove
sudo apt-get autoclean
I added repos using this 2 methods:
sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu trusty universe'
sudo apt-get update
and
sudo add-apt-repository -y ppa:ondrej/mysql-5.6
sudo apt-get update
Notice that I also installed PHP 5.6 without any problem.
Since all my project depend on MCRYPT, I have to install this version in order to it to works well.
I used mysql-server-5.7 but it is not compatible ... datas are not inserted into mysql server.
Your help is needed, thank you in advance.
I think the issue is with the mysql client, because you already have it and it is trying to install it, which is causing the error.
Run this command to cleanup unused libraries:
sudo apt-get autoremove
and then try to install it again

Updating PHP packages on Ubuntu Server 16.04 fails

I'm using Google Cloud Compute Engine for our web servers. We run our webapps on PHP7.2 using Ondřej Surý’s PPA.
We have a startup script to install all the required packages and doing the configuration:
apt install -y apache2 php7.2 php7.2-common php7.2-cli php7.2-mysql php7.2-json php7.2-opcache php7.2-readline php7.2-intl php7.2-mbstring php7.2-zip php7.2-curl php7.2-xml php7.2-memcached php7.2-imagick php7.2-bcmath php7.2-json
a2dismod php7.0
a2enmod php7.2
update-alternatives --set php /usr/bin/php7.2
update-alternatives --set phar /usr/bin/phar7.2
update-alternatives --set phar.phar /usr/bin/phar.phar7.2
update-alternatives --set phpize /usr/bin/phpize7.2
update-alternatives --set php-config /usr/bin/php-config7.2
On the inital setup of the virtual machine everything works and all the packages get installed without problems.
But when we need to install new php7.2-XXX packages or when there are updates of installed packages we always run into configuration errors like the one below:
So when we run apt -y upgrade we end up getting these errors:
Setting up php7.2-common (7.2.20-1+ubuntu16.04.1+deb.sury.org+1) ...
Internal error!
dpkg: error processing package php7.2-common (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of php7.2-curl:
php7.2-curl depends on php7.2-common (= 7.2.20-1+ubuntu16.04.1+deb.sury.org+1); however:
Package php7.2-common is not configured yet.
dpkg: error processing package php7.2-json (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of php7.2-opcache:
php7.2-opcache depends on php7.2-common (= 7.2.20-1+ubuntu16.04.1+deb.sury.org+1); however:
Package php7.2-common is not configured yet.
...
Ending in:
Errors were encountered while processing:
php7.2-common
php7.2-json
php7.2-opcache
php7.2-readline
php7.2-cli
libapache2-mod-php7.2
php7.2
php7.2-bcmath
php7.2-curl
php7.2-gd
php7.2-intl
php7.2-mbstring
php7.2-mysql
php7.2-soap
php7.2-xml
php7.2-zip
E: Sub-process /usr/bin/dpkg returned an error code (1)
What I tried:
rebooting
apt autoremove
apt autoclean
apt clean
re-running our startup script
dpkg --configure php7.2-common resulted in:
Setting up php7.2-common (7.2.20-1+ubuntu16.04.1+deb.sury.org+1) ...
Internal error!
dpkg: error processing package php7.2-common (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
php7.2-common
Luckily our webapps seem to be functioning just fine.
Been looking around for weeks now to find more info on these errors.
I can understand that you are currently experiencing issues while trying to install/update PHP packages, even though your instances seem to be working fine; I would firstly recommend you to force an installation in case that 'package install' was interrupted previously, please try the following command:
sudo apt-get install -f
If you are still unable to install the PHP 7.2 packages, please remove post info files of the troublesome package; you can try removing the files associated to the package in question from /var/lib/dpkg/info.
Due to the fact that you're having issues with all of php7.2, look for the files associated with it:
ls -l /var/lib/dpkg/info | grep -i php7.2
Thereafter try to moving them (temporarily) to another folder (see command example below):
sudo mv /var/lib/dpkg/info/php7.2-.* /tmp
And finally use sudo apt update and you should be able to install software as usual. Please let me know the results.
I'll be waiting for your response!
Francisco Z.

E: Sub-process /usr/bin/dpkg returned an error code (1)

While trying to uninstall php7.0, I got the following error:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'php7.0' is not installed, so not removed
The following packages were automatically installed and are no longer required:
linux-headers-4.4.0-92 linux-headers-4.4.0-92-generic linux-headers-4.4.0-93 linux-headers-4.4.0-93-generic linux-headers-4.4.0-96
linux-headers-4.4.0-96-generic linux-image-4.4.0-92-generic linux-image-4.4.0-93-generic linux-image-4.4.0-96-generic
linux-image-extra-4.4.0-92-generic linux-image-extra-4.4.0-93-generic linux-image-extra-4.4.0-96-generic
linux-signed-image-4.4.0-92-generic linux-signed-image-4.4.0-93-generic linux-signed-image-4.4.0-96-generic
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 46 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up libapache2-mod-php7.0 (7.0.22-0ubuntu0.16.04.1) ...
dpkg: error processing package libapache2-mod-php7.0 (--configure):
subprocess installed post-installation script returned error exit status 1
No apport report written because the error message indicates its a followup error from a previous failure.
dpkg: dependency problems prevent configuration of libapache2-mod-php:
libapache2-mod-php depends on libapache2-mod-php7.0; however:
Package libapache2-mod-php7.0 is not configured yet.
dpkg: error processing package libapache2-mod-php (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
libapache2-mod-php7.0
libapache2-mod-php
E: Sub-process /usr/bin/dpkg returned an error code (1)
I used the following command:
sudo apt-get remove php7.0
I searched the whole internet and tried all the solutions but did not got the right solution.
This is mostly because some package or dependency got stuck in package manager.
Try the following commands (with sudo):
apt-get purge
apt-get --autoremove
apt-get --autoclean
Then try uninstalling php7.0 using the following command:
apt-get --purge remove php7.0

Call to undefined function utf8_decode

I looked at other SO answers here and here about this error: FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Call to undefined function utf8_decode
Both answers say that installing php-xml will fix the error. But that didn't work. I ran sudo apt install php-xml which installed both php-xml and php7.0-xml and I restarted php-fpm and nginx. But I still get the same error.
Also checked function_exists('utf8_decode') and it returns false. So the error is obviously thrown when utf8_decode is called.
The server is Ubuntu 16.04 and PHP 7.0. Here's the phpinfo output (PDF): https://drive.google.com/file/d/0B3GpdAvwm4fOaWMwb0JkTFQyb0U/view?usp=sharing
OK so I figured it out. This was related to missing files in /etc/php/7.0/mods-available/
Normally there should be an xml.ini file there but that file was missing because of how I had installed, uninstalled and re-installed PHP. That operation was not done cleanly. After installing PHP from the PPA I had uninstalled it, deleted many files from /etc/php/ (which is not recommended. Use apt-get purge instead).
So long story short, this worked:
sudo apt-get purge php-xml php7.0-xml
sudo apt-get install php-xml
Run php -v to check the version of PHP.
If you're running version is 5.6, the solution is as follows:
sudo apt-get install php5.6-mbstring php5.6-mcrypt php5.6-mysql php5.6-xml
Otherwise, run the following:
sudo apt-get install php7.2-mbstring php7.2-mcrypt php7.2-mysql php7.2-xml
looking for the modules that I have installed in php
php -m | grep -i xml
after I run this command
yum --enablerepo remi install php-xml
and restart apache
sudo service httpd restart

Categories