尝试在 Ubuntu 20.04 上安装 Apache2 时出错

问题描述 投票:0回答:1

我尝试安装 Apache2 但遇到以下错误。 如果我在安装 cpanel/whm 之前安装 Apache2,它就可以工作。但是安装capanel/whm后,apache2无法安装。

请帮助我,非常感谢!

root@my-server-ip:~# sudo apt-get install apache2
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  apache2-data apache2-utils
Suggested packages:
  apache2-doc apache2-suexec-pristine | apache2-suexec-custom
The following NEW packages will be installed:
  apache2 apache2-data apache2-utils
0 upgraded, 3 newly installed, 0 to remove and 11 not upgraded.
Need to get 0 B/338 kB of archives.
After this operation, 1,821 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 173660 files and directories currently installed.)
Preparing to unpack .../apache2-data_2.4.41-4ubuntu3.14_all.deb ...
Unpacking apache2-data (2.4.41-4ubuntu3.14) ...
dpkg: error processing archive /var/cache/apt/archives/apache2-data_2.4.41-4ubuntu3.14_all.deb (--unpack):
 trying to overwrite '/usr/share/apache2/error/HTTP_BAD_GATEWAY.html.var', which is also in package ea-apache24 2.4.57-3+4.1.cpanel
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Preparing to unpack .../apache2-utils_2.4.41-4ubuntu3.14_amd64.deb ...
Unpacking apache2-utils (2.4.41-4ubuntu3.14) ...
dpkg: error processing archive /var/cache/apt/archives/apache2-utils_2.4.41-4ubuntu3.14_amd64.deb (--unpack):
 trying to overwrite '/usr/bin/ab', which is also in package ea-apache24-tools 2.4.57-3+4.1.cpanel
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Preparing to unpack .../apache2_2.4.41-4ubuntu3.14_amd64.deb ...
Unpacking apache2 (2.4.41-4ubuntu3.14) ...
dpkg: error processing archive /var/cache/apt/archives/apache2_2.4.41-4ubuntu3.14_amd64.deb (--unpack):
 trying to overwrite '/usr/sbin/apachectl', which is also in package ea-apache24 2.4.57-3+4.1.cpanel
Errors were encountered while processing:
 /var/cache/apt/archives/apache2-data_2.4.41-4ubuntu3.14_all.deb
 /var/cache/apt/archives/apache2-utils_2.4.41-4ubuntu3.14_amd64.deb
 /var/cache/apt/archives/apache2_2.4.41-4ubuntu3.14_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
ubuntu apache2 cpanel
1个回答
0
投票

你可以试试

sudo apt-get clean
sudo apt-get update
sudo apt install apache2
sudo apt-get -f install
  or you could install through source
Download and get utilities:
# apt install build-essential libssl-dev libexpat-dev libpcre3-dev libapr1-dev libaprutil1-dev

Download the Apache source code under the /usr/local/src/ directory. Unzip the archive file and get inside the directory.

Change the directory to src
# cd /usr/local/src/

Use wget to download the Apache source code package
# wget https://dlcdn.apache.org//httpd/httpd-2.4.57.tar.bz2

Unzip the downloaded package. Package will be unzipped into a directory
# tar -xf httpd-2.4.57.tar.bz2

Change the directory
# cd httpd-2.4.57

Build the installation package from the source using the configuration command as shone here.

Create a new directory for the installation. We can’t install Apache in the same directory we have the source.
# mkdir /usr/local/apache2.4.57

Use configure command to build the installation package. Specify the installation directory with –prefix parameter.
# ./configure –prefix=/usr/local/apache2.4.57 –enable-shared=max

You can install the package upon the successful build. You should see the summary of the build after the successful completion.

Run this make and make install commands to install the Apache server on Ubuntu.

# make && make install

You can start, stop, restart the Apache server with apachectl command from its bin directory.

# /usr/local/apache2.4.57/bin/apachectl start
# /usr/local/apache2.4.57/bin/apachectl stop
# /usr/local/apache2.4.57/bin/apachectl restart

Run this command to check the status of the Apache service.

# ps -ef | grep apache2
© www.soinside.com 2019 - 2024. All rights reserved.