How I Built My Personal Website with Alibaba Cloud

Step #1: Create a New Account

Step #2: Create a New ECS Instance

Step #3: Setup Alibaba Cloud DNS

Step #4: Connecting to Our Instance

ssh root@your-instance-ip

Step #5: Checking for Driver Errors

echo "blacklist intel_rapl" >> /etc/modprobe.d/blacklist.conf

Step #6: Update the System

apt update && apt full-upgrade -y
apt clean -y && apt remove -y

Step #7: Set the Default Time Zone

dpkg-reconfigure tzdata

Step #8: Install Nginx

apt install software-properties-common zip sendmail vim nano -y
echo "deb http://nginx.org/packages/ubuntu/ xenial nginx" >> /etc/apt/sources.list.d/nginx.list
curl -O https://nginx.org/keys/nginx_signing.key && apt-key add ./nginx_signing.key
apt update
apt install nginx -y
nginx -v
rm /etc/nginx/sites-enabled/default
rm /etc/nginx/sites-available/default
rm /var/www/html/index.nginx-debian.html
systemctl enable nginx

Step #9: Install PHP-FPM

add-apt-repository ppa:ondrej/php -y
apt update
apt install php7.2-fpm -y
php -v
apt install php7.2-redis php7.2-imap php7.2-xmlrpc php7.2-mysqlnd php7.2-imagick php7.2-gd php7.2-mbstring php7.2-common php7.2-zip php7.2-curl -y
systemctl enable php7.2-fpm

Step #10: Install MariaDB

add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://mirror.sax.uk.as61049.net/mariadb/repo/10.1/ubuntu xenial main' -y
apt update
apt install mariadb-server -y
mysql_secure_installation
systemctl enable mysql

Step #11: Create a Database & a DB user

mysql -u root -p
CREATE USER "example-user"@"localhost" IDENTIFIED BY "password";
CREATE DATABASE wordpress;
GRANT ALL PRIVILEGES ON . to "example-user"@"localhost";
FLUSH PRIVILEGES;
EXIT;

Step #12: Configure Nginx

nano /etc/nginx/nginx.conf
user www-data;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 10240;
multi_accept on;
use epoll;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
fastcgi_cache_path /var/www/cache levels=1:2 keys_zone=example.com:200m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
sendfile on;
tcp_nopush on;
tcp_nodelay on;
types_hash_max_size 2048;
server_tokens off;
keepalive_timeout 15;
client_max_body_size 512M;
add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header Referrer-Policy "strict-origin-when-cross-origin";
add_header X-FastCGI-Cache $upstream_cache_status;
gzip_vary on;
gzip_comp_level 5;
gzip_min_length 1024;
gzip_proxied any;
gzip_buffers 16 8k;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript text/x-js;
limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
limit_req_status 444;
gzip on;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
return 444;
}
}
nano /etc/nginx/sites-enabled/example.com
server {
listen 80;
listen [::]:80;
server_name example.com www.example.com;
root /var/www/html;
index index.php;
set $skip_cache 0;
if ($request_method = POST) {
set $skip_cache 1;
}
if ($query_string != "") {
set $skip_cache 1;
}
if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") {
set $skip_cache 1;
}
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
set $skip_cache 1;
}
if ($request_uri ~* "/cart/*$|/checkout/*$|/my-account/*$") {
set $skip_cache 1;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_cache example.com;
include fastcgi.conf;
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
fastcgi_cache_valid 10m;
}
location ~* \.(jpg|jpeg|gif|png)$ {
expires 365d;
}
location ~* \.(pdf|css|ico|js|swf)$ {
expires 10d;
}
}
nginx -t
systemctl restart nginx

Step #13: Configure Redis Server for Object Caching

apt install redis-server -y
systemctl enable redis-server
echo "maxmemory 256mb" >> /etc/redis/redis.conf
systemctl restart redis-server
systemctl restart php7.2-fpm

Step #14: Configure PHP

nano /etc/php/7.2/fpm/php.ini
max_execution_time = 60
max_input_time = 60
memory_limit = 512M
max_input_vars = 6000
upload_max_filesize = 512M
post_max_size = 512M

Step #15: Install FREE SSL Certificate By Let’s Encrypt

add-apt-repository ppa:certbot/certbot
apt update
apt-get install python-certbot-nginx -y
certbot --nginx -d example.com -d www.example.com
certbot renew

Step #16: Install WordPress

cd /var/www/html
wget wget https://wordpress.org/latest.zip
unzip latest.zip
mv wordpress/* ./ && rmdir wordpress
mkdir -p /var/www/cache
chown -R www-data:www-data /var/www/

Conclusion

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store