3 ms·
Some more advice for HN users of WP: 1) chmod /var/www/whatever and all subdirectories such that the web server user can read but not write to them. If you ne
by patio11 15y ago
Some more advice for HN users of WP:
1) chmod /var/www/whatever and all subdirectories such that the web server user can read but not write to them. If you need to do uploads or add a plugin, you can do it over SSH. Allowing someone to execute arbitrary code from your website is just asking for pain.
2) Many (but not all!) exploits start in wp-admin. I make mine inaccessible over the public Internet, enforced ny Nginx before any PHP gets the chance to execute. (Options: only accessible over VPN, only accessible through proxy you control, only accessible with a client certificate, etc.)
3) Routine DB/code backups. I'd keep wp-content in a git repo. Add a plugin? Have to add it through repo. Code changes other than through git? Smack yourself for setting permissions wrong, then roll back to a known good version from the repo. Weird links on blog pages? Roll back DB to known good version.
4) Should go without saying, but every blog gets it's own user and own DB, and that user only gets sufficient privileges to manipulate the blog DB.
5) Write a shell script to do an automatic "upgrade all blogs to latest version of WP" since you'll be doing this a lot. If this were totally risk-free I'd put it on an hourly cron job.
- ryan-allen 15y agoI think point #1 is very important. I do this also: * All code is owned by a 'code' user, and all files by default are user and group read/write. * The www-data user (who runs the web server) can only write to wp-content/uploads and where ever else the plugins are required to write to * The places www-data can write to have .htaccess files that turn off execution of PHP scripts (so the app itself cannot upload code and run it, if there is a zero day exploit like the timthumb.php). What this causes though is a bunch of plugins to complain they cannot work due to not enough access, and WP upgrades can't be done through the wp-admin, this tends to upset end users a bit, so I agree #5 is important. I have a deploy user who is in the code group so I can manage our automated deploys. Also, by default wp-admin doesn't have any login restrictions so people can brute force it (I think). It's really important to install something like the wp-recapcha plugin so people can't brute force your logins. This is especially important as end users who are creating accounts often choose poor passwords. I like #2, I don't do this, though I think I'm going to have to! Generally it comes down to typical system admin best practices. You're running a codebase you didn't write yourself, you have no idea what it's going to do. EDIT: These permission things are not typically doable if you're running your blog on shared hosting. So shared hosting is generally not particulary safe. I'd recommend anyone without a dedicated sysadmin to use something like http://page.ly/ http://page.ly/, which is managed by smart guys.
- dbarlett 15y agoStay away from Page.ly unless you like unannounced maintenance during business hours. I've also seen frequent outages they blame on Firehost networking and SAN.
- ryan-allen 15y agoAh, well that's unfortunate. Have you got any other managed providers you can recommend?
- dbarlett 15y agoMy client decided to move to a VPS, but http://wpengine.com/ http://wpengine.com/ looked promising.
- mildweed 15y agoI've been looking for a good #5 for a while. Could you point me to one?