PHP broken (by me) Websites all down

I tried to upgrade the php on my apache web server so ran:

root@xxxxx:~# a2enmod php7.3
Considering dependency mpm_prefork for php7.3:
Considering conflict mpm_event for mpm_prefork:
Considering conflict mpm_worker for mpm_prefork
Module mpm_prefork already enabled
Considering conflict php5 for php7.3:
Module php7.3 already enabled

Then ran

root@xxxxx:~# systemctl restart apache2
Job for apache2.service failed because the control process exited with error code.
See “systemctl status apache2.service” and “journalctl -xe” for details.
root@xxxxx:~#

Looked at systemctl status apache2.service and journalctl -xe which gave these outputs:

root@xxxxx:~# systemctl status apache2.service
apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2020-03-19 22:57:15 CET; 11min ago
Process: 26628 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)
Mar 19 22:57:15 xxxxx.xxxxx systemd[1]: Starting The Apache HTTP Server…
Mar 19 22:57:15 xxxxx.xxxxx apachectl[26628]: apache2: Syntax error on line 140 of /etc/apache2/apache2.conf: Syntax error on line 3 of /etc/apache2/mods-enabled/php7.2.load: Cannot load /usr/lib/apache2/
Mar 19 22:57:15 xxxxx.xxxxx apachectl[26628]: Action ‘start’ failed.
Mar 19 22:57:15 xxxxx.xxxxx apachectl[26628]: The Apache error log may have more information.
Mar 19 22:57:15 xxxxx.xxxxx systemd[1]: apache2.service: Control process exited, code=exited status=1
Mar 19 22:57:15 xxxxx.xxxxx systemd[1]: Failed to start The Apache HTTP Server.
Mar 19 22:57:15 xxxxx.xxxxx systemd[1]: apache2.service: Unit entered failed state.
Mar 19 22:57:15 xxxxx.xxxxx systemd[1]: apache2.service: Failed with result ‘exit-code’.

root@xxxxx:~# journalctl -xe
Mar 19 23:09:01 xxxxx.xxxxx CRON[30180]: pam_unix(cron:session): session opened for user root by (uid=0)
Mar 19 23:09:01 xxxxx.xxxxx CRON[30181]: pam_unix(cron:session): session opened for user root by (uid=0)
Mar 19 23:09:01 xxxxx.xxxxx CRON[30182]: (root) CMD ( [ -x /usr/lib/php/sessionclean ] && if [ ! -d /run/systemd/system ]; then /usr/lib/php/sessionclean; fi)
Mar 19 23:09:01 xxxxx.xxxxx CRON[30181]: pam_unix(cron:session): session closed for user root
Mar 19 23:09:01 xxxxx.xxxxx CRON[30183]: (root) CMD ( [ -x /usr/lib/php5/sessionclean ] && /usr/lib/php5/sessionclean)
Mar 19 23:09:02 xxxxx.xxxxx CRON[30180]: pam_unix(cron:session): session closed for user root

I cannot see anything to investigate in journalctl -xe but systemctl status apache2.service refers to two syntax errors in two files.

Line 140 of /etc/apache2/apache2.conf is:

137 LogLevel warn
138
139 # Include module configuration:
140 IncludeOptional mods-enabled/.load
141 IncludeOptional mods-enabled/
.conf

Line 3 of /etc/apache2/mods-enabled/php7.2.load is:

1 # Conflicts: php5
2 # Depends: mpm_prefork
3 LoadModule php7_module /usr/lib/apache2/modules/libphp7.3.so

When I look at /usr/lib/apache2/modules/. There is libphp7.4.so but not libphp7.3.so

I tried to go back to the previous version (7.0) no luck. I tried to move to the 7.4 version, no luck.

I simply do not know enough about php to interpret what is going on. Can anyone help me please? All websites are down as apache will not run.

Thanks

Geoff

Well, did you back up your system before you upgraded it? That is ALWAYS the first step when upgrading servers. Also, is it a live server online somewhere, a local server you own or a shared online service like GoDaddy’s? Lastly, one other question, did you power-cycle the server?

I think it might be stating that you had running CRON jobs that were still open and therefore Apache could not restart. Did you shut down all of your CRON jobs before upgrading? All programs and CRON jobs need to be closed before you make a large upgrade like this.

And, if you are upgrading PHP from 5 to 7, a lot of your sites may not work anyways unless you updated the code in all of them to work with 7.

Not sure if any of this helped…

****EDIT: How did you start this upgrade? If you did not download PHP7.3, you can not install it anywhere. Did you find those commands on another tutorial? If so what is it…

Hi ErnieAlex,

This is a private vps that I am trying to set up before moving my sites to it so there is nothing there that is “Live” in the sense that it is used by others.

I have backups and if necessary I will start from scratch and rebuild the entire server, even change from Debian to CentOS if necessary but would like to understand why this is not working. PHP is a bit of a black box as one version to another appears to change the modules and the locations of .ini files so I am finding it a bit difficult to navigate.

I did reboot the server before trying to make the change and have also done so since to see if it would help but no change.

I have not set up any cron jobs but there are some generated automatically (I am using virtualmin) but I did not see anywhere the need to stop cron jobs. I can disable them all through virtualmin if necessary.

My problem is that my server gives:

php -v
PHP 7.3.15-4+0~20200224.55+debian9~1.gbpbea824 (cli) (built: Feb 24 2020 18:39:46) ( NTS )
Copyright © 1997-2018 The PHP Group

but apache2 was giving PHP 7.0.33 and I was trying to align them both by upgrading the apache php version. Virtualmin uses a template to generate websites and I used the script that should have used it. Despite this it does not use 7.3 but installs 7.0 and I think it is apache that is overriding the template. Hence my decision to upgrade apache.

Every little helps!

Any more ideas I can try?

Well, if you are running under Debian, then you have to install them slightly differently. First, you need to update Debian to the latest version. You need this done first so that you can use commands not in the older versions. Then, using newer commands, you can have it install the 7.3 repository. Once that is in place, you can actually update the PHP to 7.3 by installing the libraries and systems.

Instead of trying to walk you thru it myself, here is a tutorial on the steps needed. Save me repeating it all to you. It also has a tutorial link in case you have already moved to CentOS. But, this one is for Debian…

I think it will help you out! Good luck, Ernie Installing PHP7.3 on Debian8 or Debian9

Thanks Ernie.

I will walk through that over the weekend and let you know how I got on.

Geoff

Even quicker, a late night session.

PHP7.3 is already installed on the server and the server tells me it is running 7.3. however, apache was running 7.0 and when I tried to change it to 7.3 my problems started.

So, I purged the versions showing in virtualmin that I am not using, 5.6, 7.0, 7.1 and 7.2 as I do not want to run any legacy sites.

As soon as I had purged them, I was able to restart apache. I did not believe it at first as it was so fast but my sites are back up and running so that part of the problem is cured. Thanks for pointing me in the right direction.

One last question, should I upgrade to PHP7.4? Is there any advantage? Or should I quit while I am ahead!

Geoff

Wow, so happy you got it back up and running… I was not really clear what the issue was, but nice you solved it.

No, I have several sites still on 5.6 and others on 7.1… Looking at the minor differences in 7.4, I think it is not important to move to it. If all of your sites are up and running on 7.3, I would stay there for now.

Oh, also, you might want to make an image of the drive now, so you have a full backup to get back to if more issues. Congrats…

Thanks Ernie. Can Challenge your knowledge a bit more? I purged 5.6, 7.0, 7.1 and 7.2 from my server last night but they are all still listed on my virtualmin server. Do you know if virtualmin needs any of these to run and if not, how do I remove the listing of them and all the modules? I have rebooted the server but it makes no difference.

Will stick with 7.3 as you suggest.

Thanks again,

Geoff

Well, Geoff, I do not use Virtualmin, but, basically it is a similar to Virtual-PC for Windows. It lets you create virtual machines on your system. Then, you basically have duplicate systems or duplicate servers running. Since most servers allow multiple websites on them, I am not sure why you would need to use it. Well, let’s talk about both versions.

On a standard server with multiple websites on it, you just keep them in different folders and set up them up as sub-domains. They all use the same server. MySQL databases for each can be created and named differently. They are not really separated servers since the same system handles running them.
So, they share the memory, hard drives, cpu’s, etc.

On a virtual server using something like Virtualmin, it basically creates a separate server system but, since it runs on an emulator, it also uses all of the memory, hard drives, cpu’s, etc. There is no speed improvement since it is emulated, it actually might be just a slight bit slower. But, the advantage is that the second, third, etc servers appear as just one server which sometimes make it easier to manage. But, you also can have other versions of PHP running for testing or running older software.

Some old software does not run on 7.4 or 7.? … So, that would be a reason to use an emulator or virtual server. But, all of this depends on what you are attempting to do. If it is all your personal software, update it all so it works with at least 7.0. That way you are forward compatible. There is very little difference in all of the 7’s versions. Each version creates new functions, drops some and usually finds ways to improve the speed of PHP. But, sometimes this is annoying as they get rid of commands that are used a lot. Then, you have to replace them with the newer versions. Like in 7.4 they don’t use the array_merge command, instead you use an odder “…” command to create a “spread” to create the merged array. I like the old command better myself. Gets confusing to have to learn new ways all of the time.

The 7 in 7.0 or 7.4 is a major upgrade number. The .0 .1 .4, etc, is a minor upgrade number. So, any 7.? version will be roughly the same. From what I have read so far, 5.6 is the one to use for older code and 7.2 for the newer versions. 7.3 or 7.4 would keep you up to date as long as you understand the changes and read up on them and alter all your code in all your servers.

So, in my humble opinion, it is probably best to keep up to date if possible. This would require reading all changes in PHP levels. I would suggest studying them BEFORE you update your server(s), though. You would need to edit all the code on them to work with the new version’s of code.

You said you have a private VPS, which is the same as Virtualmin. This means you have multiple servers running on one server. Having them all with the same PHP level makes it much easier to program for them. Just one PHP version to learn and code for. Here is a site which is for a Wordpress company, that explains the changes in 7.4. I picked this one since the list is easy to read and gives you some idea on the code changes. As one example I mentioned, if you use array_merge() functions, you would need to change these on all your sites to the newer “spread” version. 7.4 upgrades

Well, Geoff, sorry if this was a long post, but, wanted to explain what is going on with your comments you gave me. Hope this helps somewhat. Maybe it did not. Ask away if you have more questions…

Ernie,

Thanks for taking the time to write. The VPS is ultimately to house my (very few) private servers and frankly for me to play with. It will also house some community projects as internets sites here in France are still a little backward in design and content management and I hope I can offer them something better.

I am not interested in older versions of anything so Iiwll take your first advice and stick with 7.3 for now as it is working on both Vmin and Apache. I will read up about 7.4 but all probably wait for 8!

I feel a lot more comfortable with PHP now (I have worked with it for years but through people working for me and a little knowledge is a dangerous thing) and it s reassuring to know that the community here is so responsive. If I need more PHP help, this will be my first point of call.

On the Vmin issues, I will port them to the Vmin forums where they are more appropriate. I only asked in case you were a user.

Just so you know I follow the sub-server model in general which is a bit like the subdomain model found with most hosters. Subdomains end up in a directory in the main public-html folder of the server while sub-domains (even though they are built at top level in their environment) reside in a separate domains folder in the main server structure but have their own public-html folder and management structure. It is relatively simple to navigate around and as I say, I only have a handful of websites. The only separated virtual server I have built is my primary domain name server as I prefer to be able to control that myself rather than through my hoster (bluehost.com).

If I can ever offer you help in return I would be glad to but my technical speciality is in red wine from Bordeaux which is not generally compatible with computers!

My thanks again,

Geoff

Oh, no! Wine DOES go with computers! Ha! Just don’t pour it on them…

Sounds like you have it all under control. Since it sounds like you are the only programmer, it is fine whichever version you use since you can learn the fine points of that version. The new major version of PHP which is “8” is due out at the end of 2020. So, not really long to wait for that. I do suggest waiting about 5 or 6 months after it is first out so the bugs are gone before upgrading to it. And, of course, make a full backup before you do!

Good luck with it all and we will see you in your next post… Always fun to work on a programming puzzle…

Ernie,

You are right, I had forgotten about the MS emulator WINE!

I did not expect to be writing to you again soon! I have caused another issue myself I believe.

To save space, clear down unwanted files and reduce any chance of Vmin using earlier versions I purged 5.6, 7.0, 7.1 and 7.2 versions of PHP leaving just 7.3 and 7.4 on the machine. I also searched out and removed all files that related to those unwanted versions. When I rebooted yesterday, apache did not start. After investigation, I discovered that I had deleted a (or some?) file(s) that apache was looking for. The one missing reported in systemctl status apache2.service was was /etc/apache2/conf-enabled/php7.0-fpm.conf that /etc/apache2/apache2.conf could not locate.

I do not know if that is the only missing link as it may in turn refer to others and the apache.conf file may also call for others (though I cannot see any listed).

First, is it possible to just replace the file with a base configuration or will it have been amended as I added sites? If it can be replaced, where can I get one?

If I have to remove and reinstall the apache server and my two test websites I can do so but it will be a pain and force me to check other operations like mail etc. but if it has to be done I will do it.

Sorry to be a nuisance but would appreciate it if you could once again come to my aid.

Geoff

BTW, I thought the fpm files were only for Nginx servers not apache? So, why is it calling for it?

Geoff

Well, FPM is the FastCGI Processing Manager and the CONF file is the config for it. So, it IS needed for PHP. You can download the matching PHP install file from here: https://www.php.net/downloads.php
Then, expand it in a temporary folder and copy back any missing files. I would NOT copy all the files, just the ones that are missing. The reason is that files are sometimes altered to fit your installation. Therefore, you would need to just replace the missing ones. Or, just copy off your websites and reinstall it all.

Normally, Geoff, you don’t delete files off of a server unless you know 100% what they do and what other files they might be linked to. Often, you can Google the one file and file out what it is and track down a replacement that way. But, of course, you need to get it from a reliable source such as PHP.net

AND, as I keep telling you, back up the entire disk before you alter your server just in case it fails after your deletions or changes… Hope this helps somehow… Good luck!

Hi Ernie,

I have downloaded and expanded php-7.3.16.tar but cannot find the file php7.0-fpm. I suspect it is built during the install?

I think I have messed the settings up so much that the only option is to start again but when I tried to purge 7.3 and reinstall it it comes up with a load of references for missing files from 5.6,7.0,7.1 etc.

How do I just reinstall the version I want so that it builds from the ground up and reinstalls the files it needs to make apache work? Sorry but I am now in a bit of a pickle over all this.

Geoff

Well, you mentioned you have an Apache server. Therefore, you can do it using a standard install.
You need to have internet access on the server, of course, which you should already have running.
I would install it from the PHP servers in the normal manner. Just go to the sight I posted below.
Select your Apache2.0 or whatever one you are using and follow the step-by-step instructions to get it
installed from scratch. Please remember to backup your site files first. Since they are in folders on
the server, you should be able to copy them with ease, just in case you need to rebuild the Apache, too.
Good luck! https://www.php.net/manual/en/install.php

Ernie,

I wrote you a huge message about the actions I took and the problems that came up and although there was limited success I still kept getting errors so did not waste your time with it.

There is only on item on the server I want to keep (and I can rebuild it if necessary) so I am going to delete everything on the VPS and reinstall from scratch. At least now I am more aware of what can and cannot be done.

I will post agin once it is done to let you know how it went.

Geoff

Sounds like you have a plan. Good luck. Will await the results!

Sponsor our Newsletter | Privacy Policy | Terms of Service