apache编译安装

centos下表编译安装httpd-2.4.41

1、下载安装包

安装apache需要扩展依赖apr、apr-util、pcre

httpd-2.4.41下载地址 :http://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.41.tar.gz
apr1.7下载地址:http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.7.0.tar.gz
apr-util-1.6.1下载地址:http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.gz
pcre8下载地址:ftp://ftp.pcre.org/pub/pcre/pcre-8.00.tar.gz

2、解压安装包

  tar -zxvf httpd-2.4.41.tar.gz
  tar -zxvf pcre-8.00.tar.gz
  tar -zxvf apr-1.7.0.tar.gz
  tar -zxvf apr-util-1.6.1.tar.gz

3、安装

  /usr/local/server/均为指定的安装目录
  1、安装apr
        cd apr-1.7.0
        ./configure --prefix=/usr/local/server/apr1.7
        make && make install
  2、安装apr-util
        cd  apr-util-1.6.1
         yum install -y  expat-devel
        ./configure --prefix=/usr/local/server/apr-util1.6 --with-apr=/usr/local/server/apr1.7/bin/apr-1-config
        make && make install
  3、安装pcre
        cd pcre-8.00
        ./configure --prefix=/usr/local/server/pcre8 --with-apr=/usr/local/server/apr1.7/bin/apr-1-config
        make && make install
  4、安装apache
        cd httpd-2.4.41
       ./configure --prefix=/usr/local/server/apache2.4.4 --with-pcre=/usr/local/server/pcre8 --with-apr=/usr/local/server/apr1.7 --with-apr-util=/usr/local/server/apr-util1.6 --enable--ssl
        make && make install

4、简单站点配置

    vim /usr/local/server/apache2.4.4/conf/httpd.conf
    1、去掉ServerName前面的#号
        ServerName 
    2、更改站点目录
        DocumentRoot "/usr/local/server/www"
        <Directory "/usr/local/server/www">
    3、打开防火墙端口访问
        firewall-cmd --zone=public --add-port=80/tcp --permanent
        systemctl restart firewalld.service
    4、创建快捷启动方式
        vim /usr/lib/systemd/system/apache.service
            [Unit]
            Description=apache - high performance web server
            Documentation=http://httpd.apache.org/
            After=network.target remote-fs.target nss-lookup.target
            [Service]
            Type=forking
            WorkingDirectory=/usr/local/server/apache2.4.4
            ExecStart=/usr/local/server/apache2.4.4/bin/apachectl -k start
            ExecStop=/usr/local/server/apache2.4.4/bin/apachectl -k stop
            ExecRestart=/usr/local/server/apache2.4.4/bin/apachectl -k restart
            ExecReload=/usr/local/server/apache2.4.4/bin/apachectl -k reload
            PrivateTmp=true
            [Install]
            WantedBy=multi-user.target
         使其立即生效
           systemctl daemon-reload
        启动/停止/重启
          systemctl start apache.service
          systemctl stop apache.service
          systemctl restart apache.service
      3、设置开启启动
          systemctl enable apache.service

apache访问配置参考:https://www.jianshu.com/p/d83aa0bed8c9

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容