这次给大家说说我安装部署apache的步骤(我已经成功在使用),想要安装包以及其他问题的联系本人qq:1814148326
一、安装
安装之前先将服务器的防火墙关掉。
systemctl stop firewalld
systemctl disable firewall
第一步:
安装apr
下载:
wget -c http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.6.3.tar.bz2
解压该文件:
tar -jvxf apr-1.6.3.tar.bz2
检测:
cd apr-1.6.3
./configure --prefix=/usr/local/apr/
编译: make
make install
第二步:
安装apr-util
下载:
wget -c http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.bz2
解压该文件: tar -jvxf apr-util-1.6.1.tar.bz2
检测: cd apr-util-1.6.3
./configure --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr/
编译: make
make install
第三步:
安装pcre
下载:
wget -c http://ftp.pcre.org/pub/pcre/pcre-8.42.tar.bz2
解压该文件: tar -jvxf pcre-8.42.tar.bz2
检测: cd pcre-8.42
./configure --prefix=/usr/local/pcre/
编译: make
make install
第四步: 安装httpd
下载:
wget -c http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.29.tar.bz2
解压该文件: tar -jvxf httpd-2.4.29.tar.bz2
检测: cd httpd-2.4.29
./configure --prefix=/usr/local/httpd/ --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre/
编译: make
make install
第五步:
配置/usr/local/apache2/conf/httpd.conf
ServerName www.examda.com:80 改为 ServerName localhost:80
第六步:
启动apache服务
cd /usr/local/apache2/bin
./apachectl start
二、检测
使用浏览器访问本地IP
出现It works!成功
三、注册Apache到Linux服务
在Linux下用源代码方式编译安装完Apache后,启动关闭Apache可以通过如下命令实现:
/usr/local/apache/bin/apachectl start | stop | restart
如果想将httpd列入系统自动启动的服务,可以直接将上述的apachectl文件拷贝到 /etc/rc.d/init.d 中,然后在相应的启动级别如3,5中加入链接即可。命令如下:
1. cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd #复制到init.d 并重命名为httpd
2. ln -s /etc/rc.d/init.d/httpd /etc/rc.d/rc3.d/S61httpd
链接文件的S61是启动时的序号。当init.d目录下有httpd脚本后,我们就可以通过service命令来启动关闭apache了。在任意路径下执行:
service httpd start | stop | restart
本次教程到此结束,之后会出如何在centos里面安装mysql,安装php环境、多个域名配置、https的配置、如何配置FTP服务、apache代理tomcat进行访问。欢迎大家前来咨询。
qq群:311602501