• Get In Touch
February 6, 2017

How to Install phpList on CentOS 7

Want your very own server? Get our 1GB memory, Xeon V4, 25GB SSD VPS for £10.00 / month.
Get a Cloud Server

phpList is a free and open-source web application for managing mailing lists and sending newsletters. It is written is PHP and uses MySQL/MariaDB to store its data. phpList is a very powerful web application, it can handle a very large number of subscribers and send newsletters to them. It provides easy to use web interface to create the newsletter and send it. It comes with a messaging queue to stop sending duplicate messages or sending failures. You can personalize the emails and the applications according to your needs. The application also provides the feature to track how many emails have been open and links have been clicked. Apart from all these, it provides many features such as bounce management, HTML emails, attachments with email etc. phpList is widely used by users from 95+ countries. It is available in more the 20 different languages.

Requirements

phpList does not require any special hardware requirements. It can be installed on servers with a small amount of RAM. All the required dependencies will be installed throughout the tutorial. You will need a minimal installation of CentOS 7 with root access on it. If you are logged in as a non-root user, you can run sudo -i to switch to root user.

Installing phpList

Before installing any package it is recommended that you update the packages and repository using the following command.

yum -y update

Once you have your system updated, you can proceed to install the LAMP stack. Start the LAMP installation by installing Apache web server and MariaDB, which is a fork of MySQL using the following command.

yum -y install httpd mariadb-server mariadb

phpList can be installed on any version of PHP greater than 5.4. But as PHP 5.4 has reached the end of life. You can install PHP 7 for high performance. PHP 7 is not included in default YUM repository, hence you will need to add the Webtatic repository in your system. Webtatic repository requires EPEL repository to work. Run the following command to install EPEL repository.

yum -y install epel-release
yum -y update

Now install Webtatic repository using the following commands.

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum -y update

To install PHP 7.1 and all the required PHP modules, run the following command.

yum -y install php71w php71w-pcre php71w-imap php71w-core php71w-date php71w-gd php71w-hash php71w-spl php71w-mbstring php71w-filter php71w-openssl php71w-session php71w-curl php71w-xml php71w-iconv php71w-json php71w-gettext php71w-simplexml php71w-mysqli php71w-mysql php71w-cli

Make sure that you are using only one of the PHP versions mentioned above. Once you have PHP installed, you can check the version of PHP using the following command.

php -v
You should get an output similar to this.

[root@liptan-pc ~]# php -v
PHP 7.1.1 (cli) (built: Jan 19 2017 20:35:16) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies

Next, you will need to enable Mod_rewrite in Apache web server by editing /etc/httpd/conf/httpd.conf using your favorite text editor.

nano /etc/httpd/conf/httpd.conf

Find the following line.

<Directory "/var/www/html">
AllowOverride None

Change it to AllowOverride All.

Now start Apache web server and enable it to start at boot time using the following command.

systemctl start httpd
systemctl enable httpd

To start MariaDB and enable it to start at boot time using the following commands.

systemctl start mariadb
systemctl enable mariadb

Now run the following commands to secure your MySQL or MariaDB installation.

mysql_secure_installation

It will run a small script which asks you to provide the root password for MariaDB. As we have just installed MariaDB, the root password is not set, just press enter to proceed further. It will ask you if you want to set a root password for your MariaDB installation, choose y and set a strong password for the installation. It will also ask you for removing test databases and anonymous users. Most of the questions are self-explanatory and you should answer yes or y to all the questions.

To create a database we will need to login to MySQL command line first. Run the following command for same.

mysql -u root -p

This will prompt you for the password, provide the root password of MySQL which you have set earlier. Now run the following query to create a new database for your phpList installation.

CREATE DATABASE phplist_data;

The above query will create a database named phplist_data. For the database, you can use any name you prefer at the place of phplist_data.

Make sure that you use a semicolon at the end of each query as the query always ends with a semicolon. Once the database is created you can create a new user and grant all the permissions to the user for the database. Using root user is not recommended for the databases. To create a new database user, run the following query.

CREATE USER 'phplist_user'@'localhost' IDENTIFIED BY 'StrongPassword';

The above query will create a user with username phplist_user. You can use any preferred username instead of phplist_user. Replace StrongPassword with a strong password. Now provide the appropriate privileges to your database user over the database you have created. Run the following command.

GRANT ALL PRIVILEGES ON phplist_data.* TO 'phplist_user'@'localhost';

Now run the following command to immediately apply the changes on the database privileges.

FLUSH PRIVILEGES;

Exit from MySQL prompt using exit command.

As we have all the dependencies ready, we can now download the install package from the phpList site.

cd /tmp
wget https://downloads.sourceforge.net/project/phplist/phplist/3.3.0/phplist-3.3.0.zip -O phplist.zip

The above command will download the installer archive and store it as phplist.zip. You can always look for the latest release by going to the phpList download page.

Extract the archive using the following command.

unzip phplist.zip

If you don’t have unzip installed, you can run yum -y install unzip. The above command will extract the files under phplist-3.3.0 directory. To move all the files from Upload folder to the default web root directory, use the following command.

mv /tmp/phplist*/public_html/* /var/www/html/

Now you will need to disable your SELinux because phpList does not work with SELinux policies. To temporary disable SELinux, run the following command.

setenforce 0

To completely disable the SELinux you will need to edit
the /etc/selinux/config file.

nano /etc/selinux/config

If you don’t have nano installed, you can install it using yum -y install nano. Find the following line:

SELINUX=enforcing

Change it to:

SELINUX=disabled

Now you will need to reboot your server so that the new configuration can take effect. Once the server is rebooted, you will need to provide the ownership of the application to web server user using the following command.

chown -R apache:apache /var/www/html

You may also need to allow HTTP traffic on port 80 through the firewall if you are running one. Run the following commands for same.

firewall-cmd --zone=public --permanent --add-service=http
firewall-cmd --reload

Now edit the default configuration file config.php using the following command.

nano /var/www/html/lists/config/config.php

Find the following lines.

// what is your Mysql database server hostname
$database_host = 'localhost';

// what is the name of the database we are using
$database_name = 'phplistdb';

// what user has access to this database
$database_user = 'phplist';

// and what is the password to login to control the database
$database_password = 'phplist';

Change the value of the database name to the database we have created earlier to store the data. Further provide the username and password of the database user which we have created earlier. Further find the following line.

define('TEST', 1);

Change the above 1 to 0. It should look like shown below.

define('TEST', 0);

Save the file and exit from the editor.

You will also need to remove the index.html page. Run the following command to do so.

rm /var/www/html/lists/index.html

Now complete the installation using a web browser, go to the following link using your favorite web browser.

http://YourServerIP/lists/admin

You will see the following interface.

HP_NO_IMG/data/uploads/users/e840080c-7322-4497-85c0-150182bd4c02/1827142117.png” alt=”” />

Click on Initialise Database link. Now enter your name, organization name, your email, and password for your administrator account. The default username for administrator account is admin.

HP_NO_IMG/data/uploads/users/e840080c-7322-4497-85c0-150182bd4c02/88050413.png” alt=”” />

Once the database is initialized, click on phpList setup button at the bottom of the page. You will be taken to the configuration page, where you can further configure the application.

HP_NO_IMG/data/uploads/users/e840080c-7322-4497-85c0-150182bd4c02/960992816.png” alt=”” />

You can now configure the application or simply access the dashboard by clicking Dashboard link from the sidebar.

HP_NO_IMG/data/uploads/users/e840080c-7322-4497-85c0-150182bd4c02/1825893684.png” alt=”” />

Conclusion

In this tutorial, we have learned how to install phpList on CentOS 7. You can now easily install phpList to send the newsletters to your subscribers to promote your business. You can also easily manage the subscribers through the phpList interface.

Want your very own server? Get our 1GB memory, Xeon V4, 25GB SSD VPS for £10.00 / month.
Get a Cloud Server

Share this Article!

Related Posts

Node.js Authentication – A Complete Guide with Passport and JWT

Node.js Authentication – A Complete Guide with Passport and JWT

Truth be told, it’s difficult for a web application that doesn’t have some kind of identification, even if you don’t see it as a security measure in and of itself. The Internet is a kind of lawless land, and even on free services like Google’s, authentication ensures that abuses will be avoided or at least […]

Node.js and MongoDB: How to Connect MongoDB With Node

Node.js and MongoDB: How to Connect MongoDB With Node

MongoDB is a document-oriented NoSQL database, which was born in 2007 in California as a service to be used within a larger project, but which soon became an independent and open-source product. It stores documents in JSON, a format based on JavaScript and simpler than XML, but still with good expressiveness. It is the dominant […]

Using MySQL with Node.js: A Complete Tutorial

Using MySQL with Node.js: A Complete Tutorial

Although data persistence is almost always a fundamental element of applications, Node.js has no native integration with databases. Everything is delegated to third-party libraries to be included manually, in addition to the standard APIs. Although MongoDB and other non-relational databases are the most common choice with Node because if you need to scale an application, […]

Node.Js Vs Django: Which Is the Best for Your Project

Node.Js Vs Django: Which Is the Best for Your Project

Django and NodeJs are two powerful technologies for web development, both have great functionality, versatile applications, and a great user interface. Both are open source and can be used for free. But which one fits your project best? NodeJs is based on JavaScript, while Django is written in Python. These are two equally popular technologies […]

Nodejs Vs PHP:  Which Works Best?

Nodejs Vs PHP: Which Works Best?

Before getting into the “battle” between Node.js and PHP we need to understand why the issue is still ongoing. It all started with the increased demand for smartphone applications, their success forcing developers to adapt to new back-end technologies that could handle a multitude of simultaneous requests. JavaScript has always been identified as a client-side […]