Apache2.4 RedHat系统安装步骤
制作本地源
先将系统对应的ISO文件上传至/opt目录下,例如openEuler-20.03-LTS-SP4-x86_64-dvd.iso
然后执行以下指令将iso文件临时挂载
mount -o loop /opt/openEuler-20.03-LTS-SP4-x86_64-dvd.iso /mnt
创建repo文件备份位置,并备份
mkdir /etc/yum.repos.d.bak/
mv /etc/yum.repos.d/* /etc/yum.repos.d.bak/
将挂载镜像写入yum的配置文件
cat > /etc/yum.repos.d/kylin_x86_64.repo <<EOF
[local]
name=local
baseurl=file:///mnt
enable=1
gpgcheck=0
EOF
更新yum的缓存索引
yum clean all
yum makecache
至此本地源配置完毕
安装libxml2-devel
已配置好源可以执行
yum groupinstall 'Development Tools'
yum install -y pcre pcre-devel expat-devel libxml2-devel
安装apche运行环境
需安装apr和apr-util
tar -zxvf apr-1.7.4.tar.gz
cd apr-1.7.4/cd /opt/software/apr-1.7.4/
./configure --prefix=/usr/local/apr
make && make install
tar -zxvf apr-util-1.6.3.tar.gz
cd /opt/software/apr-util-1.6.3/
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install
安装 Apache2.4
tar -zxvf httpd-2.4.61.tar.gz
cd /opt/software/httpd-2.4.61/
首先执行configure,然后执行make
./configure --prefix=/usr/local/apache2.4 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-mods-shared=most
make
如果make不报错则继续执行make install 完成安装
make install
如果make的时候报错,则在configure后加--with-included-apr执行
./configure --prefix=/usr/local/apache2.4 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-mods-shared=most --with-included-apr
如果报如下错误
configure: error: Bundled APR requested but not found at ./srclib/. Download and unpack the corresponding apr and apr-util packages to ./srclib/.
则将aprhe apr-util拷贝至http安装目录的scrlib下并去除文件夹版本号
cp -r apr-1.7.4 httpd-2.4.61/srclib/
mv httpd-2.4.61/srclib/apr-1.7.4 httpd-2.4.61/srclib/apr
cp -r apr-util-1.6.3 httpd-2.4.61/srclib/
mv httpd-2.4.61/srclib/apr-util-1.6.3 httpd-2.4.61/srclib/apr-util
然后再执行configure就可以正常make
./configure --prefix=/usr/local/apache2.4 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-mods-shared=most --with-included-apr
make && make install
配置文件调整
参照 apache httpd配置文档
启动
执行以下命令即可启动
/usr/local/apache2.4/bin/apachectl -f /usr/local/apache2.4/conf/httpd.conf
若提示
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.16.3.184. Set the 'ServerName' directive globally to suppress this message
则修改httpd.conf中的ServerName即可
启动后可浏览器访问对应ip的80端口(httpd.conf中Listen配置的端口)
出现 it works!则证明安装成功
后续可根据实际需要把apache2.4做成服务。