The process is written in a script, the principles are written in the comments, you understand. One-click operation is sudo bash xxx.sh
Copy Code code as follows:
#!/bin/bash
#cd到临时目录创建配置文件
Cd/tmp
(Cat <<eof
<Directory/home/hursing/mylimiteddir/>
Setoutputfilter Rate_limit
Setenv Rate-limit 30
</Directory>
Eof
) > Ratelimit.conf
# The number above setenv Rate-limit is the speed limit, in kilobytes. Directory represents which directories are restricted
#创建配置文件, manual operation is to create a conf file, and write the contents between two EOF
#复制过去. Mods-available directory to place all available modules
sudo cp ratelimit.conf/etc/apache2/mods-available/
#mods-enabled directory to place all enabled modules, full of soft links, you can use Ls-l to see
Cd/etc/apache2/mods-enabled
#ratelimit就是限速模块, the load suffix file holds the path to the so library, and the Conf suffix file is configured for the module
sudo ln-s. /mods-available/ratelimit.load.
sudo ln-s. /mods-available/ratelimit.conf.
#重启服务来生效
sudo service apache2 restart
Some additions: Directory tags can be replaced by other, such as location represents a specific URL. No tagging is the global setting. There are multiple labels that can be set for different directories. The speed value cannot be decimal.