1.配置服务器ip地址
#vim /etc/sysconfig/network-scripts/ifcfg-ens33
..........................................
BOOTPROTO=static
IPADDR=192.168.1.1
#ifdown ens33;ifup ens33
2.关闭防火墙
#systemctl stop firewalld
3.关闭selinux
#setenforce 0
4.制作源代码包光盘镜像
二、安装httpd
1.检查httpd是否安装
#rpm -q httpd
2.安装依赖包(通过脚本安装)
- 挂载系统盘
#mount /dev/cdrom /mnt
#vim httpd_rpm.sh
rpm -ivh /mnt/Packages/apr-1.4.8-3.el7.x86_64.rpm
rpm -ivh /mnt/Packages/apr-devel-1.4.8-3.el7.x86_64.rpm
rpm -ivh /mnt/Packages/cyrus-sasl-devel-2.1.26-20.el7_2.x86_64.rpm
rpm -ivh /mnt/Packages/expat-devel-2.1.0-8.el7.x86_64.rpm
rpm -ivh /mnt/Packages/libdb-devel-5.3.21-19.el7.x86_64.rpm
rpm -ivh /mnt/Packages/openldap-devel-2.4.40-13.el7.x86_64.rpm
rpm -ivh /mnt/Packages/apr-util-devel-1.5.2-6.el7.x86_64.rpm
rpm -ivh /mnt/Packages/apr-util-1.5.2-6.el7.x86_64.rpm
rpm -ivh /mnt/Packages/pcre-devel-8.32-15.el7_2.1.x86_64.rpm
rpm -ivh /mnt/Packages/pcre-8.32-15.el7_2.1.x86_64.rpm
#sh httpd_rpm.sh
3.安装httpd源代码包
1)卸载系统盘
#umount /dev/cdrom
#eject
2)挂载源代码包光盘
#mount /dev/cdrom /mnt
3)解压httpd源代码包
#tar zxf /mnt/httpd-2.4.25.tar.gz -C /usr/src
4)配置
cd /usr/src/httpd-2.4.25/
./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi
5)编译
#make
6)安装
#make install
7)确认安装成功
#ls /usr/local/httpd
三、到此就可以在访问测试下
- 启动httpd
#/usr/local/httpd/bin/apachectl start
- 在客户机上打开浏览器访问测试
四、执行优化路径
#ln -s /usr/local/httpd/bin/* /usr/local/bin/
五、将httpd添加为系统服务
- #cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd //创建httpd脚本文件
- #vim /etc/init.d/httpd
#!/bin/bash //此行为首行,默认存在,将默认的sh改成bash
#chkconfig: 35 85 21 //此行在第一行后添加
#description: this is a http server //此行在第二行后添加
- #chkconfig --add httpd
六、配置httpd
1)为网站分配一个域名
#vim /usr/local/httpd/conf/httpd.conf
将此行前#去掉,并为web站点设置好域名
2)重启httpd
#systemctl restart httpd