my checklist for creating new ubuntu 16.04 server
- Login as root
- Add new user:
adduser imper
- Add root privileges:
usermod -aG sudo imper
and logout - Copy your public key from your machine:
ssh-copy-id imper@serverhost
- Login as imper
- Add autocompletion for bash with:
sudo apt update
sudo apt install bash-completion
and logout/login again - Add software-properties-common:
sudo apt install software-properties-common
- Install nano
sudo apt-get install nano
- Edit sshd config:
sudo nano /etc/ssh/sshd_config
and setPasswordAuthentication no
- Reload sshd:
sudo systemctl reload sshd
- Setup firewall:
- Install ufw:
sudo apt-get install ufw
sudo ufw allow OpenSSH
sudo ufw enable
- Check status with
sudo ufw status
- Install ufw:
- Configure timezones with
sudo dpkg-reconfigure tzdata
- Install NTP for time synchronization
sudo apt-get install ntp
sudo add-apt-repository ppa:ondrej/nginx
sudo apt update
sudo apt install nginx
sudo ufw allow 'Nginx Full'
- Visit https://downloads.mariadb.org/mariadb/repositories/#mirror=kisiek for actual repository instructions
mysql_secure_installation
- Login to mysql with
sudo mysql -p
- Add new user
CREATE USER 'imper'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON * . * TO 'imper'@'localhost';
FLUSH PRIVILEGES;
andexit
- Add ondrej repos:
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.2-fpm php7.2-mysql
- Additionals:
sudo apt-get install php7.2-bcmath php7.2-bz2 php7.2-cgi php7.2-curl php7.2-gd php7.2-imap php7.2-intl php7.2-mbstring php7.2-soap php7.2-xml php7.2-xmlrpc php7.2-zip
- Imagick:
sudo apt-get install php-imagick
- Installation:
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install python-certbot-nginx
- Obtain cert with:
sudo certbot --nginx -d example.com -d www.example.com
- Add auto renewal to crontab:
sudo crontab -e
- Add
30 2 * * 1 certbot renew >> /var/log/certbot-renew.log
- Add
35 2 * * 1 systemctl reload nginx
sudo apt-get install curl
curl -sL https://deb.nodesource.com/setup_8.x -o nodesource_setup.sh
sudo bash nodesource_setup.sh
sudo apt-get install nodejs
sudo apt-get install build-essential
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn
wget https://getcomposer.org/installer
php installer
sudo mv composer.phar /usr/local/bin/composer
curl -sO http://gordalina.github.io/cachetool/downloads/cachetool.phar
chmod +x cachetool.phar
sudo mv cachetool.phar /usr/local/bin/phpcachetool
- Create config file under
/etc/cachetool.yml
adapter: fastcgi
fastcgi: /run/php/php7.2-fpm.sock
cd ~
wget http://packages.erlang-solutions.com/site/esl/esl-erlang/FLAVOUR_1_general/esl-erlang_20.1-1~ubuntu~xenial_amd64.deb
sudo dpkg -i esl-erlang_20.1-1\~ubuntu\~xenial_amd64.deb
- Verify erlang version with
erl
double ctrl+c to exit echo "deb https://dl.bintray.com/rabbitmq/debian xenial main" | sudo tee /etc/apt/sources.list.d/bintray.rabbitmq.list
wget -O- https://www.rabbitmq.com/rabbitmq-release-signing-key.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install rabbitmq-server
sudo systemctl start rabbitmq-server.service
sudo systemctl enable rabbitmq-server.service
sudo rabbitmqctl status
sudo rabbitmqctl add_user admin password
sudo rabbitmqctl set_user_tags admin administrator
sudo rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"
- git
- redis
- supervisord
- wkhtmltopdf
- elasticsearch
sudo nano /etc/php/7.2/fpm/php.ini
cgi.fix_pathinfo=0
opcache.memory_consumption=256
opcache.max_accelerated_files=20000
opcache.validate_timestamps=0
realpath_cache_size=4096K
realpath_cache_ttl=600
max_execution_time = 180
max_input_time = 180
memory_limit = 512M
post_max_size = 100M
upload_max_filesize = 100M
default_socket_timeout = 120
pdo_mysql.cache_size = 4000
mysqli.cache_size = 4000
session.sid_length = 40
session.sid_bits_per_character = 4
mbstring.language = Polish
soap.wsdl_cache_enabled=0
opcache.enable=1
opcache.enable_cli=1
sudo nano /etc/php/7.2/fpm/pool.d/www.conf
user = imper
group = imper
pm.max_children = 20
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 20
slowlog = /var/log/php.$pool.log.slow
request_slowlog_timeout = 10s
sudo nano /etc/nginx/nginx.conf
user imper
listen.owner = imper
listen.group = imper
sudo nano /etc/mysql/my.cnf
query_cache_limit = 4M
query_cache_size = 128M
innodb_buffer_pool_size = 512M
- Under [mysqld] insert:
character-set-server = utf8mb4
collation-server = utf8mb4_polish_ci
innodb_ft_min_token_size = 1
ft_min_word_len = 1