1.安装依赖包
sudo apt-get install g++ make pkg-config libssl-dev tcl-dev libexpat1-dev libpcre3-dev libmodule-install-perl
sudo apt-get install libcap-dev libcap2 hwloc libhwloc-dev
sudo apt-get install bison flex
2.配置编译和安装
./configure --prefix=/opt/ats --with-user=ats --with-group=nogroup --enable-reclaimable-freelist --enable-debug --enable-example-plugins --enable-experimental-plugins
make -j 4
sudo make install -j 4
3.修改配置文件
records.config文件
CONFIG proxy.config.http.server_ports STRING 8081
CONFIG proxy.config.http.insert_request_via_str INT 1
CONFIG proxy.config.http.insert_response_via_str INT 2
CONFIG proxy.config.log.squid_log_enabled INT 0
CONFIG proxy.config.log.custom_logs_enabled INT 1
CONFIG proxy.config.log.xml_config_file STRING logs_xml.config
CONFIG proxy.config.diags.show_location INT 1
CONFIG proxy.config.log.max_line_size INT 35000
CONFIG proxy.config.log.log_buffer_size INT 262144
CONFIG proxy.config.core_limit INT -1
remap.config文件
regex_map http://(.*) http://$1
storage.config文件
var/trafficserver 100G
cache.config文件
dest_domain=. suffix=mp4 ttl-in-cache=10d
dest_domain=. suffix=flv4 ttl-in-cache=10d
logs_xml.config文件
% % % [%] %<{X-Forwarded-For}cqh> "%" % "%" %:% %<{Referer}cqh> "%<{User-Agent}cqh>" %"/>
4.更新动态库
sudo vim /etc/ld.so.conf
在末尾添加上
/opt/ats/libexec/trafficserver
保存退出后,运行
sudo ldconfig
设置环境变量
使用root身份
su
vim /etc/profile
在末尾添加
export PATH=/opt/ats/bin:$PATH
更新配置
source /etc/profile
使用当前用户身份
vim ~/.bashrc
在末尾添加C和C++头文件的包含路径
export C_INCLUDE_PATH=/opt/ats/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=/opt/ats/include:$CPLUS_INCLUDE_PATH
更新配置
source ~/.bashrc
5.启动ats
sudo /opt/ats/bin/trafficserver status
sudo /opt/ats/bin/trafficserver start
ps auxf | grep traffic | grep -v grep
6.测试
curl -vo /dev/null -x 127.0.0.1:18980 'http://news.sohu.com/'