Skip to content

Instantly share code, notes, and snippets.

@tzi
Last active September 25, 2017 13:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tzi/cf4e6d5427a93db49aefaf6a2317cae5 to your computer and use it in GitHub Desktop.
Save tzi/cf4e6d5427a93db49aefaf6a2317cae5 to your computer and use it in GitHub Desktop.
# Tasks when setting up a new Ubuntu server
# Chaneg root user password
passwd
# 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
# PHP
apt-get install php
# Add PHP Apache module
apt-get install libapache2-mod-php
# Add PHP DOMDocument support
apt-get install php7.0-xml
# MySQL
apt-get install mysql-server mysql-client php-mysql
# Start MySQL project configuration
mysql -uroot -p
# Create a database
mysql> CREATE DATABASE IF NOT EXISTS `project`;
# 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 https://www.sitepoint.com/quick-tip-how-to-permanently-change-sql-mode-in-mysql/
# 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>
ServerName sub.ndd.com
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
</Directory>
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment