Tested this on a lot of servers already before writing this post. I needed to move from SquareSpace to Vultr VPS, so this post is from that.
This is what I am using…
Server: Ubuntu 14.04
Memory: 512MB
CPU: 1 Core
Disk: SSD
Cost: $2.5 per month
First we install Apache2 & MySql servers.
apt-get install apache2 apt-get install mysql
When prompted add password for root user on your newly added MySql Server.
I prefer PHP-FPM for security and speed. So, this is how we install PHP-FPM.
# Install dependencies
sudo apt-get install -y apache2-mpm-worker sudo apt-get install -y libapache2-mod-fastcgi php5-fpm
# Disable prefork & Enable fcgi
sudo a2dismod php5 mpm_prefork sudo a2enmod actions fastcgi alias mpm_worker
# Create fcgi file
sudo touch /usr/lib/cgi-bin/php5.fcgi
# Add configuration file
cat > /etc/apache2/conf-available/php5-fpm.conf << EOL <IfModule mod_fastcgi.c> AddHandler php5.fcgi .php Action php5.fcgi /php5.fcgi Alias /php5.fcgi /usr/lib/cgi-bin/php5.fcgi FastCgiExternalServer /usr/lib/cgi-bin/php5.fcgi -socket /var/run/php5-fpm.sock -pass-header Authorization -idle-timeout 3600 <Directory /usr/lib/cgi-bin> Require all granted </Directory> </IfModule> EOL
# Enable PHP-FPM conf
sudo a2enconf php5-fpm
# Restart services
sudo service apache2 restart && sudo service php5-fpm restart
You can change user and group to “anyone” in /etc/php5/fpm/pool.d folder now, File: www.conf”.
Now, enable SSL & REWRITE modules for Apache2.
a2enmod ssl a2enmod rewrite service apache2 restart
Please note that you will have to create an SSL certificate on server to configure it with Apache2 virtual host.
If you are going to install WordPress MultiSite and want .htaccess to work, then please look in /etc/apache2/apache2.conf and under /var/www files section…
AllowOverride All
Install php5-mysql
apt-get install php5-mysql
Restart Apache2 and MySql servers…
service apache2 restart service mysql restart
Done!
You can install your websites under /var/www/html (or other folder if you changed) and download adminer.php from https://www.adminer.org/ and create a new database for your new website.
And, here is a little help of you want to reset PHP-FPM threads on server…
pkill -9 php pkill -9 php pkill -9 php pkill -9 php pkill -9 php pkill -9 php pkill -9 php pkill -9 php pkill -9 php pkill -9 php pkill -9 php rm -rf /var/run/php5-fpm.sock php5-fpm -y /etc/php5/fpm/php-fpm.conf -R ps -eaf | grep php
This will close all running PHP processes on server, so please do it carefully if you are doing it on a server with online websites.