Apache Increase FD limit

On CentOS 7 sevrer running apache, when try to install plugin in WordPress admin area, i get error Installazione fallita: Il download non รจ andato a buon fine. cURL error 35: Process open FD table is full This is due to Apache File Descriptor Limits. To see current Limits, use following PHP script

gunicorn behind Apache web server

gunicorn is a python application server used to run python applications in production. This is normally run behind web servers like nginx or apache. To configre gunicorn behind apache, enable following apache modules. a2enmod proxy proxy_ajp proxy_http rewrite deflate headers proxy_balancer proxy_connect proxy_html xml2enc Restart apache web server systemctl restart apache2 For web site running … Read more

Apache Invalid command AuthGroupFile

On Plesk server, i get following error on error_log for a site [Tue Apr 23 08:50:32.336220 2019] [core:alert] [pid 30457:tid 140337888573184] [client 86.243.163.203:44805] /var/www/html/.htaccess: Invalid command ‘AuthGroupFile’, perhaps misspelled or defined by a module not included in the server configuration This is because authz_groupfile apache module was not loaded. To load this, run a2enmod authz_groupfile … Read more

Apache Limit access to a url

I want to limit access to admin login url of a web application to specified IP address. The web site had admin login in following URL https://domain.com/login To limit IP address, i edited Apache VirtualHost configuration for this web site, added Order deny,allow Deny from all Allow from 103.35.199.82 Allow from 51.38.246.115 Restart apache systemctl … Read more

Ubuntu Apache Setup for WordPress

wordpress

On a Fresh Ubuntu 18.04 server, run following commands to setup Apache, PHP and MySQL needed for WordPress installation. You can go to each file and manually run the commands if you want to see what commands are executed. wget https://raw.githubusercontent.com/serverok/server-setup/master/ubuntu/1-basic-tools.sh wget https://raw.githubusercontent.com/serverok/server-setup/master/ubuntu/2-apache-php-mysql.sh wget https://raw.githubusercontent.com/serverok/server-setup/master/install/update-php-ini.sh bash ./1-basic-tools.sh bash ./2-apache-php-mysql.sh bash ./update-php-ini.sh At this stage, you … Read more

Cpanel ReverseProxy Traffic to Docker Container

Apache mod_proxy

On a cpanel server, i need to run a web application using docker container. Application running side docker container listening on port 8000 on localhost. For a web site to serve traffic from this docker container, we can use Apache mod_proxy, this is enabled by default on cpanel servers. https://httpd.apache.org/docs/2.4/howto/reverse_proxy.html You can verify it at … Read more

Disable PHP on a folder

A web site had vlunerability, all allowed hacker to upload backdoor script to “uploads” folder used by the script. As a quick fix, i disabled PHP execution from “uploads” folder. Doing this for any site is a good dea when if your site is not vlunerable at the moment. Method 1 To disable PHP execution, … Read more

Apache Benchmark

ab is a tool for benchmarking web servers. It is designed to give you an impression of how your web server installation performs. This especially shows you how many requests per second your web server is capable of serving. http://httpd.apache.org/docs/2.4/programs/ab.html To benchmark a web site, use ab command provided by Apache. This will start 15000 … Read more

Limit Access Using htaccess

To limit access to a folder using .htaccess, create .htacess file with following content. YOUR_IP_HERE = Replace it with your actual IP. You can white list IP range by entering CIDR notation for the IP range. Here is .htacess i use on one of my web sites admin folder. If your server is behind a … Read more

Show X-Forwarded-For IP in Apache

When apache is running behind the proxy server it shows the IP of the proxy server as visitor IP. To fix this, you need to enable Apache module remoteip. https://httpd.apache.org/docs/2.4/mod/mod_remoteip.html On Ubuntu/Debian, this can be enabled with the command a2enmod remoteip Now create file vi /etc/apache2/conf-available/remoteip.conf Add RemoteIPHeader X-Forwarded-For RemoteIPTrustedProxy IP_OF_YOUR_PROXY_SERVER_HERE IP_OF_YOUR_PROXY_SERVER_HERE = repace with … Read more

Apache Disable PHP for a web site

To disable PHP for a web site edit VirtualHost entry of the web site and add php_flag engine off Restart Apache systemctl restart apache2 Method 2 Add following code in VirtualHost entry SetHandler none Restart Apache. Method 3 Add following code to Apache VirtualHost entry php_admin_flag engine Off Then restart the Apache web server. Change … Read more

Run .html files as PHP in Apache

On Ubuntu, to execute .htm files as PHP, create file vi /etc/apache2/conf-enabled/php-html.conf Add following content SetHandler application/x-httpd-php This is similar code from your PHP configuration. In this case, it is from /etc/apache2/mods-available/php5.6.conf If you want it only for a specific website, edit VirtualHost entry for the website and add SetHandler application/x-httpd-php Example ServerName serverok.in ServerAlias … Read more