How to install Pelican on CentOS 7 using Python 3

As you already know, Pelican is not a content management system like WordPress, it is a Python static blog generator – there is not database, nor a web interface. We use reStructuredText or Markdown to create the posts and pages and the entire content is flat-file based and managed by the CLI. This type of storage gives you the chance to manage the posts and if necessary to migrate them. As Scriptogram appears to be Pelican-based, you can move the files and posts (including permalinks) without changing them at all. Today we will show you how to install Pelican on CentOS 7 using Python 3. Let’s get started!

1. Install Python 3.6.5

We’ll show you a quite easy method to install Python. We add a repository with pre-complied version ready for us to install. Inline with Upstream Stable repository is now added, which is a community project with an aim to bring new versions of software to systems based on RHEL.

The first step is to open a terminal and to add the repository to your Yum install.

sudo yum install -y https://centos7.iuscommunity.org/ius-release.rpm

In order to finish the repository Update Yum.

sudo yum update

Next, you need to download and also install Python, and at the same time it will also install pip, something that will help you install add-ons.

sudo yum install -y python36u python36u-libs python36u-devel python36u-pip

When these commands are finished, all you have to do is to check whether you have installed the right version of Python and you can do that following this command:

python3.6 -V

Now you are done installing Python 3.6.5 on your CentOS 7 machine, as well as installing a native Python package management tool called pip.

2. Installing Pelican

You have the chance to choose one of many different methods of installing Pelican. The simplest is via pip:

pip3.6 install pelican

(Don`t forget that operating systems will often require you to prefix the above command with sudo to install Pelican system-wide.)
If you installed a stable Pelican release via pip and wish to upgrade to the latest stable release, you can do that just by adding --upgrade:

pip3.6 install --upgrade pelican

Even though this may be the simplest method, we recommend to create a virtual environment for Pelican via virtualenv prior installing Pelican.

pip3.6 install virtualenv

Let`s assume that you have already installed virtualenv, now you need to open a new terminal session and then to create a virtual environment for Pelican:

virtualenv ~/virtualenvs/pelican
cd ~/virtualenvs/pelican
source bin/activate

At this point you are ready to install Pelican (and you should also install Markdown since you will want to create content).

$ pip3.6 install pelican Markdown

Pelican is able to build a skeleton for your site and that will set up directories within the pelican directory to keep your content, html which will be built for you by Pelican, and all of your necessary configuration files. Navigate to your www folder where you’ll want to save your site and content to (for example, /var/www/html/pelican), then enter:

$ pelican-quickstart

You should not hesitate to use the Return key in order to accept the default values for the questions with default values denoted in brackets. You should enter your domain name when you are asked for URL prefix (e.g.,http://your_domain.com).

If you use Markdown format to write your content, you will be able to provide this metadata in text files by following syntax:

Title: My first site
Date: 2018-04-30 11:21
Modified: 2018-05-04 19:46
Category: Python
Tags: tutorial, pelican

At this stage, if you prefer, you can use Markdown to create content and save the file in the /content directory inside your environment directory which was created at the beginning. Save the files using the .md or .markdown extension and then, while you are still inside the content directory, run the following command:

pelican content

Next thing to do is to move to the /output directory and run the pelican server using the folloing command:

python -m your_domain.server

If you want to test your content and site, you should open a browser and go to the address http://localhost:8000

3. Apache Virtualhost Setup

Now we will need an Apache VirtualHost to be reconfigured so that when we visit http://your_domain.com/ in a browser, our local Apache server will serve up our local pelican development site.

If you still don`t have Apache installed, you can do that with this command:

yum install httpd

Once you have done that, a file called your_domain.conf will be created in /etc/apache2/sites-available/.

nano /etc/apache2/sites-available/your_domain.conf

and paste the following text:

<code>    ServerAdmin admin@your_domain.com
    ServerName  your_domain.com www.your_domain.com

    # Index file and Document Root (where the public files are located)
    DirectoryIndex index.php index.html
    DocumentRoot /var/www/html/pelican/output/
 </code>

Now, you should create sublink:

ln -s /etc/apache2/sites-available/your_domain.conf /etc/apache2/sites-enabled/your_domain.conf

and then you need to restart apache

 service httpd restart

Open your browsers and navigate to your domain http://your_domain.com/ to see your Pelican development site.


 install Pelican on CentOS 7 using Python 3Of course you don’t have to install Pelican on CentOS 7 with Python 3, if you use one of our optimized Python VPS Hosting, which case you can simply ask our expert Linux admins to install Pelican on CentOS 7 using Python 3,  for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post, on how to install Pelican on CentOS 7, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Leave a Comment