Score:0

It looks like Apache2 fails to start

us flag

Sorry but i am new to Sysadmin stuff and really new to Linux (big noob) so i am asking you guys for help because i have no idea what is causing this (as i have already stated i am really new to Linux). I accidently removed (lucky me...) stuff with tasksel while trying to install GUI and then reinstalled some of them (atleast the ones i could remember). What i have right now is that apache2 fails to start:

fails to start

and syntax error on line 146 of /etc/apache2/apache2.conf looks like

this

The third error in /etc/apache2/mods-enabled/php7.1.load looks like

this Indeed there is no such file as "libphp7.1" in /usr/lib/apache2/modules/ only "libphp8.1" (sorry about screenshots new here) can anyone please tell me what i should do now? Change config file from 7.1 to 8.1 or just install 7.1?

Ajurna avatar
pe flag
check if the libphp7.1.so file is in that location. it's saying it cant find that file.
in flag
And please dont't post screenshots of text that you could just copy&paste. You are just making it harder to get the information.
in flag
I would advise against using 7.1, it [already reached it's end of life](https://www.php.net/supported-versions.php) and does not receive any security fixes anymore. If you still need PHP7 you need 7.4, which reaches it's end of life this November. Otherwise I'd go with 8.1.
Score:1
cn flag

Most likely is that your php version changed in your system (applicable for Debian/Ubuntu and derivatives, in other distros some paths may vary), but not in your Apache configuration, run:

php -v 

Verify what version is loading, by running:

ls -l /etc/apache2/mods-enabled/php*

then if your version differs from that loading by Apache, supposing result is

lrwxrwxrwx 1 root root 29 ago 17 12:19 php7.4.conf -> ../mods-available/php7.4.conf
lrwxrwxrwx 1 root root 29 ago 17 12:19 php7.4.load -> ../mods-available/php7.4.load

and your new version is now 8.1, check what modules are available to run with:

ls -l /etc/apache2/mods-available/

-rw-r--r-- 1 root root  855 jun 13 08:43 php7.4.conf
-rw-r--r-- 1 root root  102 jun 13 08:43 php7.4.load
-rw-r--r-- 1 root root  855 ago 15 07:24 php8.1.conf
-rw-r--r-- 1 root root  101 ago 15 07:24 php8.1.load

in listing appear the old ones (not working) and new ones php8.1, run the following to create new symlinks to those new version modules

sudo ln -s /etc/apache2/mods-available/php8.1.conf  /etc/apache2/mods-enabled/php8.1.conf
sudo ln -s /etc/apache2/mods-available/php8.1.load  /etc/apache2/mods-enabled/php8.1.load

remove old symlinks

sudo rm /etc/apache2/mods-enabled/php7.4.*

and restart Apache

sudo service apache2 restart
jm flag
This answer appears to be specific to Debian-type systems. REL derivatives use `/etc/httpd` as the base directory for the apache configurations. `mods-enabled` is also a Debian/Ubuntu command.
Roman Spiak avatar
it flag
while removing sym links with `rm` is completely OK to prevent any mishaps I recommend to remove sym links with `unlink` command.
Score:0
bd flag

libphp-7.1.so is either missing on your system, or in a place not configured in a way that Apache can find it. Likely it was removed during an upgrade of something but hard to tell.

You're finding out PHP is a mess to maintain on a Linux server. Especially on something like Ubuntu LTS (which may or may not be your distro, this is just my perspective) where you get the stability of LTS, but are then caught in a predicament which forces you to stay months to years behind new releases of other software which depend on newer functionality of "package X" to work correctly. Below is how I deal with it on Ubuntu. If you run Redhat, Slack, SuSE or Yggdrasil Linux, this won't be much help.

You can't just install a newer version of PHP without, at some point, running into dependency issues with the OS software. Sometimes these dependencies can run up against MySQL/MariaDB functionality which end can be a super tangled red pill type problem. As one person commented above, sometimes the version of PHP bundled with the standard OS is so far out of date it's unreasonable to use (which is definitely the case with anything less than PHP 8.0, and certainly sketchy with 7.4, as of 3/29/22). Also confusing for new admins because "why would your OS have software available that is so outdated?", right? Ubuntu apparently does backport security issues to LTS releases, but it takes a fair amount of digging to verify a given CVE is actually patched in the LTS packages. Sometimes a fix will be available and already implemented in the tarball/git repo of a given package, but the patch/backport is still waiting on a Ubuntu maintainer to actually roll it into the deb package so you can install it. Going out-of-band and installing software without a repo is treacherous from a security perspective because then you are relying on a manual process to remember to upgrade that OOB package and it never really works out. admins leave, people forget.

Luckly, there's this Debian maintainer Ondřej Surý (more like a wizard, really) from the Czech Repuplic who took it upon himself to put out a repo which includes all the underpinnings for upgrading PHP on Debian/Ubuntu system. You can configure this wonderous repo and upgrade PHP and still have it maintainable. As a bonus, you can upgrade NginX and Apache through his repo as well since some of the newer PHP functionality requires changes to those packages. You can probably find some better instructions at one of the links above, but there are a handful of sites which can walk you through it as well.along with any needed Nginx or Apache stack changes.

One word of caution, before installing the Ondřej Surý repo, get a listing of all the PHP/NginX/Apache packages currently installed (eg: dpkg -l | egrep -i '(apache|nginx|php)' (or some similar incantation of apt aptitude apt-get). The names of these packages DO change sometimes, and the dependencies sometimes bring in a mix of versions of the PHP packages. For instance, there was something that happened with the mbstring package a couple PHP versions ago. It required some manual intervention

Of course, all of this can sometimes be avoided with an OS upgrade (eg: "Crazy Camel" -> "Damaged Dingo") but even then, the latest LTS release may be missing bleeding edge functions that some 3rd party stack needs and you're still in the same boat.

Either way, good luck and don't forget to snapshot your VM before doing anything!

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.