{"id":405,"date":"2020-10-14T15:31:44","date_gmt":"2020-10-14T15:31:44","guid":{"rendered":"https:\/\/dft.wiki\/?p=405"},"modified":"2026-06-09T14:33:47","modified_gmt":"2026-06-09T18:33:47","slug":"wordpress-configuration-tips-and-tricks","status":"publish","type":"post","link":"https:\/\/dft.wiki\/?p=405","title":{"rendered":"WordPress Configuration and Security Tips"},"content":{"rendered":"<p>I just installed WordPress on my server and the first concern? Security!<\/p>\n<p>We will cover the following points:<\/p>\n<ul>\n<li>Fail2Ban<\/li>\n<li>WP Fail2Ban<\/li>\n<li>2FAS Prime<\/li>\n<li>Loginizer<\/li>\n<li>Disable XML-RPC-API<\/li>\n<li>WP Activity Log<\/li>\n<li>Manual Configurations<\/li>\n<li>Multi-Site<\/li>\n<li>Multi-Domain<\/li>\n<li>WP MU Domain Mapping<\/li>\n<li>WAF and CDN<\/li>\n<li>Duplicator<\/li>\n<\/ul>\n<p>If you have control of your server (like a VPS, not Godaddy, etc.) it is mandatory to have Fail2Ban securing SSH, but it can also be used with WordPress. If it is not set up yet, read the following post about Increasing Security with Fail2Ban on Ubuntu 20.4 [<a href=\"https:\/\/dft.wiki\/?p=401\">Link<\/a>].<\/p>\n<p>Inside your WordPress Dashboard, search for and install the plugin <strong>WP Fail2Ban<\/strong> (by Charles Lecklider) and activate it.<\/p>\n<p>Then go to your Linux terminal and add the Filter and the Jail:<\/p>\n<pre>sudo curl https:\/\/plugins.svn.wordpress.org\/wp-fail2ban\/trunk\/filters.d\/wordpress-hard.conf &gt; \/etc\/fail2ban\/filter.d\/wordpress.conf<\/pre>\n<p>If it does not work, get the file here [<a href=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2020\/10\/wordpress.zip\">wordpress.conf<\/a>] and place it in: \/etc\/fail2ban\/filter.d\/<\/p>\n<p>Next, edit the jail file:<\/p>\n<pre>sudo nano \/etc\/fail2ban\/jail.d\/wordpress.conf<\/pre>\n<p>Add the following configuration to the newly created file:<\/p>\n<pre>[wordpress]\r\nenabled = true\r\nfilter = wordpress\r\nlogpath = \/var\/log\/auth.log\r\nport = http,https<\/pre>\n<p>Restart the Fail2Ban service:<\/p>\n<pre>sudo service fail2ban restart<\/pre>\n<p>Test by attempting a failed login on your WordPress site before considering yourself protected. In my case it did not work right away and I had to troubleshoot it.<\/p>\n<p>Implement 2FA (Two-Factor Authentication) with the <strong>2FAS Prime<\/strong> (by Two Factor Authentication Service Inc) plugin.<\/p>\n<p>Then go to Users in the left menu and enable 2FA for your user. It is self-explanatory and only requires the Google Authenticator app to scan the QR code and enter the generated temporary code.<\/p>\n<p>Run a quick environment check with <strong>Loginizer<\/strong> (by Softaculous). After installing and activating it, find its menu on the left side.<\/p>\n<p>On the first page, the analysis may reveal opportunities such as changing file permissions to prevent modification:<\/p>\n<pre>sudo chmod 444 \/var\/www\/wordpress\/wp-config.php<\/pre>\n<p>You can now disable, delete, or simply leave this plugin installed.<\/p>\n<p>If you do not use any API that requires XML-RPC, disable this feature as it can be a vulnerability.<\/p>\n<p>Install and activate the <strong>Disable XML-RPC-API<\/strong> (by Neatmarketing) plugin. No further action is needed.<\/p>\n<p>If the website will have many users, it is recommended to install the <strong>WP Activity Log<\/strong> plugin (by WP White Security). It provides useful information about user activity.<\/p>\n<p>Edit the .htaccess file to prevent directory listing:<\/p>\n<pre>sudo nano \/var\/www\/wordpress\/.htaccess<\/pre>\n<p>Add the following:<\/p>\n<pre>Options -Indexes<\/pre>\n<p>Configure Apache:<\/p>\n<pre>sudo nano \/etc\/apache2\/apache2.conf<\/pre>\n<p>Make sure .htaccess files can override configurations:<\/p>\n<pre>&lt;Directory \/var\/www\/&gt;\r\n...\r\n     <strong>AllowOverride All\r\n<\/strong>     ServerSignature Off\r\n...\r\n&lt;\/Directory&gt;<\/pre>\n<p>As a manual alternative to disable <strong>xmlrpc.php<\/strong>, append the following to <strong>.htaccess<\/strong>:<\/p>\n<pre># BEGIN Disable XML-RPC.PHP\r\n\r\n&lt;Files xmlrpc.php&gt;\r\nOrder Deny,Allow\r\nDeny from all\r\n&lt;\/Files&gt;\r\n\r\n# END Disable XML-RPC.PHP<\/pre>\n<p>Also, disable the execution of PHP files in the uploads directory:<\/p>\n<pre>sudo nano \/var\/www\/wordpress\/wp-content\/uploads\/.htaccess<\/pre>\n<p>Add the following:<\/p>\n<pre>&lt;Files *.php&gt;\r\ndeny from all\r\n&lt;\/Files&gt;<\/pre>\n<p>Restart Apache:<\/p>\n<pre>sudo chmod 444 \/var\/www\/wordpress\/.htaccess\r\nsudo chmod 444 \/var\/www\/wordpress\/wp-content\/uploads\/.htaccess\r\nsudo chown www-data: -R \/var\/www\/\r\nsudo systemctl restart apache2<\/pre>\n<p>If the purpose of this server is to host multiple websites, enable <strong>Multi-Site<\/strong>. It creates a network where many websites can be managed from a single WordPress installation.<\/p>\n<p>The multiple sites would use one of the following address formats:<\/p>\n<p style=\"padding-left: 40px;\">example.com\/site1<br \/>\nexample.com\/site2<\/p>\n<p style=\"padding-left: 40px;\">OR<\/p>\n<p style=\"padding-left: 40px;\">site1.example.com<br \/>\nsite2.example.com<\/p>\n<p>For more flexibility, use <strong>Multi-Domain<\/strong> to support multiple domain addresses:<\/p>\n<p style=\"padding-left: 40px;\">example.com<br \/>\nanotherexample.com<\/p>\n<pre>sudo nano \/var\/www\/wordpress\/wp-config.php<\/pre>\n<p>Append the following lines:<\/p>\n<pre>\/* Multisite *\/\r\ndefine('WP_ALLOW_MULTISITE', true);<\/pre>\n<p>Go to WP Admin and navigate to Tools &gt; Network Setup, then select the subdomain option.<\/p>\n<p>The next page will show the configuration for <strong>.htaccess<\/strong>. Copy and paste it as instructed.<\/p>\n<p>Refresh the browser and a new option will appear in the top menu.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1711\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2020\/10\/Screenshot-from-2021-04-06-10-23-36.png\" alt=\"\" width=\"312\" height=\"40\" srcset=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2020\/10\/Screenshot-from-2021-04-06-10-23-36.png 312w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2020\/10\/Screenshot-from-2021-04-06-10-23-36-300x38.png 300w\" sizes=\"auto, (max-width: 312px) 100vw, 312px\" \/><\/p>\n<p>The multi-domain functionality works best with the <strong>WordPress MU Domain Mapping<\/strong> plugin (by Donncha O Caoimh).<\/p>\n<p>It is also good practice to implement a Web Application Firewall (WAF) on the server or through a third-party Content Delivery Network (CDN).<\/p>\n<p>A recommended WAF plugin is <strong>Wordfence Security &#8211; Firewall &amp; Malware Scan<\/strong> (by Wordfence). Cloudflare [<a href=\"https:\/\/www.cloudflare.com\/\">Link<\/a>] is a well-known CDN provider that offers free services as well as additional paid features.<\/p>\n<p>For backing up or migrating websites, the recommended plugin is <strong>Duplicator<\/strong> (by Snap Creek).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I just installed WordPress on my server and the first concern? Security! We will cover [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-405","post","type-post","status-publish","format-standard","hentry","category-web"],"_links":{"self":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/405","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=405"}],"version-history":[{"count":11,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/405\/revisions"}],"predecessor-version":[{"id":5826,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/405\/revisions\/5826"}],"wp:attachment":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=405"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=405"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=405"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}