Skip to content

Instantly share code, notes, and snippets.

Last active Sep 25, 2017
What would you like to do?
# Tasks when setting up a new Ubuntu server
# Chaneg root user password
# Create a new user
adduser tzi
# Add it to sudo group
usermod -a -G sudo tzi
# Add it to www-data group
usermod -a -G www-data tzi
# Apache
apt-get install apache2
# Enable URL Rewriting module
a2enmod rewrite
# Enable Header module
a2enmod headers
# Improve security, change the current values to:
# - ServerTokens Prod
# - ServerSignature Off
vi /etc/apache2/conf-available/security.conf
# Add your project Virtual Host (see file below)
vi /etc/apache2/sites-available/project.conf
# Enable it
a2ensite project
service apache2 reload
apt-get install php
# Add PHP Apache module
apt-get install libapache2-mod-php
# Add PHP DOMDocument support
apt-get install php7.0-xml
apt-get install mysql-server mysql-client php-mysql
# Start MySQL project configuration
mysql -uroot -p
# Create a database
# Create user
mysql> CREATE USER 'project'@'%' IDENTIFIED BY 'password';
# Add user access to the database
mysql> GRANT ALL PRIVILEGES ON `project` . * TO 'project'@'%';
# Import data
mysql -uproject -p project < /tmp/dump.sql
# If you need to remove the ONLY_FULL_GROUP_BY
# See
# Allow our user to deploy a website
chown -R tzi:www-data /var/www
chmod -R 774 /var/www
# Install nodejs
sudo apt-get install nodejs
cd /usr/bin/
sudo ln -s nodejs node
# Install npm
sudo apt-get install npm
# Install pm2
sudo npm install pm2@latest -g
# Start a new app as mySite
pm2 start app.js --name mySite
# Get site status
pm2 show mySite
# Get site log
pm2 logs mySite
<VirtualHost *:80>
DocumentRoot /var/www/ndd/sub
<Directory "/var/www/ndd/sub">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment