统信UOS服务器上编译安装httpd服务

277 篇文章 4 订阅
277 篇文章 6 订阅

原文链接:统信UOS服务器上编译安装httpd服务

hello,大家好啊,今天给大家带来一篇在统信UOS服务器上编译安装httpd服务的文章,以及编写systemd服务文件,使用systemctl进行启动、停止的功能操作。
1、打开终端并更新系统

[root@localhost ~]# dnf update -y
UnionTechOS-Server-20-1020-everything                                         5.1 MB/s |  15 MB     00:02    
UnionTechOS-Server-20-1020                                                    2.7 MB/s | 3.8 MB     00:01    
上次元数据过期检查:0:00:02 前,执行于 2023年07月12日 星期三 10时46分22秒。
依赖关系解决。
无需任何处理。
完毕!
[root@localhost ~]# 

img

2、安装必要的开发工具和库

[root@localhost ~]# dnf groupinstall "Development Tools" -y
上次元数据过期检查:0:00:28 前,执行于 2023年07月12日 星期三 10时45分37秒。
没有和组 "huaweijdk-8" 匹配的
依赖关系解决。
==============================================================================================================
 Package                Arch        Version                       Repository                             Size

已安装:
  apr-1.7.0-4.uel20.x86_64                                 apr-util-1.6.1-14.uel20.x86_64                     
  asciidoc-8.6.10-3.uel20.noarch                           autoconf-2.69-30.uel20.noarch                      
  automake-1.16.2-2.uel20.noarch                           byacc-1.9.20200330-1.uel20.x86_64                  
  chrpath-0.16-12.uel20.x86_64                             ctags-5.8-27.uel20.x86_64                          
  diffstat-1.62-3.uel20.x86_64                             gcc-gfortran-7.3.0-20210605.39.uel20.x86_64        
  gettext-devel-0.21-4.uel20.x86_64                        git-2.27.0-4.uel20.x86_64                          
  graphviz-2.44.0-3.uel20.x86_64                           httpd-2.4.43-7.up1.uel20.x86_64                    
  httpd-filesystem-2.4.43-7.up1.uel20.noarch               httpd-help-2.4.43-7.up1.uel20.noarch               
  httpd-tools-2.4.43-7.up1.uel20.x86_64                    intltool-0.51.0-14.uel20.noarch                    
  libgfortran-7.3.0-20210605.39.uel20.x86_64               libquadmath-7.3.0-20210605.39.uel20.x86_64         
  libquadmath-devel-7.3.0-20210605.39.uel20.x86_64         libserf-1.3.9-14.uel20.x86_64                      
  libtool-2.4.6-33.uel20.x86_64                            ltrace-0.7.91-31.uel20.x86_64                      
  ltrace-help-0.7.91-31.uel20.x86_64                       mod_http2-1.15.13-1.uel20.x86_64                   
  patchutils-0.3.4-13.uel20.x86_64                         perl-Error-1:0.17028-1.uel20.noarch                
  perl-Fedora-VSP-0.001-10.uel20.noarch                    perl-Git-2.27.0-4.uel20.noarch                     
  perl-TermReadKey-2.38-2.uel20.x86_64                     perl-XML-Parser-1:2.46-1.uel20.x86_64              
  perl-generators-1.10-11.uel20.noarch                     pesign-0.113-4.uel20.x86_64                        
  rpm-build-4.15.1-28.uel20.x86_64                         source-highlight-3.1.8-24.uel20.x86_64             
  subversion-1.12.2-3.uel20.x86_64                         utf8proc-2.5.0-1.uel20.x86_64                      
  valgrind-1:3.13.0-29.uel20.x86_64                        valgrind-devel-1:3.13.0-29.uel20.x86_64            
  vim-filesystem-2:8.2-1.uel20.noarch                     

完毕!
[root@localhost ~]# 

img

[root@localhost ~]# dnf install apr-devel apr-util-devel pcre-devel zlib-devel openssl-devel -y
上次元数据过期检查:0:01:43 前,执行于 2023年07月12日 星期三 10时45分37秒。
软件包 pcre-devel-8.44-2.uel20.x86_64 已安装。
软件包 zlib-devel-1.2.11-17.uel20.x86_64 已安装。
软件包 openssl-devel-1:1.1.1f-10.uel20.x86_64 已安装。
依赖关系解决。
==============================================================================================================
 Package                 Architecture  Version                  Repository                               Size
==============================================================================================================
安装:
 apr-devel               x86_64        1.7.0-4.uel20            UnionTechOS-Server-20-everything        194 k
 apr-util-devel          x86_64        1.6.1-14.uel20           UnionTechOS-Server-20-everything         74 k
安装依赖关系:
 cyrus-sasl-devel        x86_64        2.1.27-12.uel20          UnionTechOS-Server-20-everything         46 k
 expat-devel             x86_64        2.2.9-2.uel20            UnionTechOS-Server-20-everything         98 k
 gdbm-devel              x86_64        1:1.18.1-1.uel20         UnionTechOS-Server-20-everything         13 k
 openldap-devel          x86_64        2.4.50-7.uel20           UnionTechOS-Server-20-everything         42 k

事务概要
==============================================================================================================
安装  6 软件包

总下载:466 k
安装大小:2.0 M
下载软件包:
(1/6): apr-util-devel-1.6.1-14.uel20.x86_64.rpm                               485 kB/s |  74 kB     00:00    
(2/6): cyrus-sasl-devel-2.1.27-12.uel20.x86_64.rpm                            195 kB/s |  46 kB     00:00    
(3/6): apr-devel-1.7.0-4.uel20.x86_64.rpm                                     744 kB/s | 194 kB     00:00    
(4/6): expat-devel-2.2.9-2.uel20.x86_64.rpm                                   640 kB/s |  98 kB     00:00    
(5/6): gdbm-devel-1.18.1-1.uel20.x86_64.rpm                                   183 kB/s |  13 kB     00:00    
(6/6): openldap-devel-2.4.50-7.uel20.x86_64.rpm                               416 kB/s |  42 kB     00:00    
--------------------------------------------------------------------------------------------------------------
总计                                                                          1.2 MB/s | 466 kB     00:00     
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
  准备中  :                                                                                               1/1 
  安装    : gdbm-devel-1:1.18.1-1.uel20.x86_64                                                            1/6 
  运行脚本: gdbm-devel-1:1.18.1-1.uel20.x86_64                                                            1/6 
install-info: 没有那个文件或目录 for /usr/share/info/gdbm.info.gz

  安装    : expat-devel-2.2.9-2.uel20.x86_64                                                              2/6 
  安装    : cyrus-sasl-devel-2.1.27-12.uel20.x86_64                                                       3/6 
  安装    : openldap-devel-2.4.50-7.uel20.x86_64                                                          4/6 
  安装    : apr-devel-1.7.0-4.uel20.x86_64                                                                5/6 
  安装    : apr-util-devel-1.6.1-14.uel20.x86_64                                                          6/6 
  运行脚本: apr-util-devel-1.6.1-14.uel20.x86_64                                                          6/6 
  验证    : apr-devel-1.7.0-4.uel20.x86_64                                                                1/6 
  验证    : apr-util-devel-1.6.1-14.uel20.x86_64                                                          2/6 
  验证    : cyrus-sasl-devel-2.1.27-12.uel20.x86_64                                                       3/6 
  验证    : expat-devel-2.2.9-2.uel20.x86_64                                                              4/6 
  验证    : gdbm-devel-1:1.18.1-1.uel20.x86_64                                                            5/6 
  验证    : openldap-devel-2.4.50-7.uel20.x86_64                                                          6/6 

已安装:
  apr-devel-1.7.0-4.uel20.x86_64                          apr-util-devel-1.6.1-14.uel20.x86_64                
  cyrus-sasl-devel-2.1.27-12.uel20.x86_64                 expat-devel-2.2.9-2.uel20.x86_64                    
  gdbm-devel-1:1.18.1-1.uel20.x86_64                      openldap-devel-2.4.50-7.uel20.x86_64                

完毕!
[root@localhost ~]# 

img

3、从Apache官方网站下载所需版本的源码

[root@localhost ~]# wget http://www.apache.org/dist/httpd/httpd-2.4.57.tar.gz
--2023-07-12 10:48:10--  http://www.apache.org/dist/httpd/httpd-2.4.57.tar.gz
正在解析主机 www.apache.org (www.apache.org)... 151.101.2.132, 2a04:4e42::644
正在连接 www.apache.org (www.apache.org)|151.101.2.132|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 301 Moved Permanently
位置:https://www.apache.org/dist/httpd/httpd-2.4.57.tar.gz [跟随至新的 URL]
--2023-07-12 10:48:10--  https://www.apache.org/dist/httpd/httpd-2.4.57.tar.gz
正在连接 www.apache.org (www.apache.org)|151.101.2.132|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 302 Found
位置:https://downloads.apache.org/httpd/httpd-2.4.57.tar.gz [跟随至新的 URL]
--2023-07-12 10:48:11--  https://downloads.apache.org/httpd/httpd-2.4.57.tar.gz
正在解析主机 downloads.apache.org (downloads.apache.org)... 135.181.214.104, 88.99.95.219, 2a01:4f8:10a:201a::2, ...
正在连接 downloads.apache.org (downloads.apache.org)|135.181.214.104|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:9773385 (9.3M) [application/x-gzip]
正在保存至: “httpd-2.4.57.tar.gz”

httpd-2.4.57.tar.gz         100%[=========================================>]   9.32M  1.28MB/s  用时 7.6s    

2023-07-12 10:48:19 (1.23 MB/s) - 已保存 “httpd-2.4.57.tar.gz” [9773385/9773385])

[root@localhost ~]# 

img

4、解压源码包

[root@localhost ~]# tar -xzf httpd-2.4.57.tar.gz
[root@localhost ~]# cd httpd-2.4.57/
[root@localhost httpd-2.4.57]# 

img

5、使用以下命令配置源码

[root@localhost httpd-2.4.57]# ./configure --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr --with-apr-util=/usr
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
configure: 
configure: Configuring Apache Portable Runtime library...
configure: 
checking for APR... yes
  setting CC to "gcc"
  setting CPP to "gcc -E"
  setting CFLAGS to "  -pthread"
  setting CPPFLAGS to " -DLINUX -D_REENTRANT -D_GNU_SOURCE"
  setting LDFLAGS to " "
configure: 
configure: Configuring Apache Portable Runtime Utility library...
configure: 
checking for APR-util... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... none needed
checking how to run the C preprocessor... gcc -E
checking for -pcre2-config... no
checking for -pcre-config... no
checking for pcre2-config... pcre2-config
configure: Using external PCRE library from pcre2-config
  setting PCRE_INCLUDES to ""
  setting PCRE_LIBS to "-lpcre2-8"
configure: 
configure: Configuring Apache httpd...
    Server Version: 2.4.57
    Install prefix: /usr/local/apache2
    C compiler:     gcc
    CFLAGS:           -pthread  
    CPPFLAGS:        -DLINUX -D_REENTRANT -D_GNU_SOURCE  
    LDFLAGS:           
    LIBS:             
    C preprocessor: gcc -E

[root@localhost httpd-2.4.57]# 

img

6、编译源码

[root@localhost httpd-2.4.57]# make
Making all in srclib
make[1]: 进入目录“/root/httpd-2.4.57/srclib”
make[1]: 离开目录“/root/httpd-2.4.57/srclib”
Making all in os
make[1]: 进入目录“/root/httpd-2.4.57/os”
Making all in unix
make[2]: 进入目录“/root/httpd-2.4.57/os/unix”
make[3]: 进入目录“/root/httpd-2.4.57/os/unix”
/usr/lib64/apr-1/build/libtool --silent --mode=compile gcc  -pthread      -DLINUX -D_REENTRANT -D_GNU_SOURCE     -I. -I/root/httpd-2.4.57/os/unix -I/root/httpd-2.4.57/include -I/usr/include/apr-1 -I/root/httpd-2.4.57/modules/aaa -I/root/httpd-2.4.57/modules/cache -I/root/httpd-2.4.57/modules/core -I/root/httpd-2.4.57/modules/database -I/root/httpd-2.4.57/modules/filters -I/root/httpd-2.4.57/modules/ldap -I/root/httpd-2.4.57/modules/loggers -I/root/httpd-2.4.57/modules/lua -I/root/httpd-2.4.57/modules/proxy -I/root/httpd-2.4.57/modules/http2 -I/root/httpd-2.4.57/modules/session -I/root/httpd-2.4.57/modules/ssl -I/root/httpd-2.4.57/modules/test -I/root/httpd-2.4.57/server -I/root/httpd-2.4.57/modules/md -I/root/httpd-2.4.57/modules/arch/unix -I/root/httpd-2.4.57/modules/dav/main -I/root/httpd-2.4.57/modules/generators -I/root/httpd-2.4.57/modules/mappers  -prefer-non-pic -static -c unixd.c && touch unixd.lo
/usr/lib64/apr-1/build/libtool --silent --mode=link gcc  -pthread         -o libos.la -static  unixd.lo  
make[3]: 离开目录“/root/httpd-2.4.57/os/unix”
make[2]: 离开目录“/root/httpd-2.4.57/os/unix”

img

7、安装Apache

[root@localhost httpd-2.4.57]# make install
Making install in srclib
make[1]: 进入目录“/root/httpd-2.4.57/srclib”
make[2]: 进入目录“/root/httpd-2.4.57/srclib”
make[2]: 离开目录“/root/httpd-2.4.57/srclib”
make[1]: 离开目录“/root/httpd-2.4.57/srclib”
Making install in os
make[1]: 进入目录“/root/httpd-2.4.57/os”
Making install in unix
make[2]: 进入目录“/root/httpd-2.4.57/os/unix”
make[3]: 进入目录“/root/httpd-2.4.57/os/unix”
make[3]: 离开目录“/root/httpd-2.4.57/os/unix”
make[2]: 离开目录“/root/httpd-2.4.57/os/unix”
make[2]: 进入目录“/root/httpd-2.4.57/os”
make[2]: 离开目录“/root/httpd-2.4.57/os”
make[1]: 离开目录“/root/httpd-2.4.57/os”
Making install in server
make[1]: 进入目录“/root/httpd-2.4.57/server”
Making install in mpm
make[2]: 进入目录“/root/httpd-2.4.57/server/mpm”
Making install in event
make[3]: 进入目录“/root/httpd-2.4.57/server/mpm/event”
make[4]: 进入目录“/root/httpd-2.4.57/server/mpm/event”

img

8、确保Apache已安装成功

[root@localhost httpd-2.4.57]# /usr/local/apache2/bin/apachectl -v
Server version: Apache/2.4.57 (Unix)
Server built:   Jul 12 2023 10:51:52
[root@localhost httpd-2.4.57]# 

img

9、创建Systemd服务文件

[root@localhost httpd-2.4.57]# vi /etc/systemd/system/httpd.service
[root@localhost httpd-2.4.57]# cat /etc/systemd/system/httpd.service
[Unit]
Description=The Apache HTTP Server
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/apache2/bin/apachectl -k start
ExecReload=/usr/local/apache2/bin/apachectl -k graceful
ExecStop=/usr/local/apache2/bin/apachectl -k stop
PrivateTmp=true

[Install]
WantedBy=multi-user.target
[root@localhost httpd-2.4.57]# 

img

10、使用以下命令让systemd重新加载服务文件

[root@localhost httpd-2.4.57]# systemctl daemon-reload
[root@localhost httpd-2.4.57]# systemctl start httpd
[root@localhost httpd-2.4.57]# systemctl enable httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /etc/systemd/system/httpd.service.
[root@localhost httpd-2.4.57]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/etc/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2023-07-12 11:00:35 CST; 12s ago
 Main PID: 55308 (httpd)
    Tasks: 82
   Memory: 27.0M
   CGroup: /system.slice/httpd.service
           ├─55308 /usr/local/apache2/bin/httpd -k start
           ├─55309 /usr/local/apache2/bin/httpd -k start
           ├─55310 /usr/local/apache2/bin/httpd -k start
           └─55311 /usr/local/apache2/bin/httpd -k start

712 11:00:35 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...
712 11:00:35 localhost.localdomain apachectl[55307]: AH00558: httpd: Could not reliably determine the serv>
712 11:00:35 localhost.localdomain systemd[1]: Started The Apache HTTP Server.
[root@localhost httpd-2.4.57]# 

img

11、防火墙放开80端口

[root@localhost httpd-2.4.57]# firewall-cmd --permanent --add-service=http
success
[root@localhost httpd-2.4.57]# firewall-cmd --reload 
success
[root@localhost httpd-2.4.57]# netstat -luntap |grep 80
tcp        0      0 192.168.122.231:22      192.168.122.1:40458     ESTABLISHED 8097/sshd: root [pr 
tcp6       0      0 :::80                   :::*                    LISTEN      55308/httpd         
udp        0      0 0.0.0.0:51998           0.0.0.0:*                           809/avahi-daemon: r 
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           809/avahi-daemon: r 
udp6       0      0 :::46766                :::*                                809/avahi-daemon: r 
udp6       0      0 :::5353                 :::*                                809/avahi-daemon: r 
[root@localhost httpd-2.4.57]# 

img

12、访问查看

截图_选择区域_20230712144154

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
### 回答1: 统信uos是一种基于Linux操作系统,常用于企业级服务器或高性能计算机。在安装软件时,可以使用apt命令来快速地安装软件包及其依赖项。 要在统信uos服务器安装apt,可以按照以下步骤进行操作: 第一步,打开终端或命令行窗口,输入以下命令来确认系统中是否已经安装了apt: apt -v 如果系统已经安装了,将会显示版本信息;如果没有,将会提示“apt命令未找到”的错误信息。 第二步,如果系统中没有apt,可以使用以下命令来安装: yum install apt 这个命令会自动下载并安装apt及其相关的依赖项。在安装过程中会出现类似“是否确认安装”等提示,可以根据需要输入y或n来进行选择。 第三步,安装完成后,就可以使用apt来安装软件包了。例如,如果要安装git: apt install git 这个命令会自动下载并安装git及其相关的依赖项。在安装过程中也会出现类似“是否确认安装”等提示,可以根据需要输入y或n来进行选择。 需要注意的是,安装软件包时需要具有管理员权限。如果使用的是非管理员账户,需要在命令前加上sudo来获取管理员权限,例如: sudo apt install git 此外,apt还可以用来更新已安装的软件包及其依赖项。例如,如果要更新系统中已安装的所有软件包: apt update apt upgrade 这个命令会自动更新所有已安装的软件包及其依赖项。在更新过程中也会出现类似“是否确认更新”等提示,可以根据需要输入y或n来进行选择。 总之,使用apt可以快速方便地在统信uos安装和更新软件包,提高工作效率。 ### 回答2: 统信uos是一种优秀的服务器操作系统,它具有安全、稳定、高效、易用等优点,因此受到了广泛的认可和使用。在统信uos服务器上,apt是一种非常强大的软件包管理工具,可以帮助用户快速安装和管理各种软件包。那么如何在统信uos服务器上使用apt进行软件安装呢? 首先,我们需要在统信uos服务器上打开终端,并输入sudo apt-get update命令来更新软件源。 其次,我们可以使用sudo apt-get install命令来安装需要的软件包,例如我们想安装apache2的话,可以输入sudo apt-get install apache2,之后按照提示完成安装即可。 如果我们想查询一下当前系统中已经安装的软件包,可以使用sudo apt list命令来实现。 另外,我们还可以使用sudo apt-get remove命令来卸载不需要的软件包,例如我们想卸载apache2的话,可以输入sudo apt-get remove apache2,之后按照提示完成卸载即可。 总之,apt是统信uos服务器上非常常用的软件包管理工具,通过合理使用apt,可以帮助我们更高效、更方便地进行软件安装和管理。 ### 回答3: 统信 UOS 服务器是一个基于国产操作系统服务器操作系统,可以在其上进行各种应用程序的部署与运行。在统信 UOS 服务器安装软件可以采用 apt 命令进行安装。 apt 是一个包管理器,可以通过它来安装、更新和卸载软件包。在统信 UOS 服务器上默认安装了 apt,可以使用以下命令来进行安装软件包: 1. 更新软件包列表:sudo apt-get update 2. 搜索软件包:sudo apt-cache search 软件包名称 3. 安装软件包:sudo apt-get install 软件包名称 4. 卸载软件包:sudo apt-get remove 软件包名称 5. 升级系统中已安装的软件:sudo apt-get upgrade 6. 清理系统中已下载的安装包:sudo apt-get clean 需要注意的是,如果您的统信 UOS 服务器无法连接到网络,或者网络不畅,那么 apt 将无法正常工作。此时您需要手动下载相关软件包并在本地进行安装。当然,这一般情况下并不是您的首选方案,因为使用 apt 可以更方便地管理您的软件包。 总之,apt 是一个非常强大的工具,可以为您在统信 UOS 服务器上进行软件包管理提供便利。希望这些简单的安装命令提示能够帮助到您。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

鹏大圣运维

编写不易,还请支持

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值