Linux中Apache的安装

(一)Apache2.2的make install

下载安装包
wget http://archive.apache.org/dist/httpd/httpd-2.2.3.tar.gz 
解压
tar xvf httpd-2.2.3.tar.gz
cd httpd-2.2.3
配置安装路径
./configure --prefix=/usr/local/apache --enable-so
make
安装
make install

apache的启动关闭
/usr/local/apache/bin/apachectl -k start
/usr/local/apache/bin/apachectl -k stop

(二)apache2.4的make install

1.选择性安装以下资源

yum install gcc gcc-c++ prce-devel expat-devel
yum install -y libxml2-devel
yum -y install automake autoconf libtool make
yum -y install zlib zlib-devel openssl openssl-devel pcre-devel

2.安装apr-1.7.0

wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.7.0.tar.gz
tar -zxvf apr-1.7.0.tar.gz
cd apr-1.7.0/
./configure --prefix=/usr/local/apr
make
make install

3.安装pcre-8.44

wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-iconv-1.2.2.tar.gz
wget https://sourceforge.net/projects/pcre/files/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

4.安装apr-util-1.6.1

wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.gz
tar -zxvf apr-util-1.6.1.tar.gz
cd apr-util-1.6.1/
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make
make install

5.安装httpd-2.4

wget https://mirrors.bfsu.edu.cn/apache//httpd/httpd-2.4.46.tar.bz2
tar -jxvf httpd-2.4.46.tar.bz2
cd httpd-2.4.46/
./configure --prefix=/usr/local/apache2.4 --sysconfdir=/etc/httpd --enable-so --enable-rewirte --enable-ssl --enable-cgi --enable-cgid -enable-mble-cgi --enable-cgid -enable-modules=most --enable-mods-shared=most --enable-mpms-shared=all --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
make
make install

apache的启动关闭
/usr/local/apache2.4/bin/apachectl  start
/usr/local/apache2.4/bin/apachectl  stop

(三)apache2.4的yum install

1.如果需要网络代理,配置如下
在/etc/profile中追加下两行
export http_proxy=http://IP:port
export https_proxy=http://IP:port
2.配置完代理后,重启reboot起效.
3.或者redhat注册,使用redhat的yum源。
了解注册方式参考https://access.redhat.com/solutions/253273
了解注册账号或登录https://access.redhat.com/labs/registrationassistant/.了解redhat订阅参考https://www.redhat.com/wapps/eval/index.html?evaluation_id=1036
订阅付费成功后
终端使用如下:
sudo subscription-manager remove --all
sudo subscription-manager unregister
sudo subscription-manager clean

sudo subscription-manager register
sudo subscription-manager refresh
sudo subscription-manager attach --auto
4.或者使用和redhat免费版的centos8代替,下载yum源.
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
5.安装apache2.4
yum install -y httpd
6.关闭防火墙
systemctl stop firewalld
7.启动禁用防火墙
systemctl disable firewalld
8.apache启动,关闭,状态查看
systemctl start httpd
systemctl stop httpd
systemctl restart httpd
systemctl status httpd

(四)关于其他

1.检查SELinux是否开启

/etc/selinux/config
开启:SELINUX=enforcing(默认)
关闭:SELINUX=disabled
临时关闭:setenforce 0
临时开启:setenforce 1
不关闭可能会出现403.权限不足的错误,

2.检查Apache的CGI模块的设置。
如果没有开启,访问apache会直接下载或者画面显示源码

3.检查/var/run/httpd/是否有访问权限,没有权限会出现503
chmod 755 /var/run/httpd/

4.检查Apache的MPM模块的设置
官网参考https://access.redhat.com/documentation/ja-jp/red_hat_jboss_core_services/2.4.37/html/apache_http_server_connectors_and_load_balancing_guide/multi_processing_modules#_mpm_overview
prefork(apache2.2默认)
worker
event(apache2.4默认)可能会出现503

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值