This article was last revised 242 days ago, and some of the information may be out of date.If you need to update urgently, please leave a message in the comment area below.
In the spirit of sharing for fun, I will record the specific steps I took to build this blog as detailed as possible below.This is a huge project, which will involve many unknown fields. I will take the method, idea and behavior of my blog building at the beginning as a benchmark, and try to simplify those steps as much as possible.
That is, do not consider too many principles, as long as you know how to operate.
Some are out of date. It is not recommended to refer to
Basic concepts
visitSound of beginning, you need to enter in the browserhimiku.com, browser viaDomain name resolution serviceQuery the abovewebsitedirectiveIP addressby192.168.xx.xx, andIP addressAndThe serverBinding, accessing the IP is accessing the server.The serverQuery towww.himiku.comThe point isTypechoThis oneBlog programSo all the files that can be displayed in this directory are returned.Finally, the blog program returns the content to the visitor and displays it on the browser.
Some basic concepts include: domain name, server, domain name resolution service, IP, blog program, and running environment.That is:
Domain name=himiku.com
Server=Linux system (my system is Ubuntu)
Domain name resolution service=DNSPOD, or other
IP = 192.168.xx.xx
Blogger=Typecho
Running environment=LNMP (Linux+Nginx+MySQL+PHP)
The things we need to buy are: domain names, servers, domain name resolution services (generally, domain names are provided for free, of course, there are also paid ones, but the free ones are enough, as if there is a lot of nonsense).
The domain name and server can be purchased directly from the ECS manufacturer, and then the network environment can be deployed on the server. The subsequent installation of blog programs is very simple.
Purchase server
There are too many server platforms, including Amazon, Tencent Cloud, Alibaba Cloud, Google, VULTR, movers, and Linode.How to buy is of course your choice, but if you just want to play or write logs, you can give priority to domestic servers. Just pay attention to buying and usingLocated in ChinaThe domain name needskeep on record。If you don't like filing, you can buy servers located abroad.
Follow the official steps to create an account, real name system and complete student certification. If you don't mind, you can pass myInvitation linkRegister an account.
If you are over 18 years old, a college student, and willing to make a real name system and file, you can purchase Tencent Cloud's student machine.Student machine purchase entrance:https://cloud.tencent.com/act/campus
Personally, I recommend buying a "lightweight application server with one core and 2G". Although the only available regions are Shanghai and Beijing, the upload bandwidth is "5M".The system first selects "CentOS", which can be changed after purchase.
Open lightweight application serverConsole, click in.
Then find "Application Information" and click "Reset Application".
Select Ubuntu 20.04 LTS.
If the domain name has not been filed or does not want to be filed, you can consider purchasing servers in overseas regions.Purchase address:https://buy.cloud.tencent.com/lighthouse
One core 1G configuration is enough at the beginning. The region can be Hong Kong or Singapore, China, and the mirror image can be selectedUbuntu 20.04 LTSThe minimum configuration is 24 yuan a month, and 30M bandwidth is enough.
You can use mine if you don't mindPromotion linkPurchase.
Alibaba Cloud
AliCloud student machine, formerly called "Cloud Wing Plan", is now renamed "Developer Growth Plan".
Follow the official steps to create an account, real name system and complete student certification. If you don't mind, you can pass myInvitation linkRegister an account.
Choose "lightweight application server" when purchasing, and the bandwidth is relatively high.Choose "System image, Ubuntu 20.04" for the pre installed environment. The region is optional, and it is better to be close to yourself.
If you don't want to buy a student computer or file it, you can also directly buy a lightweight computer:https://www.aliyun.com/product/swas
Choose "Hong Kong, Ubuntu 20.04".
Connect server
Use Xshell
useSSH connection toolTo connect to the server, consider usingXshell。After downloading and installing, enter the software and click the upper left cornerfile,newly buildOneconversation。
As shown in the figure above.
stayhostFill in theIP address
The default port number is 22. Don't worry
Then clickconnectThe pop-up will be confirmed directly
The user name is generallyroot, butTencent ClouduseUbuntuInstance created by image, disabled by defaultrootThe user logs in with a password, so the user name must be filled inubuntu
The password is given by the host company, and it is also filled in.If the key is given, download it from the host company, import it into the Xshell, and then select the key to log in.
searchchinese, install Simplified Chinese, and restart Visual Studio Code;Re searchssh, foundRemote - SSH, install.After installation, there is one more on the leftRemote Explorer。Then go to Remote Explorer Settings.
Click Remote Explorer and the following figure will appear.
Click the set gear and a prompt will pop upSelect SSH confiquration file to update。
Select firstC:\User\xxx\.ssh\config, fill in the connection configuration.
HostThe name is arbitrary,HostNamenamelyipAddress;PortThe default port is 22;UserFor user name, if it is a key login, set the key andconfigFiles in the same location, such as
Tencent CloudNot enabled by defaultrootThe user must enable it.
Use firstubuntuAnd set the password to log in to the server
ssh ubuntu@192.188.1.1
The first connection will require confirmation and complete inputyes, press Enter, and then enter the password.
The input password is completely invisible and can be copied and pasted.Right click to paste in Windows terminal.
Then switch toroot
sudo su root
May be similar/home/ubuntu/Directory, you need to switch torootOnly in the directory
cd
Then modify/etc/ssh/sshd_config
vim /etc/ssh/sshd_config
vimThe basic usage of is to pressiStart input, adjust the cursor position with the direction key, and pressescKey to exit input, input:wqpreservation.Find the following things and change them intoyes, if there is#Just remove it.
your_email@domain.comFill in your email and press Enter for all prompts until prompted
Your identification has been saved in /root/.ssh/id_rsaYour public key has been saved in /root/.ssh/id_rsa.pub
That means the creation is completed, where,id_rsaIs a private key,id_rsa.pubIs the public key.
Then install the public key on the server
cd .sshcat id_rsa.pub >> authorized_keys
usexftporvscodeDownload the private key.
Confirm that the private key is saved locally, and then delete the private key on the server
rm id_rsa
Then use the key to log in.If you successfully log in with the private key, modify the/etc/ssh/sshd_config, disable password login
PasswordAuthentication no
Finally, restart the SSH service:
sudo service ssh restart
Deploy network environment
There is a suspected poisoning event in lnmp.org(Portal), please use with caution.
Because I don't like pagodas, but I don't install Nginx, MySQL and PHP one by one, I recommend usingLNMP one button package。There are also many basic requirements for installing LNMP1H2G、Ubuntu 20.04On the premise, install the latest version of LNMP.
Log in to the console and switch torootuser
sudo su root
Basic system environment under update
apt update && apt upgrade -y
Software on which the installation point is based
apt install -y wget git zip curl
Clean up the garbage
apt autoremove
installscreen
apt install -y screen
Start a new window
screen -S lnmp
If the network is disconnected, executescreen -r lnmp, you can returnlnmpInstallation process
installLNMPIt's a big play. Let's take it step by step.The command here is to install1.8betaVersion. If there is an update, please install the latest version.
wget http://soft.vpser.net/lnmp/lnmp1.8beta.tar.gz -cO lnmp1.8.tar.gz && tar zxf lnmp1.8.tar.gz && cd lnmp1.8 && ./install.sh lnmp
If the machine configuration is not enough,MySQL 5.7.34That's enough.inputfour, enter.
TipsPlease setup root password of MySQL., meaning inputMySQLOfrootThe user password can be defaulted by the script and changed later. Enter directly.
Enabled by default, enter.
comePHP。becauseTypechoOfPHP 8The compatibility of is not very good, and many topics are not supported yetPHP 8, so enter hereten, and then enter.
This also defaults to Enter.
Then the process is over. PromptPress any key to install...or Press Ctrl+c to cancel, continue to enter, and the script will be automatically installedLnmp。
It takes a long time to install LNMP. You can register the domain name at this time.
Register domain name
There are many choices for domain name purchase.If you just build a blog, you can register in China because it is cheaper.If you want to write something wrong, you should choose a foreign domain name provider, which is more appropriate.Specific self inspection.
Domain name suffix, preferred.com、.netAnd other mainstream common domains.Not recommended.xyz, because Baidu does not include or very slow to include;Not recommended.top, because it is worn out, I don't think it looks very good.
Set domain name resolution
With the server and the domain name, the next step is to set the domain name resolution and connect the domain name to the server.Take Tencent Cloud as an example.
With myhimiku.comFor example, the host record is filledwww, the record value is filled in the aboveIP address。Then save it.
So your blog link is www.himiku.com.If you want blog links to appear ashimiku.com, fill in@。Or put@Turn it into your personal homepage withblog.himiku.comIt is also a good choice.
Install Blogger Typecho
1. Download Typecho
If you have already installed LNMP and set the resolution, you can install the blog program first.Here we needXftp,XftpFollow the aboveXshellIt belongs to one company.Download it yourself.The login steps are alsoXshellThe same, turn it up and look again.
After logging in, the default is/rootCatalog, let's go backRoot PathIt usually looks like this.
My screenshot is incomplete, regardless of him.get into/home/wwwrootDirectory. The header here is the root directory of the website you created in LNMP.
Then download the blog program.reachTypecho official websiteDownload the development version directly.The official version has many problems, but the development version is better.Then decompress.What you get is abuildThe folder contains such things.
Drag these things directly into the root directory of the website!But you'd better change your name, such asblogIt's easy to remember, just like this.
There is a disadvantage of the folder dragged in directly. Its owner isroot, Xftp will display, and you can see it after a good search.Here we need some commands to change their owner towww。Please enter the following command in the Xshell:
-RFollow the path of your blog.If the blog program directory is not calledblog, change it yourself.The same is true for subsequent plug-ins. Repeat the above operation and set the blog directory.
2. Create database
Because one step in LNMP's official virtual host adding tutorial is to add a database with the same name, but if you follow my method directly, it is equivalent to skipping, so you need to manually create the database.
If you have just installed LNMP, visitHttp://your ip/phpmyadmin/, enter the login page of phpMyAdmin, and fill in the user nameroot, the password is set when you install LNMP.Recommend renamingphpMyAdminThis folder makes others can't guess what it is.
Then click New on the left and fill in the database name on the left, as shown inblog, default selection on the rightutf8mb4_general_ci, click Create.
3. Install Typecho
In normal order, the domain name should be added to the server before the installation interface can be opened.
If you want to test connectivity first, you can temporarily modify the defaultdefaultfolder.Rename this folder to another name, and then create the newblogFolder renamed todefault, you can directly access the initial settings of the IP start Typecho.
Pay attention to the originaldefaultIn folderphpMyadminThe folder is also moved to your typecho folder.
As shown in the figure, the database adapter, database address, and database port remain default, and the user name isroot,Database nameIt is the newly created database above, such asblog。Database codeModify toutf8mb4, others remain default.
Be sure to selectutf8mb4, otherwise it will be used lateremojiWill crash the database.
If you press OK, a prompt pops up saying:
This is the reason why the permission of the blog program is not enough.New is not recommendedconfig.inc.phpFor files, permissions should be granted to prevent such problems from occurring later.
If your blog path is/home/wwwroot/blog, then:
chown www:www -R /home/wwwroot/blog
This completes the initial installation of the blog.
get into/usr/local/nginx/conf/vhostThis directory (you can copy and paste it into the address bar, press Enter to enter directly), and create a new domain name configuration.confYou can also create the file locally on your PC and upload it to the server.Take my domain name as an example, such aswww.himiku.com.conf。
Use the editor (recommendedVisual Studio Code)Open this file, copy the following contents, and modify the domain name configuration in line 5, the path configuration of the blog program in line 7, and the domain name in line 35.
usednsapiTo verify the ownership of the domain name, and to facilitate the renewal operation in a great way. Here we take Dnspod (Tencent Cloud) as an examplednsapiThe description of needs referenceOfficial Tutorial, almost all the same.
The issued certificate is generally generated by default inroot/.acme.sh/For security reasons, do not use the certificate here directly, but copy it to/usr/local/nginx/conf/sslDirectory, just need to create manuallysslAnd domain folders,
Only need to add a copy certificate--ecc, but the domain name should also be changed accordingly.If you are afraid of making mistakes, please follow me directly.
The certificate will be automatically updated after 60 days without any operationThis time may be shortened in the future, but it is automatic.But you can still use this command to check
acme.sh --renew-all
It is also recommended to enable automatic update
acme.sh --upgrade --auto-upgrade
After that, you need to generate adhparam.pemFile to increase security.
After the certificate is issued successfully, you need to modify the configuration file and force thehttps。Directly replace the original file without certificate, and fill in the following contents.Also, some places need to be explained when modifying the domain name.
The function of line 5 is to accesshttp://himiku.comorhttp://www.himiku.comWill jump tohttps://himiku.com
The purpose of lines 11-13 is to accesshttps://www.himiku.comWill be forced to jump tohttps://himiku.com
Line 17-19 is part of the certificate. Please modify it according to your certificate location and name
Note: After modifying the domain name configuration file, you can test whether there are errors
nginx -t
Restart the Nginx service after no error
lnmp nginx restart
About Typecho Settings
Site name, link settings
For site name and link settings, seeSetup → BasicTo modify.For example, the name of this site is "Initial Voice", which is described as "Listen to the initial voice in your heart", and the site is described as "Initial Voice, Blog".These settings are not only displayed on the home page, but also available for search engines.
staySet → Permanent LinkYou can set custom articles, independent pages, and classification paths in.This site usesWordpress style/archives/{slug}. htmlLink settings for.This style of link has one advantage,slugIt can be modified by itself. Links are not simply digital displays.Default stylecidIt cannot be changed.However, each has his own needs.
Other independent pages and classification paths are default.
It should be noted that once the link format is determined, it should not be easily modified, unless you don't care about the pages that have been captured and displayed by search engines.
Website Logo
The logo of the website is afavicon.icoFile, prepare a square or circular picture, search for "favicon making", and rename the conversion result tofavicon, put this file in the blog root directory.
Refresh blog, pressctrl+shift+R, it will be displayed in the address bar after refreshing.
Personal portrait and nickname
The profile is set inConsole → Personal SettingsThe password is reset here.
Pseudo static
Previously, pseudo static configuration was added to the Nginx configuration file.The pseudo static of Typecho is mainly used to remove theindex.php, we need toSet → Permanent LinkEnable this feature in.However, after enabling, you will be prompted that the detection of rewriting function failed. If you are sure that you have added pseudo static, you can directly check Enable and ignore this error.
Installing plug-ins
Take blog directory asblogThe plug-in is stored in/home/wwwroot/blog/usr/plugins, drag all downloaded plug-ins to this header, and grantwww:wwwAuthorityseven hundred and fifty-fivejurisdiction.Note that the compressed package should be decompressed and uploaded.
For other plug-ins, please refer to thePlug in List。
About VOID Topic Settings
If you refer to this site and also use the VOID theme, some settings will not be set without viewing the document.This part is added on the basis of your laziness.
file
stayManagement → Independent PageCreate a new page named "Archive" in the address bar and modify it toarchives, rightCustom TemplateSelect Archives.
Friendly chain
stayManagement → Independent PageCreate a new page named "Friendly Link" in the address bar and modify it tolinks。The format of the friend chain is as follows:
Because these codes will be parsed directly if the VOID theme is used, please remove the '#' symbol in the following codes.[#links][Blog name] (Blog link)+(avatar link)[#/links]
Super Advanced Settings
There are "Super Advanced Settings" in the theme settings.Found in theme fileadvanceSetting.sample.jsonThis file contains the description of super advanced settings.The settings of the height and font of the head map are all in it, which is very detailed.
Here is an example. Set the desktop end map height to account for 100, the mobile end map height to account for 30, the navigation bar mode to be fixed, and the image title will be displayed below the image.
It can be uploaded directly in the blog, but later maintenance is troublesome, so it is recommended to use the public map bed orSelf built map bed, specific self inspection.
Copyright notice:Unless otherwise stated, all articles are my own creation. Please contact the author for reprinting and quotation, and indicate the source (author, original link, etc.).
• Please fill in the real email when commenting so that you can receive the reply reminder. • Initial comments need to be reviewed, and comments irrelevant to the article should be posted on the message page.
Blogs and articles are great! By the way, please tell me how to implement the copyright notice at the end of the article. It seems that in addition to plug-ins, you need to add code to the. php document. Simply installing plug-ins is invalid. In addition, how is the function of the button of enjoying a cup of coffee realized? Thank you for your answer.
The copyright notice is the function of the plug-in, and the coffee tasting button is the function of the theme. Just fill in a picture link at the reward QR code of the theme setting
Thanks for the answer.At present, the plug-in for which I installed the copyright notice cannot be used normally.I tried for a long time, but I don't know what the problem is.Is it convenient to specify how to use this plug-in? My current problem is that after the plug-in is installed, the settings page can be opened, but after checking the settings, click Save, and cannot be saved.By modifying permissions, there is still no way to implement plug-in functions, and there is no response before installation.
I still can't figure it out. It's too difficult for someone who doesn't understand PHP. This plug-in is just needed, and its functions are very practical, but the configuration is really deadly.The problem is not the plug-in, but the user himself. It may also be that the version does not match. My version is the latest development version of Docker Environment+Typecho (official download of github, V1.2.1-rc+VOID development version). Sorry, please ask me again. This plug-in is directly enabled in the background. Can it be used?Or do I have to modify the php file in the plug-in folder after enabling it?Or something like that (I look at the original author's description document, which says, "You can set the value of any field toInteger 0To close it.)
Thank you for your praise (/ω\) As for the mouse problem, do you use the pointer to draw word for word, if so, it will really hinder reading It's just a personal hobby to beautify the mouse. I don't really want to change it back. Sorry | ´・ω・) ノ
Hi, I'm here again. I want to ask you, after installing the lnmp, will the file contents in the build of the typecho be directly dropped into the wwwroot directory?Is it convenient to add a Q?My email is qq email