ubuntu安装Apache2

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值