源码安装web服务(阿帕奇)

1. 关闭Linux防火墙

[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
[root@localhost ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
[root@localhost ~]# setenforce 0 

2. 安装环境

[root@localhost ~]# yum install -y make gcc gcc-c++ expat-devel

3. 下载扩展包

# 安装Apache需要下载apr、apr-util、pcre这三个扩展包
wget https://mirror.bit.edu.cn/apache/apr/apr-1.6.5.tar.gz

wget https://mirror.bit.edu.cn/apache/apr/apr-util-1.6.1.tar.gz

wget https://netix.dl.sourceforge.net/project/pcre/pcre/8.40/pcre-8.40.tar.gz

 #下载Apache安装包
wget https://mirror.bit.edu.cn/apache/httpd/httpd-2.4.46.tar.gz 

4. 解压,预编译,安装APR扩展包

[root@localhost ~]# tar -zxvf apr-1.6.5.tar.gz
[root@localhost ~]# cd apr-1.6.5/
[root@localhost apr-1.6.5]# ./configure --prefix=/usr/local/apr
[root@localhost apr-1.6.5]# make && make install

# 安装过程没有报错,说明安装成功,然后去/usr/local下面看有没有apr目录
[root@localhost apr-1.6.5]# ls /usr/local/
apr  bin  etc  games  include  lib  lib64  libexec  sbin  share  src
[root@localhost apr-1.6.5]# ls /usr/local/apr/
bin  build-1  include  lib
# 出现以上文件说明安装成功 

5. 解压、预编译、安装apr-util扩展包

[root@localhost ~]# tar -zxvf apr-util-1.6.1.tar.gz
[root@localhost ~]# cd apr-util-1.6.1/
[root@localhost apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr

# 安装过程没有报错,说明安装成功
[root@localhost apr-util-1.6.1]# ls /usr/local/
apr  apr-util  bin  etc  games  include  lib  lib64  libexec  sbin  share  src
[root@localhost apr-util-1.6.1]# ls /usr/local/apr-util/
bin  include  lib
# 出现上面所示的目录,说明安装成功 

6.解压、预编译、安装PCRE扩展包

[root@localhost ~]# tar -zxvf pcre-8.40.tar.gz
[root@localhost ~]# cd pcre-8.40/
[root@localhost pcre-8.40]# ./configure --prefix=/usr/local/pcre

# 安装成功没有报错,说明安装成功
[root@localhost pcre-8.40]# ls /usr/local/
apr  apr-util  bin  etc  games  include  lib  lib64  libexec  pcre  sbin  share  src
[root@localhost pcre-8.40]# ls /usr/local/pcre/
bin  include  lib  share
# 出现上面所示的目录,说明安装成功  

7. 解压、预编译、安装Apache服务

[root@localhost ~]# tar -zxvf httpd-2.4.46.tar.gz
[root@localhost ~]# cd httpd-2.4.46/
[root@localhost httpd-2.4.46]# ./configure --prefix=/usr/local/httpd \

# 安装过程没有报错,说明安装成功
[root@localhost httpd-2.4.46]# ls /usr/local/
apr  apr-util  bin  etc  games  httpd  include  lib  lib64  libexec  pcre  sbin  share  src
[root@localhost httpd-2.4.46]# ls /usr/local/httpd/
bin  build  cgi-bin  conf  error  htdocs  icons  include  logs  man  manual  modules
# 出现什么所示目录,说明安装成功

8. 添加软连接

[root@localhost ~]# ln -s /usr/local/httpd/bin/apachectl /usr/local/bin/apachectl

9. 修改httpd.conf的配置文件

[root@localhost ~]# cd /usr/local/httpd/conf/
[root@localhost conf]# ls
extra  httpd.conf  magic  mime.types  original
[root@localhost conf]# vim httpd.conf
...........
User apache         //所列出的是需要修改的内容
Group apache
...........
ServerName 192.168.174.128:80    //将servername修改自己的IP加端口号

10. 创建apache用户

[root@localhost ~]# groupadd -r apache
[root@localhost ~]# useradd -r -g apache apache
[root@localhost ~]# id apache
uid=991(apache) gid=987(apache) 组=987(apache) 

11. 启动httpd服务

[root@localhost ~]# apachectl start
posted @ 2023-10-18 10:42  廿九九  阅读(45)  评论(0编辑  收藏  举报