Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Ismaaa/7963d99aba6ea1dbf6023a4c6398295e to your computer and use it in GitHub Desktop.
Save Ismaaa/7963d99aba6ea1dbf6023a4c6398295e to your computer and use it in GitHub Desktop.

Server setup for Ubuntu 16.04 on Digital Ocean

Update system

apt-get update && apt-get dist-upgrade -y
apt-get autoremove -y

Script for installing Apache, MySQL, PHP, etc

apt-get -y install wget screen python
wget http://mirrors.linuxeye.com/lnmp-full.tar.gz
tar xzf lnmp-full.tar.gz
cd lnmp 
screen -S lnmp
./install.sh

You now have LEMP/LAMP/LNMP/LNMPA Installed...

Install Composer Globally

This does all the tricks

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

Install NodeJS (just incase JS frontend things)

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.5/install.sh | bash

Note: On Linux, after running the install script, if you get nvm: command not found, simply close your current terminal, open a new terminal, and try verifying again.

Install npm

nvm install node

Creating a 4GB Swap File (Essential for servers below 2GB RAM)

Create the file

sudo fallocate -l 4G /swapfile

Enable the swap file and set the correct permissions

sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

Make the the Swap File Permanent, edit the following file

sudo nano /etc/fstab

Go to the bottom of the file and add the following line

/swapfile   none    swap    sw    0   0

Tweak how much of the swap the system uses

sudo nano /etc/sysctl.conf

Insert the following lines at the bottom of the file

vm.swappiness=10
vm.vfs_cache_pressure = 50

End Of Server Setup

(Good Idea to take the Snapshot of your droplet at this point)

How to use

How to add Extensions

cd ~/lnmp    // Must enter the directory execution under lnmp
./addons.sh    // Do not sh addons.sh or bash addons.sh such execution

How to add a virtual host

cd ~/lnmp    // Must enter the directory execution under lnmp
./vhost.sh    // Do not sh vhost.sh or bash vhost.sh such execution

How to delete a virtual host

cd ~/lnmp
./vhost.sh del

How to add FTP virtual user

cd ~/lnmp
./pureftpd_vhost.sh

How to backup

cd ~/lnmp
./backup_setup.sh    // Backup parameters 
./backup.sh    // Perform the backup immediately 
crontab -l    // Can be added to scheduled tasks, such as automatic backups every day 1:00 
  0 1 * * * cd ~/lnmp;./backup.sh  > /dev/null 2>&1 &

How to manage service

Nginx/Tengine/OpenResty: service nginx {start|stop|status|restart|reload|configtest}

MySQL/MariaDB/Percona: service mysqld {start|stop|restart|reload|status}

PHP:: service php-fpm {start|stop|restart|reload|status}

HHVM: service supervisord {start|stop|status|restart|reload}

Apache: service httpd {start|restart|stop}

Pure-Ftpd: service pureftpd {start|stop|restart|status}

Redis: service redis-server {start|stop|status|restart|reload}

Memcached: service memcached {start|stop|status|restart|reload}

How to upgrade: ./upgrade.sh

How to uninstall: ./uninstall.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment