安装Httpd服务
版本说明:
CentOS 7 以上,默认系统是httpd 2.4,CentOS 6 版默认为httpd 2.2
Ubuntu 18.04 默认 Apache/2.4.29
范例:CentOS 8 安装httpd
[root@CentOS8 ~]# yum info httpd
Baseos 3.8 MB/s | 3.9 kB 00:00
AppStream 4.2 MB/s | 4.3 kB 00:00
EPEL 7.1 kB/s | 4.7 kB 00:00
EPEL 1.1 MB/s | 13 MB 00:11
Available Packages
Name : httpd
Version : 2.4.37
Release : 30.module_el8.3.0+561+97fdbbcc
Architecture : x86_64
Size : 1.7 M
Source : httpd-2.4.37-30.module_el8.3.0+561+97fdbbcc.src.rpm
Repository : AppStream
Summary : Apache HTTP Server
URL : https://httpd.apache.org/
License : ASL 2.0
Description : The Apache HTTP Server is a powerful, efficient, and extensible
: web server.
[root@CentOS8 ~]# yum install httpd -y
Last metadata expiration check: 0:00:21 ago on Mon 10 Oct 2022 10:57:38 PM CST.
Dependencies resolved.
=================================================================================================================================================================
Package Architecture Version Repository Size
=================================================================================================================================================================
Installing:
httpd x86_64 2.4.37-30.module_el8.3.0+561+97fdbbcc AppStream 1.7 M
Installing dependencies:
apr x86_64 1.6.3-11.el8 AppStream 125 k
apr-util x86_64 1.6.1-6.el8 AppStream 105 k
centos-logos-httpd noarch 80.5-2.el8 Baseos 24 k
httpd-filesystem noarch 2.4.37-30.module_el8.3.0+561+97fdbbcc AppStream 37 k
httpd-tools x86_64 2.4.37-30.module_el8.3.0+561+97fdbbcc AppStream 104 k
mod_http2 x86_64 1.15.7-2.module_el8.3.0+477+498bb568 AppStream 154 k
Installing weak dependencies:
apr-util-bdb x86_64 1.6.1-6.el8 AppStream 25 k
apr-util-openssl x86_64 1.6.1-6.el8 AppStream 27 k
Enabling module streams:
httpd 2.4
Transaction Summary
=================================================================================================================================================================
Install 9 Packages
Total size: 2.3 M
Installed size: 6.0 M
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
..............
Installed:
apr-1.6.3-11.el8.x86_64 apr-util-1.6.1-6.el8.x86_64
apr-util-bdb-1.6.1-6.el8.x86_64 apr-util-openssl-1.6.1-6.el8.x86_64
centos-logos-httpd-80.5-2.el8.noarch httpd-2.4.37-30.module_el8.3.0+561+97fdbbcc.x86_64
httpd-filesystem-2.4.37-30.module_el8.3.0+561+97fdbbcc.noarch httpd-tools-2.4.37-30.module_el8.3.0+561+97fdbbcc.x86_64
mod_http2-1.15.7-2.module_el8.3.0+477+498bb568.x86_64
Complete!
[root@CentOS8 ~]# systemctl enable httpd
httpd@ httpd.service httpd@.service httpd.socket
[root@CentOS8 ~]# systemctl enable httpd.service --now
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@CentOS8 ~]# httpd -v
Server version: Apache/2.4.37 (centos)
Server built: Nov 4 2020 03:20:37
范例:Ubuntu 1804 安装apache2
tom@ubuntu1804-1:~$ apt install apache2 -y
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?
tom@ubuntu1804-1:~$ sudo apt inst