一、搭建YUM仓库
虚拟机需要关闭防火墙、内核防护,最好做一个永久挂载方便下次使用。
mount /dev/cdrom /mnt
ll /etc/yum.repos.d/
mkdir backup
mv C* backup/
cp backup/CentOS-Base.repo local.repo
vi local.repo
[centos]
name=centos
baseurl=file:///mnt
gpgcheck=0
enabled=1
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
yum clean all
yum makecache
二、编译安装HTTP服务
需要将安装包添加进来,SecureCRT可以通过软件xftp添加软件包,xshell可直接将包拖进去。
tar xf apr-1.6.2.tar.gz
tar xf apr-util-1.6.0.tar.gz
tar xf httpd-2.4.29.tar.bz2
mv apr-1.6.2 httpd-2.4.29/srclib/apr
mv apr-util-1.6.0 httpd-2.4.29/srclib/apr-util
三、安装环境
需注意\前面有空格
[root@localhost opt]#
yum -y install \
gcc \
gcc-c++ \
make \
pcre-devel \
expat-devel \
perl
四、配置模块
[root@localhost opt]# cd /opt/httpd-2.4.29/
./configure \
--prefix=/usr/local/httpd \
--enable-so \
--enable-rewrite \
--enable-charset-lite \
--enable-cgi
五、编译安装
-j3是你核心数,最大不要超过虚拟机的核心数
make -j3 && make install -j3
六、配置文件添加系统给服务
在/lib/systemd/system/目录下,建立一个以.service 结尾的单元(unit)配置文件,
用于控制由 systemd 管理或监控的 httpd 服务
[root@localhost ~]# cd /lib/systemd/system/
[root@localhost system]# vim httpd.service
[Unit]
Description=The Apache HTTP Server
After=network.target
[Service]
Type=forking
PIDFile=/usr/local/httpd/logs/httpd.pid
ExecStart= /usr/local/bin/apachectl $OPTIONS
ExecrReload= /bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target
[root@localhost system]# systemctl start httpd.service
[root@localhost system]# systemctl enable httpd.service ###开机自启http
[root@localhost system]# systemctl is-enabled httpd.service ###检查HTTP单元是否启动