Skip to content

Setting up the project on DigitalOcean droplet from A to Z

egikyan edited this page Oct 21, 2016 · 1 revision

DigitalOcean manual

I assume you have created a fresh 16.04 Ubuntu LAMP droplet, and are running everything as the root user. This setup is not suitable for a longer production usage, nor we assume any responsibility if you break something :) If you are not sure what a step does - google it :)

If working on a new droplet, you can copy/paste most of the commands below directly - if not, just use them as reference :)

Getting the project files

...in the right place - that way we use the default virtualhost of Apache, so there is no need for a virtualhost to be onfigured.

rm -rf /var/www/html
git clone repo-url /var/www/html

Enable and install mod_rewrite

Unzip is recommended for composer

apt update
apt upgrade
apt install unzip php-xml -y
a2enmod rewrite
phpenmod xml
service apache2 restart

Enabling swap

You need this on both 512MB or 1 GB droplets - if not present npm install hangs source & explanations

fallocate -l 1G /swapfile
mkswap /swapfile
chmod 600 /swapfile
swapon /swapfile
sudo cp /etc/fstab /etc/fstab.bak
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
sudo cp /etc/sysctl.conf /etc/sysctl.conf.bak
echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.conf
echo 'vm.vfs_cache_pressure=50' | sudo tee -a /etc/sysctl.conf

Get composer

You may also want to validate the install file - check Step 2 from here

cd ~
curl -sS https://getcomposer.org/installer -o composer-setup.php
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer

Install node/npm

DigitalOcean manual with more details

cd ~
curl -sL https://deb.nodesource.com/setup_6.x -o nodesource_setup.sh
sudo bash nodesource_setup.sh
sudo apt-get install nodejs -y

Install gulp and bower as global packages

npm install -g gulp bower

Set up mysql user/pass

When prompted for those during composer install you can use user root and the mysql root pass generated by DigitalOcean (check it by running cat /root/.digitalocean_password)

Still it is best to create database user and pass for each application you are using. In order to do it from the mysql cli run mysql -uroot -p, type the root password and run those. something-really-random should be changed - you can generate a value for it by running openssl rand -hex 26 beforehand).

create database sportify;
CREATE USER 'sportify_usr'@'%' IDENTIFIED BY 'something-really-random';
GRANT ALL ON sportify.* TO 'sportify_usr'@'%';
FLUSH PRIVILEGES;
exit

Run all the shiny tools installed

You will be prompted for configuration data during composer install - chechk the README on what is what there

composer install
npm install
bower install --allow-root
gulp

All files should be owned by the apache user

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

Continue with Application parameters and initial setup :)