当前位置: 首页 > news >正文

源码编译安装httpd 2.4,提供系统服务管理脚本并测试(两种方法实现)

  1. 下载 httpd 2.4 源码:

    wget https://dlcdn.apache.org/httpd/httpd-2.4.x.tar.gztar -zxvf httpd-2.4.x.tar.gzcd httpd-2.4.x
    
  2. 配置、编译和安装:

    ./configure --prefix=/usr/local/apache2 --enable-so --enable-ssl --enable-cgi
    makesudo make install
    

实现方法一:使用 Systemd

  1. 创建 Systemd 服务文件 /etc/systemd/system/httpd.service

    [Unit]
    Description=The Apache HTTP Server
    After=network.target[Service]
    Type=forking
    ExecStart=/usr/local/apache2/bin/apachectl start
    ExecReload=/usr/local/apache2/bin/apachectl graceful
    ExecStop=/usr/local/apache2/bin/apachectl stop
    PrivateTmp=true[Install]
    WantedBy=multi-user.target
    
  2. 重新加载 Systemd 守护进程:

    sudo systemctl daemon-reload
    
  3. 启动 httpd 服务:

    sudo systemctl start httpd
    
  4. 测试服务:

    curl http://localhost
    
  5. 查看服务状态:

    sudo systemctl status httpd

使用方法二使用 init 脚本

  1. 创建 /etc/init.d/httpd 脚本:

    #!/bin/sh
    ### BEGIN INIT INFO
    # Provides:          httpd
    # Required-Start:    $local_fs $network
    # Required-Stop:     $local_fs $network
    # Default-Start:     2 3 4 5
    # Default-Stop:      0 1 6
    # Short-Description: Apache HTTP Server
    # Description:       Apache HTTP Server
    ### END INIT INFOHTTPD_PATH=/usr/local/apache2/bin/apachectlcase "$1" instart)$HTTPD_PATH start;;stop)$HTTPD_PATH stop;;restart)$HTTPD_PATH restart;;status)$HTTPD_PATH status;;*)echo "Usage: $0 {start|stop|restart|status}"exit 1;;
    esac
    exit 0
  2. 设置脚本权限:

    sudo chmod +x /etc/init.d/httpd
    
  3. 启动 httpd 服务:

    sudo /etc/init.d/httpd start
    
  4. 测试服务:

    curl http://localhost
    
  5. 查看服务状态:

    sudo /etc/init.d/httpd status
http://www.lryc.cn/news/521609.html

相关文章:

  • 深度学习在自动化测试中的创新应用:提升运维效率与质量
  • 单独编译QT子模块
  • 学习华为熵减:激发组织活力(系列之三)
  • CNCF云原生计算基金会
  • STM32 FreeRTOS时间片调度---FreeRTOS任务相关API函数---FreeRTOS时间管理
  • SQL LAST()
  • 云服务信息安全管理体系认证,守护云端安全
  • 【Hive】新增字段(column)后,旧分区无法更新数据问题
  • C# (图文教学)在C#的编译工具Visual Studio中使用SQLServer并对数据库中的表进行简单的增删改查--14
  • 4G DTU赋能智能配电环网柜通信运维管理
  • 快速上手 HarmonyOS 应用开发
  • 解决nginx: [emerg] unknown directive “stream“ in /etc/nginx/nginx.conf问题 --九五小庞
  • Object类和hashcode方法
  • 速通Docker === 介绍与安装
  • OpenStack 网络服务的插件架构
  • SAP SD销售模块组织架构介绍(销售组织、分销渠道等)
  • CMake学习笔记(2)
  • Linux下源码编译安装Nginx1.24及服务脚本实战
  • 4、dockerfile实现lnmp和elk
  • Portainer.io安装并配置Docker远程访问及CA证书
  • 探索 Transformer²:大语言模型自适应的新突破
  • Flutter 多终端测试 自定义启动画面​​​​​​​ 更换小图标和应用名称
  • rsarsa-给定pqe求私钥对密文解密
  • flutter开发-figma交互设计图可以转换为flutter源代码-如何将设计图转换为flutter源代码-优雅草央千澈
  • Deep4SNet: deep learning for fake speech classification
  • 3 前端: Web开发相关概念 、HTML语法、CSS语法
  • SpringBoot工程快速启动
  • Unity WebGL:本机部署,运行到手机
  • 【线性代数】行列式的概念
  • Android SystemUI——StatusBar视图创建(六)