Skip to content

Instantly share code, notes, and snippets.

@fer-ri
Last active September 29, 2017 08:10
Show Gist options
  • Save fer-ri/b43c82c761d22acac49eb1cf6bfe5dbe to your computer and use it in GitHub Desktop.
Save fer-ri/b43c82c761d22acac49eb1cf6bfe5dbe to your computer and use it in GitHub Desktop.
VPS Setup Guide for Debian 8

run

apt-get update && apt-get upgrade
apt-get install nano curl screen htop git

(optional) disable ipv6 if apt-get update can't resolve via ipv6

sysctl -w net.ipv6.conf.default.disable_ipv6=1
sysctl -w net.ipv6.conf.all.disable_ipv6=1

run

apt-get purge nscd bind9 sendmail apache2 apache2.2-common -y

run

nano /etc/apt/sources.list

add these lines

deb http://packages.dotdeb.org jessie all
deb-src http://packages.dotdeb.org jessie all

run

wget https://www.dotdeb.org/dotdeb.gpg
apt-key add dotdeb.gpg
apt-get update

Open https://downloads.mariadb.org/mariadb/repositories/

Select Debian > Debian 8 "Jessie" > 10.0 [Stable] > Choose country

Or run commands below

for ID

apt-get install software-properties-common
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db
add-apt-repository 'deb [arch=amd64,i386] http://mariadb.biz.net.id/repo/10.0/debian jessie main'

for US

apt-get install software-properties-common
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db
add-apt-repository 'deb [arch=amd64,i386] http://ftp.osuosl.org/pub/mariadb/repo/10.0/debian jessie main'

run

apt-get update
apt-get install nginx php5-fpm php5-common php5-mysqlnd php5-dev php5-cli php5-memcache php5-curl php5-mcrypt php5-xsl php5-gd php5-xmlrpc mariadb-server

Open https://www.random.org/passwords/?num=5&len=12&format=html&rnd=new to generate password for mysql

Open https://gist.github.com/ghprod/07dea09c5101ea19cf6c

Open https://gist.github.com/ghprod/f27df1d9577688a8d7ea

run

useradd -s /bin/false nginx
mkdir -p /home/nginx/domains/default/{logs,public_html}
chown -R nginx: /home/nginx
cd /home/nginx/domains/default/public_html
wget https://www.adminer.org/latest-mysql-en.php -O d.php
echo "<?php phpinfo();" > i.php
chown -R nginx: /home/nginx
service nginx restart && service php5-fpm restart

Test disk speed

dd if=/dev/zero of=test bs=64k count=16k conv=fdatasync

Run command as nginx

nano ~/.bashrc_aliases

# OR

nano ~/.bashrc

Add

alias asnginx="su -s /bin/bash nginx && cd /home/nginx"

Run

source ~/.bashrc_aliases

# OR

source ~/.bashrc

Install letsencrypt / certbot in Debian 8 (Jessie)

nano /etc/apt/sources.list

## add the line to the end of file
deb http://ftp.debian.org/debian jessie-backports main

apt-get update
apt-get install certbot -t jessie-backports

certbot certonly -a webroot --webroot-path=/home/nginx/domains/domain.com/public_html -d domain.com -d www.domain.com

## run this command only once when setup server
openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048

You can check configuration using https://www.ssllabs.com/ssltest/analyze.html?d=domain.com

Renew

Run this command certbot renew.

Or setup crontab by run crontab -e

30 2 * * 1 certbot renew >> /var/log/le-renew.log
35 2 * * 1 service nginx restart

Cloudflare

Go to Crypto > SSL, set to Full.

@fer-ri
Copy link
Author

fer-ri commented Sep 2, 2017

For switch PHP version including one in CLI

https://gist.github.com/halkyon/15bcf89ccf4e25548b2ac3f334e0cd0d

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