Compile, install Apache Portable Runtime (APR) on Ubuntu

Compile and install APR
root needed!

Download source packages, apr-1.5.2.tar.gz and apr-util-1.5.4.tar.gz, from Apache site, https://apr.apache.org/download.cgi

Unpack the packages to /root/apache/apr-1.5.2 and /root/apache/apr-util-1.5.4

Installation path: /usr/local/apr

# compile and install apr
# /root/apache/apr-1.5.2
./configure --prefix=/usr/local/apr
make
make install
# compile and install apr-util
#/root/apache/apr-util-1.5.4
./configure --prefix=/usr/local/apr/lib --with-apr=/usr/local/apr
make
make install

For Tomcat
Compile and install tomcat native
Go to tomcat/bin, unpack tomcat-native.tar.gz, then go to tomcat-native-1.1.29-src/jni/native, compile and install tomcat-native

# /home/root/apache-tomcat-7.0.53/bin/tomcat-native-1.1.29-src/jni/native
./configure --with-apr=/usr/local/apr --with-java-home=/usr/lib/jvm/java-VERSION-oracle/
make
make install

Configuration
In the start script of Tomcat, add

CATALINA_OPTS="$CATALINA_OPTS -Djava.library.path=/usr/local/apr/lib"

In conf/server.xml, update protocol of connectors to use the following protocols,

org.apache.coyote.http11.Http11AprProtocol
org.apache.coyote.ajp.AjpAprProtocol

Restart tomcat, if you see the following in the catalina.out and no exception, the APR is running.

...
INFO: Loaded APR based Apache Tomcat Native library 1.1.29 using APR version 1.5.2.
Nov 26, 2015 2:58:54 PM org.apache.catalina.core.AprLifecycleListener init
...

Apache NameVirtualHost中IP到域名的Rewrite

有台apache服务器,想把所有通过IP的http访问重定向到域名http://dev.ymeng.net,结果完全没效果,VirtualHost配置如下

<virtualhost *:80>
    DocumentRoot /var/www/html/dev.ymeng.net
    ServerName dev.ymeng.net
    ErrorLog /var/log/apache2/dev.ymeng.net-error_log
 
    <directory "/var/www/html/dev.ymeng.net">
      Order allow,deny
      Deny from all
      Allow from 212.5.5.1
    </directory>
</virtualhost>
 
<virtualhost *:80>
    DocumentRoot /var/www/html/dev.ymeng.net
    ServerName 217.12.15.69
    ErrorLog /var/log/apache2/dev.ymeng.net-error_log
 
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^217\.12\.15\.69
    RewriteRule ^(.*)$ http://dev.ymeng.net [R,L]
 
    <directory "/var/www/html/dev.ymeng.net">
      Order allow,deny
      Deny from all
    </directory>
</virtualhost>

仔细检查后,发现NameVirtualHost被注释掉了
NameVirtualHost *:80