How to Install phpRedisAdmin on CentOS 7
Introduction
phpRedisAdmin is a web application that manages Redis® databases with an intuitive graphic user interface.
This tutorial will explain how to install phpRedisAdmin on a Vultr CentOS 7 server instance.
Prerequisites
- Deploy a fresh Vultr CentOS 7 server instance.
- Log in as a non-root sudo user.
Step 1: Updating the system
Use the following command to update your CentOS 7 system to the latest stable status:
sudo yum update -y && sudo reboot
After the system restarts, use the same sudo user to log in.
Step 2: Installing Redis® from source
Since the version of Redis® in the YUM repo is out of date, you can install the latest stable version of Redis® from source, which is 3.2.0 at the time of writing.
Install dependencies:
sudo yum install gcc make
Install Redis® 3.2.0 to /opt/redis/3.2.0
:
cd ~
wget http://download.redis.io/releases/redis-3.2.0.tar.gz
tar -zxvf redis-3.2.0.tar.gz
cd redis-3.2.0
make
sudo make PREFIX=/opt/redis/3.2.0 install
As a matter of convenience, you can add the path of Redis® into the PATH environment variable:
sudo cp /etc/profile /etc/profile_backup
echo 'export PATH=$PATH:/opt/redis/3.2.0/bin' | sudo tee -a /etc/profile
source /etc/profile
echo $PATH
Step 3: Starting the Redis® server
For now, let's start the Redis® server using the default configuration:
redis-server
After the Redis® server starts, you will probably see several warning messages. Troubleshooting steps for various warnings are listed below.
First of all, stop the Redis® server by inputting the following command from another SSH console:
redis-cli shutdown
If you see "WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.":
echo 'net.core.somaxconn = 511' | sudo tee -a /etc/sysctl.conf echo '511' | sudo tee -a /proc/sys/net/core/somaxconn
If you see "WARNING overcommit_memory is set to 0!":
echo 'vm.overcommit_memory = 1' | sudo tee -a /etc/sysctl.conf sudo sysctl vm.overcommit_memory=1
If you see "WARNING you have Transparent Huge Pages (THP) support enabled in your kernel.":
echo 'never' | sudo tee -a /sys/kernel/mm/transparent_hugepage/enabled
Having these warning messages eliminated, run the Redis® server again:
redis-server
In another SSH console, run the Redis® CLI to input some data:
redis-cli
In the redis-cli console, you can manipulate any data as you wish:
127.0.0.1:6379> set key1 hello
OK
127.0.0.1:6379> get key1
"hello"
If you want to quit, Press Ctrl + C
.
Step 4: Installing Git, Apache, PHP and other dependencies
Install these components using YUM:
sudo yum install git httpd php php-redis php-devel php-mbstring
Here, I use Apache to serve phpRedisAdmin, you can choose Nginx or any other web server instead.
Modify the default settings of Apache in order to enhance security:
sudo sed -i 's/^/#&/g' /etc/httpd/conf.d/welcome.conf
sudo sed -i "s/Options Indexes FollowSymLinks/Options FollowSymLinks/" /etc/httpd/conf/httpd.conf
Create a virtual host for phpRedisAdmin:
sudo vi /etc/httpd/conf.d/phpRedisAdmin.conf
Populate the file with the following code segment. Be sure to replace the values of ServerAdmin, ServerName, ServerAlias, ErrorLog, and CustomLog with your own ones.
<VirtualHost *:80>
ServerAdmin xxx@example.com
DocumentRoot /var/www/html/phpRedisAdmin/
ServerName phpredisadmin.example.com
ServerAlias www.phpredisadmin.example.com
<Directory /var/www/html/phpRedisAdmin/>
Options FollowSymLinks
AllowOverride All
</Directory>
ErrorLog /var/log/httpd/phpredisadmin.example.com-error_log
CustomLog /var/log/httpd/phpredisadmin.example.com-access_log common
</VirtualHost>
Save and quit:
:wq
Step 5: Installing phpRedisAdmin
Download phpRedisAdmin using git
:
cd ~
git clone https://github.com/ErikDubbelboer/phpRedisAdmin.git
cd phpRedisAdmin
git clone https://github.com/nrk/predis.git vendor
Create the configuration file using a sample file:
cp includes/config.sample.inc.php includes/config.inc.php
Note: In the future, you can use this file to customize phpRedisAdmin, like adding more Redis® servers, enabling HTTP authentication, and such. But for now, let's use the default settings.
Move the directory to the virtual host location we setup earlier:
cd ~
sudo chown -R apache: ~/phpRedisAdmin
sudo mv ~/phpRedisAdmin /var/www/html
Step 6: Visiting phpRedisAdmin
Start and enable Apache:
sudo systemctl start httpd.service
sudo systemctl enable httpd.service
Modify firewall rules in order to allow visitors to access phpRedisAdmin:
sudo firewall-cmd --zone=public --permanent --add-service=http
sudo firewall-cmd --reload
Finally, visit phpRedisAdmin from your web browser. Be sure that redis-server
is running.
http://<your-Vultr-server-IP>
You will be presented with the interface of phpRedisAdmin, where you can view and manage your Redis® databases. This concludes the tutorial.