1.执行安装命令 sudo apt-get install apache2
2.打开proxy_ajp和deflate模块 sudo a2enmod deflate proxy_ajp
3.apache2相关配置
在 /etc/apache2/sites-available 中创建新的配置文件 api.conf,内容如下
<VirtualHost *:80>
ServerName cc.wxcc.com (二级域名)
ServerAdmin webmaster@localhost
DocumentRoot /var/www/mdcms(默认访问路径)
# user pic files (配置文件路径访问)
ProxyPass /mdcms/userfiles/ !
Alias /mdcms/userfiles /home/tomcat7/mdcmsuploaddir/userfiles
<Directory /home/tomcat7/mdcmsuploaddir/userfiles>
# For 2.4
Options -Indexes +FollowSymlinks
AllowOverride All
Require all granted
# For 2.2:
#Options Indexes FollowSymLinks
#AllowOverride None
#Order allow,deny
#Allow from all
</Directory>
#tomcat访问路径
ProxyPass /testcms ajp://localhost:8079/testcms
ProxyPassReverse /testcms ajp://localhost:8079/testcms
</VirtualHost>
4.将/etc/apache2/sites-available下的配置文件,软链接到/etc/apache2/sites-enabled目录下,Apache2启动中读取的是/etc/apache2/sites-enabled下 的 *.conf配置文件
命令: ln -s /etc/apache2/sites-enabled/api.conf /etc/apache2/sites-enabled
5.启动Apache2 sudo service apache2 start
6.如果启动的时候报了 Invalid command 'ProxyPass'
将/etc/apache2/mods-available 下的proxy相关配置文件软链接到/etc/apache2/mods-enabled文件下
ln -s /etc/apache2/mods-available/proxy.conf /etc/apache2/mods-enabled
ln -s /etc/apache2/mods-available/proxy.load /etc/apache2/mods-enabled
ln -s /etc/apache2/mods-available/proxy_ajp.load /etc/apache2/mods-enabled