This is a quick guide on how to get a D8 site running on DigitalOcean
- Spin up a D8 droplet
- ssh into the IP address assigned: ssh root@IPADDRESS
Move your user mysql config file (it messes with drush and isn't needed)
mv ~/.my.cnf ~/.my.cnf.bak
Install PHP 7.x
sudo add-apt-repository ppa:ondrej/php sudo apt-get update sudo apt-get install php7.1-fpm php7.1-curl php7.1-gd php7.1-xml php7.1-mysql php7.1-json php7.1-mbstring php7.1-opcache php7.1-zip sudo nano /etc/nginx/sites-enabled/drupal
Once in the nginx hosts file change the following
#fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
- reboot the server or restart nginx, either or works.
- If you are deploying a repo from github, add a ssh key with: ssh-keygen -t rsa and paste the public key into the repos → settings → deploy keys section. reboot the server.
Install composer with:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php -r "if (hash_file('SHA384', 'composer-setup.php') === '55d6ead61b29c7bdee5cccfb50076874187bd9f21f65d8991d46ec5cc90518f447387fb9f76ebae1fbbacf329e583e30') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" php composer-setup.php php -r "unlink('composer-setup.php');" mv composer.phar /usr/local/bin/composer
- Install Drush
- Edit your ~/.bashrc and put this at the end: export PATH="$HOME/.composer/vendor/bin:$PATH" and exit out of the server then ssh back in
- Run this command: composer global require drush/drush
- Grab the DB settings from /var/www/html/drupal/sites/default/settings.php
- Apply the DB connection string to your repos settings.
- Make sure to change the sync directory to what is on your current sites settings.php
Run the following commands:
cd /var/www/html/drupal drush sql-drop cd .. sudo rm -rf drupal sudo apt-get install git git clone YOUR-REPO drupal sudo chown www-data:www-data -R drupal
- Copy in your local DB and files via scp or FTP or whatever method you use.
- Import the DB and files, you may need to run: sudo chown www-data:www-data -R drupal again
- Make sure your tmp folder is correct in admin/config/media/file-system
- Check the status report for any issues and address them if need be.
- Highly Recommend using the site with CloudFlare to help mitigate DDoS attacks and CDN management. Drupal Instructions.
- If you want to optimize PHP & MySQL: check out this page
- If you want to optimize the server: check out this page