Set up a remote server to host simple static websites from scratch.
I could use out of the box options, but building something from scratch helps me better understand and wrap my head around how web servers work.
Heard about it from sive.rs. Reserved a server with them, and got to work.
Soundtrack: https://open.spotify.com/playlist/2lrw8XWJtmhq5SCDbc4VLn?si=3042d3e6c02a489e
Set up SSH via vultr UI. ssh-ed in via iterm. Here we go.
![[Screenshot 2022-12-24 at 16.13.00.png]]
index.html
file from
local computer to remote server.index.html
locally via a web server
index.html
on achao.io
arcpartnering.com
on
my remote server with Apache Virtual Hostsheader.html
.html
, .php
) Created a ~/workspaces/achao.io
directory to house my personal website files. Of note, I had already
reserverd achao.io
via Google Domains.
![[Screenshot 2022-12-24 at 16.13.37.png]]
Transfer local index.html
file from local computer to remote server.
On local machine:
> sftp root@207.XXX.XXX.XXX
Connected to 207.XXX.XXX.XXX.
sftp> put /Users/anthony/Workspaces/achao.io/index.html /root
Uploading /Users/anthony/Workspaces/achao.io/index.html to /root/index.html
index.html 100% 627 23.8KB/s 00:00
On remote machine:
root@achaovultr1:~# ls
index.html workspaces
Success!
Reference(s):
Run index.html locally in the remote server
Get the static page running on the remote server
Step 0: Initial Server Setup with Debian 11 (source)
Step 1: Install Appache HTTP Server on Debian 11 (https://httpd.apache.org/)
![[Screenshot 2022-12-24 at 17.35.13.png]]
Hell yeah! Apache Web Server installed successfully :)
![[Screenshot 2022-12-24 at 17.38.19.png]]
Set up an apache virtual host in /var/www/achao.io
. It's alive!!!
![[Screenshot 2022-12-24 at 17.53.56.png]]
What is a web server?
What is the LAMP Web Application Architecture?
Reference(s):
Connect/host index.html on achao.io
Intermediate goal, get the "LAMP" stack set up to enable my server to host dynamic websites and web apps. (Linux, Apache, MariaDB, PHP)
Installed mariaDB
and PHP
.
![[Screenshot 2022-12-24 at 18.20.21.png]]
Next intermediate goal, how to link my two domains, achao.io
and arcpartnering.com
to
my http://207.XXX.XXX.XXX/
server?
![[Screenshot 2022-12-24 at 18.52.38.png]]
Updated Advanced DNS settings for my domain at namecheap.com.
Redirect and host arcpartnering.com
on my remote server with Apache Virtual Hosts
https://www.howtogeek.com/devops/how-to-host-multiple-websites-with-one-apache-server/
Magical. It works.
![[Screenshot 2022-12-25 at 00.18.09.png]]
Set up TLS/SSL Certificates
What are TLS/SSL Certificates?
sudo certbot --apache -d arcpartnering.com -d www.arcpartnering.com
sudo certbot --apache -d achao.io -d www.achao.io
Secure :)Ï
![[Screenshot 2022-12-25 at 00.42.07.png]] ![[Screenshot 2022-12-25 at 00.41.55.png]]
So you can use SSI (S)
https://unix.stackexchange.com/questions/627020/how-to-enable-xbithack-on-apache2-web-server-debian
Apply a consistent header to all pages via header.html
I didn't want to duplicate <header>
code in all my different pages, so I was trying to
understand the simplest way to implement this.
This article describes what I'm trying to do pretty well.
DRY, Don't Repeat Yourself.
So, I found Apache SSI (Server Side Includes), which is super cool - it provides a way to add dynamic content to existing HTML documents.
With newer versions of Apache, the main server configuration file lives at /etc/apache2/apache2.conf
How do you check your Apache version?
anthony@achaovultr1:~$ sudo apache2 -v
Server version: Apache/2.4.54 (Debian)
Server built: 2022-06-09T04:26:43
How do you enable SSI for your Apache server?
https://httpd.apache.org/docs/2.4/howto/ssi.html
Once XBitHack
is on, how do you enable it? XBitHack
tells Apache to parse files for
SSI
directives. If the files have the execute bit set, SSI
will work.
anthony@achaovultr1:/var/www/achao.io/pages$ ls -lh
total 28K
-rw-r--r-- 1 anthony anthony 502 Jan 1 06:49 about-me.html
-rw-r--r-- 1 anthony anthony 455 Jan 1 06:49 books.html
-rw-r--r-- 1 anthony anthony 423 Jan 1 06:34 header.html
-rw-r--r-- 1 anthony anthony 389 Jan 1 06:49 now.html
-rw-r--r-- 1 anthony anthony 416 Jan 1 06:49 posts.html
-rw-r--r-- 1 anthony anthony 422 Jan 1 06:49 projects.html
-rw-r--r-- 1 anthony anthony 482 Jan 1 06:49 setup.html
anthony@achaovultr1:/var/www/achao.io/pages$ chmod +x *.html
anthony@achaovultr1:/var/www/achao.io/pages$ ls -lh
total 28K
-rwxr-xr-x 1 anthony anthony 502 Jan 1 06:49 about-me.html
-rwxr-xr-x 1 anthony anthony 455 Jan 1 06:49 books.html
-rwxr-xr-x 1 anthony anthony 423 Jan 1 06:34 header.html
-rwxr-xr-x 1 anthony anthony 389 Jan 1 06:49 now.html
-rwxr-xr-x 1 anthony anthony 416 Jan 1 06:49 posts.html
-rwxr-xr-x 1 anthony anthony 422 Jan 1 06:49 projects.html
-rwxr-xr-x 1 anthony anthony 482 Jan 1 06:49 setup.html
anthony@achaovultr1:/var/www/achao.io/pages$
Remove file extensions from end of URLs (e.g. .html
, .php
)
https://httpd.apache.org/docs/2.4/mod/mod_rewrite.html https://code.tutsplus.com/tutorials/an-in-depth-guide-to-mod_rewrite-for-apache--net-6708 https://cheatography.com/davechild/cheat-sheets/mod-rewrite/