Before you can twist anything, point your domain like example.com to your IP address, in order to do this, you will need to login your domain dashboard, update DNS Record and add two following lines:
HOSTNAME | TYPE | ADDRESS/VALUE | DISTANCE/PRIO | TTL |
---|---|---|---|---|
@ | A | 192.168.0.1 | NA | 17027 |
WWW | A | 192.168.0.1 | NA | 17027 |
- Make sure port 80 and port 443 are enabled, to make this you will need to shutdown your firewall (ufw/firewalld/iptables) or configure the firewall.
systemctl start firewalld.service # Launch FirewallD service
firewall-cmd --zone=public --add-port=80/tcp --permanent # Open port 80
firewall-cmd --zone=public --add-port=443/tcp --permanent # Open port 443
firewall-cmd --reload # Active new added rules
ufw allow 80/tcp # Open port 80
ufw allow 443/tcp # Open port 443
systemctl ufw restart ## Active new rules
/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
/sbin/iptables -I INPUT -p tcp --dport 443 -j ACCEPT
/etc/rc.d/init.d/iptables save
/etc/init.d/iptables restart
If it's hosted on Aliyun, make sure to build similar security rules on your dashboard.
Once login your VPS, move to lamp directoy by type cd lamp
, then start to create a virtual host for the site.
lamp add
Above command will lead you through the whole process, when asking for the domain, be sure to enter both example.com www.example.com, then there is nothing special, choose Lets Encrypt to get a free SSL certificate. Once done, your are good to have a cup of tea.
** Be sure to remember your database name and password **
cd
yum install wget # Install a downloading tool
wget https://wordpress.org/latest.tar.gz
tar -zxvf latest.tar.gz # Decompress files
mv ./wordpress/* /data/www/example.com # Replace example.com to your domain
chown -R apache:apache /data/www/example.com
find /data/www/example.com/ -type d -exec chmod 755 {} \;
find /data/www/example.com/ -type f -exec chmod 644 {} \; # Set up the secure permission
Open browser and type your domain like example.com while will lead you to a installation page, some information here needs you to offer including:
- Database name
- Database user name
- Database password
- [Prefix] change default "wp_" to anyting others like "wp1_" to better secure your database
- Change [Settings] -> [Permalinks]
- Edit wp-config.php to add following two lines to active cache
define('ENABLE_CACHE', true);
define('WP_CACHE', true);
- Create .htaccss file if not exist
- Paste lines below into it
# Redirect http to https, works for both www or not
# Don't put following code into BEGIN WordPress section
# Source: https://wordpress.org/support/topic/ssl-redirect-breaks-on-http/
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} !=on [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}%/$1 [R=301,L]
</IfModule>
# BEGIN WordPress
# The directives (lines) between `BEGIN WordPress` and `END WordPress` are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress