technical details of the blog

hantian

June 20, 2024

1 intro

once one get used to LaTeX, it is impossible to distract him from writing anything with LaTeX. it just werks. when it comes to write blogs on a website, the current solution either has an unsatisfactory solution depending on mathjax or cannot be deployed easily on a cloud server. so this is the initiative of all this: a static blog mananged manually, linux and apache and nothing more.

2 cloud server

in mainland china, one do not have too many viable choices, this blog is build on an ecs of aliyun. there is an on-going 618 promotion where a large 2 core unit costs 99 rmb per annum.

the operating system is ubuntu 22.04 (jammy jellyfish) which is a lts version. there is no preferrence of ubuntu over the other alternatives whatsoever, it’s just that i am more familiar with apt package manager. (trivia: apt is the abbrivation of ‘advanced package tool’)

after the installation update the library with

    # apt update && apt -y upgrade

so that the system is up-to-date.

next, one needs to create a non-root user to login remotely:

    # adduser [username]
    # usermod -aG sudo [username]

do not forget to test if the user is truly in the sudo group.

    # su - [username]
    $ sudo apt -y install apache2

if the webserver is successfully installed, then everything is progressing alright.

if secure remote login is required (it is always required), ssh-key pairs need to be added. ssh-keygen is by default installed for most linux distributions, including ubuntu.

    $ ssh-keygen

note that this command should be run as user. it is highly recommended that password/pass-phrase being by-passed, for the ease of daily usage. currently aliyun accepts all kinds of authentication type, ed25519 seems to be the most secured type.

now go to the ecs settings and add the public key, which can be found under ~/.ssh as ~/.ssh/id_ed25519.pub. copy the content that begins with id_ed25519 …the key will be automatically trusted for the root user, but not the user that is created afterwards.

log in to the console, and switch to the user that is lately created, add the key to ~/.ssh/authorized_keys. now the cloud server can be logged in remotely by

    $ ssh [username]@[public_ip]

where [public_ip] can be seen on the aliyun control panel. in addition to that, it is also possible to remote sync files over ssh by

    $ rsync [local_dir] [username]@[public_ip]:[remote_dir]
    $ rsync [username]@[public_ip]:[remote_dir] [local_dir]

should one have public domain registered and resolved to his public ip, the field can be replaced by easier-to-remember version of domain.

3 apache server

to serve webpages, that is, html files (php not a consideration for this site from the very beginning), httpd service is required. there are many options available on shelf, however the most adopted are apache and nginx (read as engine x). in general the former is easier to deploy and the latter is more robust and flexible, suitable for even more scenarios. my purpose is to archive my maths blogs. a static site is the best match for this purpose, thus apache it is.

apache2 is actually preinstalled on aliyun ubuntu, but it does not hurt to check and reinstall if required. after installation, apache service should automatically enabled. it can be checked by

    $ sudo systemctl status apache2

if it’s not already running, start the service by

    $ sudo systemctl start apache2

the service name can be different for centos and open suse.

while the service is up and running, it still cannot be visited from public domain, that is because the net security strategy of aliyun ecs. walk to the security tab of the control panel and in outgoing strategies add port 80 (for http) and 443 (for https) for all ip address, that is 0.0.0.0. now the default apache lauch page can be seen if one visits the public domain or public ip address of the ecs, the site is officially online.

4 LaTeXsettings

as proposed in the first place, the only point of this site is to write blogs with LaTeX(and possible all lower case letters). while it is doable to install texlive-full on the ecs, or even add repository for lts version, it is preferred to edit the tex file locally, as one can preview it easily by compile it into pdf.

as to my taste, i use vim and vimtex for the composition and prevision of LaTeXfiles, the setup can be find at here. i find it very swift and highly recommend it.

come with the latest versions is the make4ht service that compiles tex files to dvi and the tranlate them into proper html file. the html is quite basic, as is for this post. however, it is possible to adjust the related css file for better appearance.

    $ make4ht [post_name].tex

generates the html with post_name.html as the file name, use rsync to push the page to the ecs:

    $ rsync [post_name].html [username]@[pub_ip]:/var/www/html/

as for the index page and other settings, one can ‘view source code’ of this blog to see that it has nothing interesting in it.

5 public domain

on aliyun, .xyz, .xin, .ink domains are reasonably cheap, down to around 30 rmb per annum. to make a purchase, one need to supply photo of his identification, and make icp registration with the relevant bureau. this process normally takes around 2-3 work days. as the writting of this post, the site is still undergoing this process. after the icp registration, it is required to put the registration number in the footer of the home page.

surely it is possible to choose an oversea isp, but in general the latency of oversea dns makes a pain in the *rse.

6 optional matters

there are some optional matters can be done to the blog, which i think i won’t do.

1.
add ssl to the site,
2.
use php to serve the site dynamically,
3.
write a script to automate the compilation and rsync
4.