Monthly Archives: April 2015

How to fix WordPress Media upload trouble caused by open_basedir restriction

I’ve recently migrated a WordPress site from one server to another (running Plesk) and noticed that file uploads were no longer working. All existing files showed up fine, but new uploads were always aborted with a message such as “Is your uploads directory writable?” – which of course it was.

Here’s what it looked like – a familiar sight for anyone with WordPress issues:

Screen Shot 2015-04-27 at 11.29.46

Uploads had been working fine on the pervious server, and other sites on the new server didn’t have a problem. Puzzles like that rob me of sleep and sweet dreams. I decided to poke into any error logs on the new server (which wasn’t even that new mind you).

To my surprise I found that in /var/www/vhosts/system/domain.com/logs, there was an error log that was seemingly growing out of control very quickly. At one point it was over 500GB in size. Obviously this had a very adverse effect on the that server, which was running out of space when it shouldn’t have.

The repeating error message was this:

Sure I thought, I can understand why the server had a problem with this: the path is just NOT where domain data is saved on my target server. Why was it addressing a path that may have worked on the source server? Shouldn’t WordPress adjust itself automatically?

Why yes, usually it does – unless of course there’s an old database entry that specifies this path. Many options have been removed from the WordPress admin interface over time, but the values that could be set are still in effect. Thankfully it was an easy fix – even though it took me days to think of this: that nasty path was defined under Settings – Media:

Screen Shot 2015-04-27 at 11.28.24

Anything in the top field is a full server path. If it starts with a slash it’s a root path, while no slash at the beginning is a relative path. A wrong path (like mine) messed up all future uploads. All I had to do was delete anything in that field.

Note that this option only shows up if a path is defined: as soon as I cleared the field, the option disappeared.

Thanks to cleasterwood for this tip, who had this problem 5 years ago (goes to show how old my WordPress installation really was):

As for that huge 500GB log file, that’s another story: simply deleting it was not enough to free up space on the server. Because Apache kept an open write connection to that file, I was still running low on space – even though the file was gone. Restarting Apache didn’t do the trick either.

What did work here was a full server restart. It took a little longer than usual, but the massive log file was gone, and over 500GB of space was back at my disposal. And more importantly, my WordPress instance was accepting uploads again.

Phew!

How to open SMTP port 587 to send emails in Plesk

Plesk-LogoBy default Plesk on Linux uses Postfix for outgoing email, and by default listens on port 25 for outgoing SMTP mail. Some service providers do not allow to send emails on that port, and tragedy occurs: clients can’t send email with their Plesk servers. Not good.

Other SMTP ports will usually work, such as the other favourite 587 – but by default, Postfix is not listening on this port for email submissions – at least not in Plesk 12.0.8 on CentOS 7.

Here’s how to enable port 587 for such ventures:

Open the Postfix configuration file at /etc/postfix/master.cf and find the following line. It’s commented out. All we have to do is to remove the hash in front of it, and email can be sent via port 587:

Restart Postfix for the changes to take effect. In CentOS 5 and 6:

This will also work in CentOS 7, but to be more precise:

Happiness!

Note that port 587 needs to be open in your firewall. If the Plesk Firewall Extension is enabled, it’ll take care of it for you automagically.

 

  • http://blog.mailgun.com/25-465-587-what-port-should-i-use/
  • http://www.faqforge.com/linux/how-to-enable-port-587-submission-in-postfix/
  • http://know.mailsbestfriend.com/how_to_enable_port_587_submission_in_postfix-1932675618.shtml
  • a Plesk 11 alternative: http://kb.sp.parallels.com/en/114417

What is the Prove your Humanity login feature in WordPress

Screen Shot 2015-04-21 at 08.31.32

Some of my clients have recently noticed a new math question on their WordPress login screen. It prompts to Prove your humanity in addition to your user name and password.

This feature was recently introduced in Jetpack as part of the Protect Feature, which prevents hackers from trying to gain access to your WordPress site via brute-force attacks. Prove your humanity means that bots have a hard time logging in. You can even see how many times Jetpack has prevented unsuccessful login attempts.

To remove the math question you can whitelist your own IP so that Jetpack knows you’re logging in from a legitimate address. To do this, login to your admin interface and head over to Jetpack – Settings – find the Protect Feature and hit Configure. This brings up a window similar to the one below.

Screen_Shot_2015-04-23_at_09_38_18

You will see your current IP address. Add it to the list and click save – and you won’t see the additional math question again, provided you login from the same IP. Repeat the process and add additional IPs if needed. If you have multiple users on your team who all contribute to the site, ask them to provide their IP via http://whatsmyip.org or similar services.

If you’ve been accidentally logged out can cannot gain access to WordPress anymore, you can add a single IP address to your wp-config.php file by defining the following constant:

Replace 12.34.56.78 with your actual IP address (obviously).

How to turn off all Plesk Health Monitor alert emails

Plesk-LogoI have previously described how to adjust the values that the Plesk Health Monitor uses to determine when an email should be sent out.

There is also a way to switch these emails off entirely. Here’s how:

To turn off the daemon that is responsible for sending these emails, issue this:

No more emails until you restart the server, when the daemon will be resumed. If you don’t want that, switch it off at boot time using

To remove the Health Monitor altogether, head over to Tools and Settings – Updates and Upgrades and uninstall the component.

  • http://forum.odin.com/threads/constant-alarm-level-changed-emails.261363/page-2
  • http://www.devblog.co/how-to-disable-health-monitoring-notifications-from-parallels-plesk/

How to fix Apache/NGINX trouble after restarting your Plesk server

Plesk-LogoSome of my servers have a weird habit of throwing an Apache error after a restart: NGINX is running fine, but Apache can’t start and all websites are down. I have no idea why some servers do it and some do not. But when they do, it’s just plain annoying.

Here are two ways to fix this problem.

Restart Apache gracefully

The quickest option is to shutdown NGINX, restart Apache, tell it to shutdown gracefully and then bring up NGINX again. Here are the commands that will work on CentOS 7:

Likewise, on CentOS 6 we can use the service command to do the same:

Note that Apache doesn’t always like a restart – in which case, stop the service first, give it a moment and then restart it. Quirks and habits I guess.

Thanks to Mike Yrabedra for this tip!

If you find yourself doing this a lot, consider writing a quick script with the above commands, or restart your server less often (sometimes it’s enough to restart Plesk, or not reboot the machine at all). Alternatively, you can remove NGINX altogether and avoid such problems in the future.

Removing NGINX from Plesk

NGINX is not necessary – Apache will do a good job by itself. If you want to get rid of it completely, head over to Tools and Settings (or the Server Tab if you’re in Power User Mode) and select Updates and Upgrades. You’ll be taken to the Parallels Installer. Select Add/Remove Components.

Screen Shot 2015-04-21 at 08.10.45

Scroll down to the NGINX section under Web Hosting Features and untick both NGINX options. Now click Continue at the bottom and NGINX will be removed, leaving Apache in charge for all website connections. There’s no need to restart Plesk.

Screen_Shot_2015-04-21_at_08_11_17

Why would anyone want to use both NGINX and Apache together?

Very good question indeed. Both are excellent web servers, and logic dictates that you should use one or the other. Using two web servers together is a certain sign of trouble.

From what I understand, NGINX is not designed to be a replacement web server in Plesk (even though NGINX can be used in this way on a LAMP Stack). Instead it is implemented as an enhancement to Apache, sitting in front of it. Static files are therefore served from NGINX via Apache, and NGINX acts as a reverse proxy server.

The benefits are faster connections and a smaller memory footprint. Read more about how NGINX and Apache are implemented in Plesk in the following articles:

  • http://download1.parallels.com/Plesk/Doc/en-US/online/plesk-administrator-guide/index.htm?fileName=70837.htm
  • http://download1.parallels.com/Plesk/Doc/en-US/online/plesk-administrator-guide/index.htm?fileName=71997.htm

How to setup Plesk Mail in Mozilla Thunderbird for Windows

In this episode I’ll show you how to setup Plesk Mail in Thunderbird for Windows. Unlike most email clients, Thunderbird can figure out the correct settings by itself – something neither Outlook nor Mac Mail can do. Therefore, the real magic with Thunderbird is figuring out how to get to the account settings.

To do so, click the three little lines next to the search box. It will bring up a fly-out menu. Under Options – Account Settings, setup a new account or change the settings for an existing one.

TB-Demo

Thunderbird is clever usually enough to detect the settings it needs to connect to the Plesk server. In case it fails, use the following:

  • STARTTLS as encryption
  • Authentication: use encrypted password
  • your full email address as user name (such as you@domain.com)
  • Port 143
  • Outgoing Mail Server: Port 587
  • Incoming Mail Server: Port 143 OR 993

Good luck!

Catch this episode on my WP Guru Podcast:

How to setup Plesk Mail in Microsoft Outlook for Windows

In this episode I’ll show you how to setup Plesk Mail in Microsoft Outlook on Windows. It’s often a big stumbling block for users. The instructions will also work for Microsoft Essentials, the predecessor of Outlook Express. I’m using Outlook 2010 here, but the instructions are also applicable to later versions.

The two important windows are under Account Settings, there’s a window with six tabs. One of which is labelled Outgoing Server and the other one is called Advanced:

Screen Shot 2015-04-13 at 18.16.03

 

Screen Shot 2015-04-13 at 18.16.13

Make sure Outlook is set to use TLS for both incoming and outgoing connections. The Root Folder Path needs to be set to INBOX (in all capitals).

Good luck 😉

Catch this episode on my WP Guru Podcast:

LAMP Stack for Humans – now available on Amazon

Lampstack-SoftcoverMy book LAMP Stack for Humans is now available on Amazon, as Paperback and for Kindle Devices!

In this 284 page guide I’ll walk you through the process of turning an old laptop into an always-on server. You can use it to run web applications in the comfort of your own home or office – no “cloud” required.

Together we will configure the entire server: you will learn how to install CentOS, Apache, PHP and MySQL (or MariaDB) and WordPress. I will show you how you can reach your server from other computers on the network and how to create regular backups.

Perfect for the Linux newbie and those who want to get started with web applications without spending money “in the cloud” (in my opinion THE WORST expression for describing remote computers).

If you’re an avid reader of this site and have always wished that some instructions would be presented in a more cohesive form rather than in snippets, then LAMP Stack for Humans is perfect for you.

Grab your free sample today, or read the entire book for free via Kindle Unlimited!

Continue reading LAMP Stack for Humans – now available on Amazon

How to edit your network connection settings from the command line in CentOS 7

CentOS 7 has a very funky text-based user interface that allows editing several important network connection settings. It’s called nmtui.

Type the command without any parameters to get started:

Now use this handy interface:

Screen Shot 2015-04-09 at 16.22.13

Screen Shot 2015-04-09 at 16.22.59

Screen Shot 2015-04-09 at 16.22.33

Your system may require a full restart for all settings to take affect.

  • https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Networking_Guide/sec-Networking_Config_Using_nmtui.html

How to allow resuming FTP uploads in Plesk and ProFTP

Plesk-LogoProFTP has a handy feature that lets uploads resume if they were interrupted, much like Safari downloads. This feature has to be enabled both on the server and the client.

By default however, resuming uploads are disabled for security reasons – a wise precaution if anonymous uploads are allowed to a server. Here’s how to enabled it.

Plesk uses ProFTP, and all we have to do is add a couple of lines to the /etc/proftpd.conf file. Anywhere will do, as long as it’s outside the “global” tags:

ProFTP is part of the xinetd system service, and for the change to take effect we’ll have to restart this:

To make use of this feature, an FTP client needs to support this feature too: in FileZilla it’s under Settings – Transfers – File Exists Action:

Screen Shot 2015-04-09 at 12.40.26

  • http://soulhuntre.com/2005/01/27/plesk-proftpd-and-resume/
  • http://www.proftpd.org/docs/directives/linked/config_ref_AllowStoreRestart.html