Skip to content

Instantly share code, notes, and snippets.

@jewei
Last active February 26, 2018 07:10
Show Gist options
  • Save jewei/2b66a86717c015b33d5d1bdcb63fcef2 to your computer and use it in GitHub Desktop.
Save jewei/2b66a86717c015b33d5d1bdcb63fcef2 to your computer and use it in GitHub Desktop.
Ubuntu 17.10 Server Setup

Basic Raw Server Setup

Based on Ubuntu 17.10

System Update

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

Timezone

sudo dpkg-reconfigure tzdata

SSH Login

ssh-copy-id -i ~/.ssh/id_rsa user@ipaddress

Default editor

update-alternatives --config editor
sudo select-editor

Add user

adduser deploy sudo
passwd deploy
usermod -aG sudo username

Sudoer

sudo visudo

deploy    ALL=(ALL:ALL) NOPASSWD:ALL

Setup Firewall

sudo ufw reset
sudo ufw allow ssh
sudo ufw allow http
sudo ufw allow https
sudo ufw allow from 192.168.1.0/24 to any port 3306
sudo ufw enable
sudo ufw status

Install MySQL

sudo apt-get install mysql-server
mysql_secure_installation
sudo service mysql status

sudo mysql -u root -p
add_header Content-Security-Policy "default-src 'self'; script-src 'self'; object-src 'self'; style-src 'self'; img-src 'self'; media-src 'self'; frame-src 'self'; font-src 'self'; connect-src 'self'";
add_header X-Content-Security-Policy "default-src 'self'; script-src 'self'; object-src 'self'; style-src 'self'; img-src 'self'; media-src 'self'; frame-src 'self'; font-src 'self'; connect-src 'self'";
add_header X-WebKit-CSP "default-src 'self'; script-src 'self'; object-src 'self'; style-src 'self'; img-src 'self'; media-src 'self'; frame-src 'self'; font-src 'self'; connect-src 'self'";
add_header Referrer-Policy "no-referrer";
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains; preload";
add_header X-Content-Type-Options nosniff;
add_header X-Frame-Options SAMEORIGIN;
add_header X-XSS-Protection "1; mode=block";
client_body_buffer_size 100K;
client_body_timeout 10;
client_header_buffer_size 1k;
client_header_timeout 10;
client_max_body_size 100k;
large_client_header_buffers 2 1k;
send_timeout 10;
server_tokens off;
# http://www.cspisawesome.com/

Install Latest Nginx

echo "deb http://nginx.org/packages/mainline/ubuntu/ artful nginx" | sudo tee -a /etc/apt/sources.list
echo "deb-src http://nginx.org/packages/mainline/ubuntu/ artful nginx" | sudo tee -a /etc/apt/sources.list
wget -qO - https://nginx.org/keys/nginx_signing.key | sudo apt-key add -

sudo apt update
sudo apt install nginx
sudo systemctl enable nginx.service

sudo usermod -a -G www-data $USER

Install NodeJS

curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
sudo apt-get install -y nodejs

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs

Install PHP 7.2

sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php7.2-cli php7.2-curl php7.2-fpm php7.2-gd php7.2-json php7.2-mbstring php7.2-opcache php7.2-xml php7.2-zip
# /etc/php/7.2/fpm/php.ini

upload_max_filesize = 100M
post_max_size = 100M
max_execution_time = 120
memory_limit = 1024M
date.timezone = Asia/Kuala_Lumpur

sudo systemctl restart php7.2-fpm.service

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