My intention with this project was to try other cpanel alternatives which I could possibly use to manage hosting for 25 WordPress sites. This tutorial covers how I tried the simple cpanel from Server Pilot to manage my Digital Ocean VPS. Simple by no means short in features. Server Pilot uses the LAMP/LEMP stack to combine Apache and Nginx when delivering performance for PHP websites. To know more how Server Pilot puts together these two Open Source web servers to work click here. You can read up more about Server Pilots features here.
How to create a VPS on Digital Ocean
Choose region where your server will be hosted.
Choose the operating system. At the moment Server Pilot will only work with Ubuntu 12.04 and Ubuntu 14.04 64 bit versions.
Click Create Droplet.
How to connect your Digital Ocean VPS to Server Pilot
Connect DigitalOcean server to Server Pilot by clicking Connect Server.
Take note this only applies to Ubuntu 12.04 or 14.04 at the moment. If you prefer other Linux distros you’re out of luck for now.
Then SSH to your Digital Ocean server using the root account.
ssh -l root 126.96.36.199 (IP address of your Droplet)
paste the install script you just copied onto the console.
Grab a cup of coffee while Server Pilot does all of the hard work configuring your server.
From the Server Pilot Dashboard you will see PHP, Apache, NginX being setup for you.
It may appear done on the command line but let the setup complete on the Server Pilot dashboard before doing anything else. When you get this part you’re server has been setup successfully by Server Pilot.
WordPress Hosting using Apache, Nginx and PHP-FPM
How to install WordPress on Server Pilot
Serverpilot refers to any PHP application you want your server to host as an App be it an WordPress, Joomla, Concrete5, etc. Click on New App to get started.
Enter required details of your app.
Under domain name this would be like – example.com
You’re given the option to choose from three versions of PHP to use.
Server will be your Digital Ocean server.
System user the user created by Serverpilot which by default is named serverpilot.
Click create app.
Details of your newly created app.
By default Server Pilot creates a system user on your server. This will be the user account which you will use to SSH to your server to download WordPress.
Click the account serverpilot under System User.
Put in your password. Click update.
SSH to your Digital Ocean server using the ServerPilot account.
ssh -l serverpilot 188.8.131.52
Once logged in these will be the files and directories available in your serverpilot user account.
Create a Database for your WordPress app to use. Click Databases.
Install WordPress on Server Pilot
cd apps/wordpress/public wget https://wordpress.org/latest.tar.gz tar xzf latest.tar.gz mv wordpress/* . rm latest.tar.gz rmdir wordpress
From your web browser go to the IP address or domain name of your Digital Ocean server. This will then run the WordPress installer, follow the prompts. Enter your database name, password, database host and WordPress database prefix.
When your database information has been accepted you will now be able to run installer.
Fill out your WordPress, information and username. Do not use admin or administrator. This first account will have administrator rights so name it to something uncommon.
If you type in your domain name you should be able to see your brand new WordPress, site.
Install Webmin on Server Pilot
I want to be able to manage my server using a web interface for this I will install Webmin.
Add the Virtualmin Repositories.
deb http://software.virtualmin.com/gpl/debian/ virtualmin-wheezy main deb http://software.virtualmin.com/gpl/debian/ virtualmin-universal main
Add the Virtualmin Software GPG keys.
wget http://software.virtualmin.com/lib/RPM-GPG-KEY-virtualmin wget http://software.virtualmin.com/lib/RPM-GPG-KEY-webmin apt-key add RPM-GPG-KEY-virtualmin apt-key add RPM-GPG-KEY-webmin
Install the following.
apt-get install webmin
apt-get install webmin-virtualmin-nginx webmin-virtualmin-nginx-ssl
The first time you login to Webmin at http://184.108.40.206:10000 change this to your server IP address.
You will be greeted by the Virtualmin wizard ignore this for we will delete this module.
Go to Webmin menu > Webmin configuration > Webmin modules > then click delete.
Delete it too from users and reset settings. Click delete.
How to setup Webmin Nginx module on Server Pilot
Nginx is the public-facing server ServerPilot runs on your servers. Nginx listens on ports 80 and 443 of all network interfaces, both IPv4 and IPv6.
To restart Nginx via command line:
service nginx-sp restart
Global log directory: /var/log/nginx-sp
Configuration setup for Webmin Nginx module.
This is what will appear on the Nginx Webmin configuration page. I currently have one WordPress site hosted on this server as shown.
How to setup Webmin MySQL module on Server Pilot
The first time you click on the Webmin MySQL module you will be prompted for the root password. Enter the root for login and the root password then click Save.
How to restart via command line:
service mysql restart
Global log file: /var/log/mysql.log
Global error file: /var/log/mysql.err
How to backup MySQL databases on Server Pilot
Click on backup databases.
to check created scheduled it is under cron webmin module
How to setup Webmin Apache module on Server Pilot
Click on Apache module from the un-used modules menu. When you do you will get this.
Only click Module config!
Set configuration options as shown on image.
Set system configuration as shown on image.
Where it appears cut off set the following to.
Path to the apachectl command: /opt/sp/apache/bin/apachectl
Path to httpd.conf or apache2.conf: /etc/apache-sp/httpd.conf
Path to mime.types: /etc/apache-sp/mime.types
Path to Apache PID file: /opt/sp/apache/var/logs/httpd.pid
Apache variables what is shown on image.
Where it appears cut off.
Environment file defining Apache variables: /opt/sp/apache/bin/envvars
Apache Webmin module will now show websites hosted on your droplet.
How to create an alias redirect for my WordPress website on Server Pilot
How I did it using the Apache Webmin module by clicking the virtual server-wordpress app icon.
Then clicking Aliases and redirects.
On Temporary URL redirects I added the URL to send the user to when they type /dummy to http://joealdeguer.com/how-to-install-pfsense-firewall-including-using-virtio-drivers/
From the command line this can be done by editing this file.
Add the line below just before </VirtualHost>
RedirectTemp /dummy http://dev.joealdeguer.com/how-to-install-pfsense-firewall-including-using-virtio-drivers/ To add more redirects just place it on the next line and so forth.
Then restart Apache to apply the new configuration.
service apache-sp restart
How to manage global PHP configuration on Server Pilot
To setup Webmin PHP configuration the following have to be set.
From the Unused-modules menu go to PHP configuration the click on module config. Add the following as shown below. Click save.
If you want to manage the php.ini file for each app just click on manage.
To manage individual php.ini file for each user account add the last line shown on image below into the module config. Add more for each user or each app you create.
How to Backup users and PHP websites on Server Pilot
Create a directory to store your backups on the local server.
1. From Webmin > System menu > File System Backup, click on browse
2. Expand TAR filesystems backup details. Backup each user account using the path /srv/users/serverpilot.
3. Expand backup options. Below are settings which I used.
4. Expand backup schedule. Make sure backup is enabled by choosing the option enabled at times chosen below. Fill out the email address to send confirmation backup was done. Choose your schedule using simple or complex then click Create and Backup Now.
You will now have a scheduled backup.
Repeat the process for each user if you have more than one.
How to restore users on Server Pilot
1. From your schedule filesystem backups click on the user schedule you want to restore.
2. Click Restore. Set restore to directory to root /. This will restore all of the files to /srv/users/useraccount (This will be the account being restored). The settings below will overwrite all files.
How to backup PHP websites and MySQL databases to a remote server on Server Pilot
1. This is done on the remote server. Create an account on the remote server which will hold the backups.
2. This is done on the remote server. Create a directory under the user account you will be using to login as.
3. Done on the server managed by Server Pilot. Expand TAR Filesystem Backup details. Fill out host IP address of remote server. Enter the username of the user you will be logging as on the remote server. Fill out the path to the remote directory where the backup will be copied to. The remote command to be used will set to SSH. Fill out the password for the remote user account.
4. Done on the server managed by Server Pilot. Expand Backup options. Copy the settings shown on the image below.
5. Done on the server managed by Server Pilot. Expand Backup schedule. Set your schedule then click Save and Backup Now.
Server Security Updates
From the Server Pilot dashboard I have automatic security updates enabled. This will allow the Server Pilot to apply security updates without my intervention.
I have this set to off. For my setup I am using CSF firewall install using this guide. After installing and setting up CSF, disable uncomplicated firewall from booting up. Click now and on boot.
How to install Malware Scanner on Server Pilot
Install the following software:
apt-get install clamav clamav-daemon zoo unzip bzip2 arj nomarch lzop cabextract apt-listchanges libnet-ldap-perl libauthen-sasl-perl clamav-docs daemon libio-string-perl libio-socket-ssl-perl libnet-ident-perl zip libnet-dns-perl
Download new virus definitions.
Start the clamav-daemon
service clamav-daemon start
Scanning for viruses using Maldetect.
Maldetect will use the Clamscan binary as the scanner engine to do scans for it will be faster.
One of the Joomla websites I was hosting got infected by malware which started to send hundreds of spam emails. I was able to fix it by using Maldetect. When I ran Maldetect it was able to find the Malware which was then quarantined. I now have a cron job which will run maldetect daily to scan all of the home directories for websites I host. Has your website been taken over by a spambot? Give Maldet a try to resolve the problem.
cd /usr/local/src wget http://www.rfxn.com/downloads/maldetect-current.tar.gz tar -xzvf maldetect-current.tar.gz cd maldetect-1.4.2 ./install.sh
Once maldetect has been installed the following settings have to be changed.
# [ EMAIL ALERTS ] ## # The default email alert toggle # [0 = disabled, 1 = enabled] email_alert=1 # The subject line for email alerts email_subj="maldet alert from $(hostname)" # The destination addresses for email alerts # [ values are comma (,) spaced ] email_addr="firstname.lastname@example.org" # Ignore e-mail alerts for reports in which all hits have been cleaned. # This is ideal on very busy servers where cleaned hits can drown out # other more actionable reports. email_ignore_clean=0 ## # [ QUARANTINE OPTIONS ] ## # The default quarantine action for malware hits # [0 = alert only, 1 = move to quarantine & alert] quar_hits=1 # Try to clean string based malware injections # [NOTE: quar_hits=1 required] # [0 = disabled, 1 = clean] quar_clean=1
There is even an option to suspend a user account infected by malware.
# The default suspend action for users wih hits # Cpanel suspend or set shell /bin/false on non-Cpanel # [NOTE: quar_hits=1 required] # [0 = disabled, 1 = suspend account] quar_susp=0 # minimum userid that can be suspended quar_susp_minuid=500
To scan a directory.
maldet --scan-all or maldet -a /var/www/
To monitor user account in the background.
maldet –monitor /home/joe
And the monitoring will continue to run in background and the resultant logs will be reported in below log file.
To have maldet run as a cron job I added this for the website owner I want to be scanned on a daily basis. Using Webmin’s scheduled cron job module found under the system menu.
Improve PHP security
vi /srv/users/useraccount/apps/wordpress/public/.user.ini open_basedir = /srv/users/useraccount
Add these to what are already disabled by default.
disable_functions = show_source, system, shell_exec, passthru, exec, popen, proc_open
expose_php = Off
max_execution_time = 30 memory_limit = 32M
How to enable SSL on Server Pilot
Sign up for a free SSL certificate here.
If you want to try Server Pilot for free go here.