apt-get update
apt-get install apache2
nano /etc/apache2/mods-enabled/dir.conf
- Add
index.php
to beginning ofDirectoryIndex
list (remove from place in list further down)
a2enmod rewrite headers expires
nano /etc/apache2/apache2.conf
- Change
AllowOverride None
toAllowOverride All
within<Directory /var/www/>
block
service apache2 restart
apt-get install php libapache2-mod-php php-mcrypt php-mysql -y
apt-get install php-cgi php-cli php-common php-curl php-gd -y
apt-get install mysql-server
mysql_secure_installation
- n
- n
- y
- y
- y
- y
ssh www-data@SERVER_IP_ADDRESS -L 42001:localhost:3306
-
3306 is default mysql port
-
42001 is a free (unless you are running something else on this port, highly unlikely!)
-
allows local access to remote mysql server for easier creation of db's and users
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
apt-get install -y nodejs
Follow the instructions on the Yarn website to install yarn onto the server.
apt-get install git
Note: tld
means Top-Level Domain
i.e. .com, .co.uk, .io
etc, make sure to replace .tld
with your
domain's TLD extension
cd /etc/apache2/sites-available/
- if creating one site on box:
cp 000-default.conf my-site.domain.tld.conf
nano my-site.domain.tld.conf
ServerName my-site.domain.tld
ServerAdmin [email protected]
DocumentRoot /var/www/html/
a2dissite 000-default.conf
a2ensite my-site.domain.tld.conf
- if creating multiple (i.e. staging and qa):
cp 000-default.conf my-site-staging.domain.tld.conf
nano my-site-staging.domain.tld.conf
ServerName my-site-staging.domain.tld
ServerAdmin [email protected]
DocumentRoot /var/www/html/staging
cp 000-default.conf my-site-qa.domain.tld.conf
nano my-site-qa.domain.tld.conf
ServerName my-site-qa.domain.tld
ServerAdmin [email protected]
DocumentRoot /var/www/html/qa
a2dissite 000-default.conf
a2ensite my-site-staging.domain.tld.conf my-site-qa.domain.tld.conf
- Ensure directories specified above (each
DocumentRoot
path) are created by www-data user, once this user is setup using the instructions below.
nano /etc/passwd
www-data:x:33:33:www-data:/var/www:/bin/bash
passwd www-data
- Enter www-data user password
chown -R www-data:www-data /var/www
(As root user)
nano /etc/ssh/sshd_config
- Change
PermitRootLogin yes
toPermitRootLogin no
service ssh restart
Disconnect from server and try root
user ssh, will be given permission denied
message.
Use www-data
user the su
to swap to the root
user when required.
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
su
- swap to root in order to move wp-cli
mv wp-cli.phar /usr/local/bin/wp
exit
- swap back to www-data
- Run
hostname
to see what the currently set hostname is set to - Run
hostnamectl set-hostname mysite.com
to change the hostname (permanently, otherwise will reset on reboot) - Note: Important that this step is performed before setting you your mail server!
apt-get install mailutils
- Set mail configuration type to
Internet Site
- Set system mail name to FQDN i.e.
mysite.com
, ensure you DO NOT add any subdomains in front i.e.www.
as this will invalidate the mail record - As root:
nano /etc/postfix/main.cf
and changeinet_interfaces
to:
inet_interfaces = loopback-only
- Then change
mydestination
to:
mydestination = localhost.$mydomain, $mydomain
- Finally, restart postfix (mail sending service)
service postfix restart
- To check that the server is sending out emails correctly you can run the following command:
echo "This is the body of the email" | mail -s "This is the subject line" [email protected]