diff --git a/Makefile b/Makefile index de4f1db..49b1ecb 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,25 @@ +# Define the Red Hat paths +APACHE_INCLUDES := -I/usr/include/httpd/ +APR_INCLUDES := -I/usr/include/apr-1/ + +# Check for Debian/Ubuntu paths +ifneq (, $(shell test -d /usr/include/apache2 && echo "true")) + APACHE_INCLUDES := -I/usr/include/apache2 + APR_INCLUDES := -I/usr/include/apr-1.0/ +endif + +CPPFLAGS := $(APACHE_INCLUDES) $(APR_INCLUDES) -fPIC all: mod_vhost_limit.so shm.o : shm.cpp - g++ -c -I/usr/include/httpd/ -I/usr/include/apr-1/ -fPIC shm.cpp + g++ -c $(CPPFLAGS) -fPIC shm.cpp mod_vhost_limit.o : mod_vhost_limit.cpp - g++ -c -I/usr/include/httpd/ -I/usr/include/apr-1/ -fPIC mod_vhost_limit.cpp + g++ -c $(CPPFLAGS) -fPIC mod_vhost_limit.cpp mod_vhost_limit.so : mod_vhost_limit.o shm.o - g++ -shared -o mod_vhost_limit.so mod_vhost_limit.o shm.o + g++ -shared -o mod_vhost_limit.so mod_vhost_limit.o shm.o clean: rm -rf mod_vhost_limit.o mod_vhost_limit.so shm.o diff --git a/README.md b/README.md index af9d87a..cabbb59 100644 --- a/README.md +++ b/README.md @@ -41,14 +41,26 @@ total 72 4 -rw-r--r-- 1 root root 3368 Aug 14 10:41 shm.o ``` -mod_vhost_limit.so is your module. That's it. Now you have to install it. -This is different for each system, so i will show how to install it in a Fedora install : +`mod_vhost_limit.so` is your module. That's it. Now you have to install it. +This is different for each system, so i will show how to install it in... + +## Fedora/Redhat: ```bash $ cp -f mod_vhost_limit.so /etc/httpd/modules/ $ echo -e "\nLoadModule vhost_limit_module modules/mod_vhost_limit.so" >> /etc/httpd/conf.modules.d/00-base.conf $ systemctl restart httpd ``` + +## Debian/Ubuntu: + +```bash +$ cp -f mod_vhost_limit.so //usr/lib/apache2/modules/ +$ echo -e "\nLoadModule vhost_limit_module modules/mod_vhost_limit.so" >> /etc/apache2/mods-available/vhost_limit.load +$ a2enmod vhost_limit +$ systemctl restart apache2 +``` +
 $ tail /var/log/httpd/error_log
 
@@ -77,8 +89,6 @@ To make it DO something, you need to use the only directive supported (for now)
 And restart httpd/apache.
 MaxVhostClients will set a maximum number of connections to be accepted for that vhost.
 
-Everytime you get a visit, a per-vhost counter will increment. When that connection is finished, the counter will decrement. In this case, we are limiting the vhost to 3 simultaneous connections, and every excess visit will receive a HTTP_SERVICE_UNAVAILABLE response.
+Everytime you get a visit, a per-vhost counter will increment. When that connection is finished, the counter will decrement. In this case, we are limiting the vhost to 3 simultaneous connections, and every excess visit will receive a `HTTP_SERVICE_UNAVAILABLE` response.
 
 > Please note : Using a fastcgi script (e.g. mod_fcgi/php-fpm) might not close the connection immediately after finished. It might take a little longer. So if you are testing, have this in mind before thinking something broke.
-
-