Tag Archives: CentOS

How to update Plesk via the Command Line

Plesk-LogoYou can update Plesk via the Web Interface (under Tools and Settings – Updates and Upgrades). However sometimes the interface times out, or browsers get confused – therefore it’s good to know that you can apply updates via the command line interface as well. In this article I’ll show you how (in Linux – I don’t know much about running Plesk on Windows I’m afraid).

We need to download the standard installer script for this. It’s a powerful little tool which can also be used to add or remove components from the current Plesk installation, or to install Plesk on a barebones server.

As of 2017 the link can be found here:

Screen Shot 2015-05-03 at 09.39.40

If you click the option “Download Plesk installer for Linux”, you’ll see the actual script open in a new browser tab. Not what we want, although you could copy and paste this into a new file on your Linux system. Instead, right-click on the link and choose “Copy Link” instead.

Screen Shot 2015-05-03 at 09.41.27

With that link in your clipboard, connect to your server via SSH and download the file with something like wget:

This will result in a file called “plesk-installer” with some nasty parameters at the end, several hundred characters in total. Let’s rename it to something easier and tweak the execution permissions:

Now we can run the script like so:

Follow the instructions to upgrade Plesk. You can also call the script with several options, for a full list of those call it with “–help”. To see all available versions of Plesk during the installation, use “–all-versions”, which will eventually lead you to a screen similar to this:

If you call the script without any parameters, only micro updates and additional components are applied. Micro updates are usually applied automatically if this feature is enabled (it is by default).

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.

 

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.

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:

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.

How to move the vhosts directory in Plesk

Plesk-LogoThe default directory for all web files in Plesk on Linux is /var/www/vhosts. Usually this works well, but if you’d like to use another partition instead, you’ll be pleased to hear that you can!

Parallels (or Odin as we call them now) have written a handy script which moves the content and patches the relevant configuration file and copies all content at the same time. The script is called transvhosts and you can download it here:

Download it using wget and make the file executable:

It’s a PERL script, which means it needs prefixed with ‘perl’ to be called. Say you want to move your vhosts directory to /home/vhosts, you’d call it like this:

This may take a moment or two depending on the amount of content you have in the current directory. The script will patch Plesk’s configuration file and restart the panel. There’s minimal downtime in involved in this process.

Getting started with Jekyll on CentOS 7

jekyll-iconIt’s not quite as easy to get up and running with Jekyll as the Quick Start Guide makes it sound. But it’s not super difficult either – if explained from one human to another.

Here’s how I got Jekyll working on a vanilla CentOS 7 instance.

Installing some necessary packages

Before we can install Jekyll using Rubygems, we need a few packages which aren’t with us by default. One comes from the Fedora EPEL repository, so let’s enable that first:

I love how easy this has become since CentOS 7! Next, some packages. We’ll need Ruby and the developer extensions. We also need a web server, so I’ll choose Apache – but I understand that others work just as well.

The installation guide doesn’t mention it, but it is actually mandatory to have a JavaScript runtime present, as mentioned in this project (which I guess Jekyll relies upon): https://github.com/sstephenson/execjs. Let’s choose NodeJS as its available from EPEL.

What this boils down to are the following packages:

Great! Now that Ruby is working, let’s install Jekyll via Rubygems:

This could take a moment, be patient. When it’s finished, let’s put Jekyll to work.

Creating and previewing a test site

Let’s call our new test site “test”. I’m assuming you’re in your home directory from which usually no web files shall ever be served – but thanks to Jekyll we can make that happen for local testing purposes. The following command will create a brand new site in the current directory:

Excellent! But how do we get to see it? Well Jekyll has created a directory called “test” for us. Let’s enter it and preview the site:

What Jekyll is trying to say is that IF we are building this on a system with a desktop environment, we could open a web browser and enter http://localhost:4000 now to preview the site. Jekyll spawns a web server on port 4000 so that we can see any changes we’ve made since last time without affecting a live site.

Sadly this approach doesn’t work on remote servers though, at least not for me: port 4000 on a remote server simply did not respond. Regardless, on the local sever it was working just fine, and we should see a picture like this:

Screen Shot 2015-03-05 at 19.40.06

That’s a good start – let’s put the site live so that our web server can show it to the world!

Building the site

Press CTRL-C to stop the preview serving procedure and ask Jekyll to create this site in our default web directory. In CentOS that’s /var/www/html. Mine is empty so I’ll create the site there using

Nicely done! Now let’s surf to http://localhost (without the 4000 at the end), and the local machine should see this content served up fresh just like any other website. Remote computers should use either the IP address or a domain resolving to it (say http://12.34.56.78).

Now that you know how it works, enjoy using Jekyll!

The Debian Experience: Cheat Sheet for CentOS and Fedora users

DebianI’ve just installed a LAMP stack on my Nook Tablet using Debian. However I’ve been using CentOS since 2008 and I’m so used to how things are done there that it was a bit of a culture shock doing relatively simple things “on the other side”. It’s like a country whose language you don’t speak well enough.

Here are a few pointers for how to so these simple things in Debian and Ubuntu, for CentOS and Fedora Users:

Installing Packages

While I’m used to yum and it’s super easy search and install options, its counterpart apt is very different. Searching for packages is done with

instead of yum list. Likewise, installing a package is done with

I believe the cache is not created automatically, so from time to time (or before an update/install operation) we need to run

To update all packages (equivalent to yum update), we have to run

There are other front ends available which I have not explored yet. aptitude is for the command line and appears to have a similar simplified syntax to yum. synaptic is for GNOME like environments.

 

LAMP Stack

Apache is called httpd on CentOS, but it’s called apache2 on Debian. Its system user does not run as apache:apache, but as www-data:www-data.

The web root directory is not in /var/www/html but instead in /var/www. File ownership should be tweaked to the above user in this directory. SELinux is not enabled by default.

The Apache config file is not in /etc/httpd/httpd.conf but in /etc/apache2/apache2.conf. The content however is the same, except for the system user which is defined in envvars in the same directory.

PHP is not just called php, but instead it’s php5 on Debian. This is true for all derivatives, such as

  • php5
  • php5-cli
  • php5-mysql
  • php5-gd

MySQL is still MySQL in Debian Wheezy, and not MariaDB (yet).

 

Starting and stopping services on boot

chkconfig does not work on Debian. Instead we can use a script called update-rc.d. Here’s how to enable something at boot:

And to disable something:

How to find which package provides a command in yum

CentOS-LogoSometimes you know you need a package, but when you try to install it with yum you’ll get a message like “No matches found”. Yet you’re sure the package exists because you’ve used it before.

This can happen if the package in question is part of a set which installs multiple packages. The net-tools package springs to mind.

yum has a great option called whatprovides with which you can query what package you need to install to use a command. Let’s try it out!

Say I wanted to install mkfs.vfat which is not installed by default in CentOS. Simply trying to install it won’t work:

Of course it won’t. But I can ask yum what provides this package:

Well fantastic! The package I’m looking for is called dosfstools. Knowing that, I can simply use yum install dosfstools, and a few moments later mkfs.vfat will work as expected.

Thanks, yum!

How to view local websites on your iPad with Squid

squidI like developing and testing websites on my local network before they go live. On both Mac and PC it’s easy to tweak the /etc/hosts file so that the URL doesn’t point to a numeric IP, but instead to http://yourserver (or something equally catchy).

On iOS devices we can’t tweak that file unless we deal with the highly unethical practice of jailbreaking. Turns out there is an easier way to surf local websites on mobile devices, simply by using a Proxy Server such as Squid.

A Proxy Server is often used as a caching server or to disguise where a request is coming from. For example, surfers use proxies to pretend they’re visiting from a different country, or ISPs  use proxies to speed up data delivery in local areas. In simple terms, a proxy is fetching data on our behalf. Then we talk to the proxy and get the data from him. Think of a Proxy Server as a middle man in a network transaction.

To surf local websites on an iPad or iPhone, we can connect to our WiFi network with a proxy on a machine on which we CAN tweak the /etc/hosts file. Let me show you how this works.

For this example I’m using a development server on my local network. It’s a simple LAMP Stack running CentOS.

 

Installing and configuring Squid

We’ll install Squid on the development server. Websites are accessible via http://localhost but also as something more swish when the /etc/hosts file is tweaked, for example http://yourserver.

Squid is available via yum, and installation is simple:

The second line will start Squid on every server restart, just in case.

Squid should work out of the box on port 3128, but if you ever need to tweak this, you can do so in /etc/squid/squid.conf.

 

Configuring the iPad Connection

When you connect your iOS device to your local WiFi network it will do this without a Proxy Server by default. We’ll change this under Settings – WiFi, then tap the little info icon next to your active connection. It goes without saying that the development server needs to be on the same network as your iPad.

At the bottom of this page, under “http proxy”, select manual and add your development/proxy server’s numeric IP, and 3128 under Port. Leave authentication off. It should look like this:

image-2

 

Now any tweaked URL that works on your development server will work on the iOS Device too: visit http://yourserver to verify this.

Should Safari give you a problem, maybe due to its spurious caching technology, head over to Settings – Safari – Clear History and Website Data.

 

Notes

Squid will cache every request you make on your iOS device as long as your WiFi connection uses the proxy setting. Chances are that your development server isn’t going to deliver results as fast as non-cahced results would come in from your router – unless you surf the same slow website over and over.

Also, Squid will leave a record of every request that has been made in /var/log/squid/access.log. If you’re using such a setup in your office, you may need to tell users on the network that their requests will be logged.

So if you’re concerned about any of these aspects, simply switch the proxy off in your WiFi settings.