Skip to content

Instantly share code, notes, and snippets.

@ankyit
Last active July 5, 2018 03:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ankyit/e48881e05d48d2f5ef5a289250434eb0 to your computer and use it in GitHub Desktop.
Save ankyit/e48881e05d48d2f5ef5a289250434eb0 to your computer and use it in GitHub Desktop.
WordPress Installation
### Update the Server
apt-get update
apt-get upgrade
##Install webserver, PHP and MariaDB
apt-get install nginx php php-cli php-common php-curl php-dev php-fpm php-gd php-intl php-json php-mbstring php-mysql php-opcache php-readline php-soap php-xml php-zip mariadb-server
##Secure Maria DB and create database
mysql_secure_installation
mysql -i
create database <databasename>;
grant all on <databasename>.* to '<databaseuser>'@'localhost' identified by '<password>';
flush privileges;
##Configure Nginx
server {
listen 80;
listen [::]:80;
server_tokens off;
root /var/www/<sitepath>;
index index.php index.html index.htm index.nginx-debian.html;
server_name <sitename>;
add_header 'Access-Control-Allow-Origin' '*';
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ /.well-known {
allow all;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.1-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
## verify nginx configuration
nginx -t
## download and extract wordpress leatest version
cd /var/www
mkdir <sitename>
cd <sitename>
wget https://wordpress.org/latest.tar.gz
tar -xvf latest.tar.gz
cd wordpress
cp -r * /var/www/<sitename>
cd ..
rm -rf wordpress/
## change permissions
chown -R www-data:www-data /var/www/
## install let's encrypt SSL
add-apt-repository ppa:certbot/certbot
apt-get update
apt-get upgrade
apt-get install python-certbot-nginx
certbot --nginx -d <sitename> -d <sitename>
## Install wordPress
https://<sitename>
## activate Swap File
fallocate -l 1G /swapfile
ls -lh /swapfile
chmod 600 /swapfile
ls -lh /swapfile
mkswap /swapfile
swapon /swapfile
## Make SWAP permanent
cp /etc/fstab /etc/fstab.bak
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
nano /etc/sysctl.conf
vm.swappiness=10
vm.vfs_cache_pressure=50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment