第四节:Centos下安装Apache2.4.43

1、下载依赖包

需要用到 apr、apr-util、pcre、expat、gcc编译器

a、apr:点我下载apr-1.6.5.tar.gz

b、apr-util:点我下载apr-util-1.6.1.tar.gz

c、pcre:点我下载pcre-8.44

d、httpd(apache服务):点我下载apache2.4.43

e、expat :点我下载  提取码:mm53 

f、gcc编译器

#安装指令
yum -y install gcc-c++

2、安装apr

步骤说明:下载apr,解压,进到apr的根目录,配置(指定安装位置),编译,安装

#apr安装
wget https://downloads.apache.org/apr/apr-1.6.5.tar.gz 
tar -zxvf apr-1.6.5.tar.gz 
cd apr-1.6.5 
./configure --prefix=/usr/local/apr 
make 
make install

3、安装apr-uitl

步骤说明:下载expat,解压expat,进入expat根目录,配置expat,编译expat,安装expat,下载apr-util,解压,进到apr-util的根目录,配置(指定安装位置),编译,安装

#expat的安装(安装apr-util时报错No such file or directory)
wget 你的expat下载链接 或者用xftp把找到的文件扔到服务器上 
tar -zxvf expat.tar.gz 
cd expat 
./configure 
make 
make install
#apr-util安装
wget https://downloads.apache.org/apr/apr-util-1.6.1.tar.gz 
tar -zxvf apr-util-1.6.1 
cd apr-util-1.6.1 
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config  
make 
make install

4、安装pcre

步骤说明:yum 安装gcc编译器,下载pcre,解压,进到pcre的根目录,配置(指定安装位置),编译,安装

#pcre安装
yum -y install gcc-c++ 
wget https://nchc.dl.sourceforge.net/project/pcre/pcre/8.44/pcre-8.44.tar.gz 
tar -zxvf pcre-8.44.tar.gz 
cd pcre-8.44 
./configure --prefix=/usr/local/pcre 
make 
make install

5、安装apache(httpd)

步骤说明:下载httpd,解压,进到httpd的根目录,配置(指定安装位置),编译,安装

#httpd安装
wget https://downloads.apache.org/httpd/httpd-2.4.43.tar.gz 
tar -zxvf httpd-2.4.43.tar.gz 
cd httpd-2.4.43 
./configure --prefix=/usr/local/httpd --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre/ --enable-so --enable-rewrite --enable-charset-lite --enable-cgi 
make 
make install

安装完了以后启动试试看

cd /usr/local/httpd/bin 
./httpd -k start 
curl 127.0.0.1

返回It works! 成功

6、生成apache服务

拷贝apachectl到指定的目录下

cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd

编辑httpd

vi /etc/init.d/httpd  

#添加下面两行
# chkconfig: 35 61 61 
# description: Apache

#执行下面代码
chkconfig --add httpd 

操作完成后就可以以服务的方式启动apache了哦

#启动服务
service httpd start


#停止服务
service httpd stop

开机自动启动Apache服务:

#切换到sbin目录 
cd /sbin 
#执行配置 
./chkconfig --level 5 httpd on 
#查看启动项,如果httpd5:on,表示开机自动启动 
./chkconfig --list 
httpd 0:off 1:off 2:off 3:on 4:off 5:on 6:off

猜你喜欢

转载自blog.csdn.net/chenchao_JAVA/article/details/107611727