在Ubuntu 16.04 LTS上安装Pound来加速Apache2

Pound是一个开源HTTP加速器。
它通常配置在WebServers前面,以快速提供HTTP/HTTPS请求。它可以大大提高服务器性能。
Pound也可以用作负载均衡器来分发多个WebServers的负载。

本文将介绍如何安装Pound并将其配置为Apache2的代理服务器。

第4步:配置Pound使用端口80

现在端口80是空闲的,让我们配置Pound使用该端口。

Pound默认配置文件是/etc/pound/pound.cfg

sudo nano /etc/pound/pound.cfg

修改监听端口,并配置后端服务器
使用服务器IP地址而不是环回(127.0.0.1)

User            "www-data"
Group           "www-data"
#RootJail       "/chroot/pound"
LogLevel        1
## check backend every X secs:
Alive           30
# poundctl control socket
Control "/var/run/pound/poundctl.socket"## listen, redirect and .  to:
## redirect all requests on port 8080 ("ListenHTTP") to the local webserver (see "Service" below):
ListenHTTP
        Address 192.168.43.133
        Port    80
        ## allow PUT and DELETE also (by default only GET, POST and HEAD)?:
        xHTTP           0
        Service
                BackEnd
                        Address 192.168.43.133
                        Port    8080
                End
        End
End

保存文件并关闭。

修改默认启动脚本。

sudo nano /etc/default/pound

然后将值更改为1

# prevent startup with default configuration
# set the below varible to 1 in order to allow pound to start
startup=1

保存文件。

重新启动Apache2 和Pound

sudo systemctl restart apache2.service
sudo systemctl restart pound.service

我们刚刚安装了Pound支持的apache

如果我们遵循上面的步骤而无法恢复侦听端口80,
检查Pound套接字控制目录,如果没有该目录,
请运行下面的命令创建:

sudo mkdir /var/run/pound

第2步:安装Pound 代理服务器

运行以下命令以安装Pound

sudo apt-get install pound

安装Pound 后,下面的命令可用于启动,停止和启用Pound服务(在服务器引导时自动启动)

sudo systemctl stop pound.service
sudo systemctl start pound.service
sudo systemctl enable pound.service

第3步:将Apache2默认端口更改为8080

由于Pound 将监听来自端口80的所有流量。所以我们需要配置Apache2,让它使用其他端口号。

我们可以在/etc/apache2/ports.conf下打开apache2默认端口配置文件并将侦听值更改为8080。

打开Apache2默认端口配置文件。

sudo nano /etc/apache2/ports.conf

修改如下:

# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf
NameVirtualHost 127.0.0.1:8080
Listen 127.0.0.1:8080

打开Apache2默认VirtualHost配置文件。

sudo nano /etc/apache2/sites-available/000-default.conf

修改如下:

<VirtualHost 127.0.0.1:8080>

保存然后文件并退出。

然后重新启动Apache2.

sudo systemctl restart apache2.service

现在要访问apache2,我们必须输入服务器IP或者主机名,后跟端口#8080。

http://localhost:8080

第1步:安装Apache2 HTTP服务器

首先运行以下命令以安装apache2 webserver。

sudo apt-get update
sudo apt-get install apache2

安装Apache2后,下面的命令可用于停止,启动服务以及设置在服务器引导时自动启动服务

sudo systemctl stop apache2.service
sudo systemctl start apache2.service
sudo systemctl enable apache2.service

默认情况下,Apache2 HTTP服务自动键入HTTPS端口80和443.

日期:2020-07-07 20:57:12 来源:oir作者:oir