Preface
By chance, I saw a highly praised question on a certain website: How to prove the ability of computer science students? There are also many comments under the question. The most clear and realistic one I remember is: What ability do I have? I just want to show off.
Seeing this, I have to stand up and say that building a website is not the only way to prove one’s ability, right? After all, “every profession has its own specialty”, right? I don’t know why improving one’s practical skills and broadening one’s knowledge has become a keyboard warrior’s show-off. I can’t criticize it, please forgive me, please forgive me
OK, back to the point. My original intention of building a personal website is actually very simple. Maybe you have also thought about it, but you just haven’t done it. I thought: there are many writing platforms on the Internet now, such as the C station I am using now. It is very mature and has everything you need for community discussion, question posting, Blink dynamics, etc. After I have learned the relevant knowledge, why can’t I write one myself? Maybe it’s more because I like to tinker, haha
I first came into contact with it in the “Section Customization” module of C Station’s article publishing. I could enter a few lines of code to have a beautiful interface. At that time, I had not yet come into contact with CSS and Web front-end, so I learned them for free from the Internet, which aroused my interest in further learning.
What is a blog? A blog is a platform for sharing and communication. We can learn from others’ experience and improve ourselves. This is true for people who read blogs. For bloggers, it is a summary of what they have learned, which can help them sort out their thoughts, facilitate future review, and develop good habits. Technical blogs can record the problems we encounter and better bug handling solutions. When we encounter the same problems in the future development process, we will remember them more deeply.
Once you have an idea, you should start working on it. When I actually started working on it, I realized that it was not some headline-grabbing article, like “Build your own website in 10 minutes, you still can’t build a website yourself?” When I actually watched their videos and articles to operate, some of them were really great. They assumed that you should know some things, and they would write them in a simpler way. Some of them were just “great porters”, who simply posted other people’s articles without putting the original link.
It is because I have not found a complete set of resources that can help novices develop a website, so I decided to write down the process of UP website building and share some of my experiences from the beginning to the final realization. So, if you also want to have your own website, you can follow the operation. If you encounter any problems during the process, you can send a private message or leave a message. Now, let’s get started together
Think about it, what do we use most to search for information? Some friends will say: Why ask? It must be “Studying at Bilibili” or search engines. Yes, I think this is the tool most used by most of us when we learn new things and keep exploring. So, what do we search for? For example, you can do this:
Perhaps you can also:
Indeed, you can search for a lot of videos and articles. But in this part, I will describe my mental journey from the perspective of a beginner: because this thing is just a preliminary idea in my mind, and I don’t know how to realize it. It’s like a person who is lost in the mountains. I only know that I have to get out, but I can’t find the way.
In this post, let’s talk about building a website and what I should prepare. Most of the tutorials on the Internet are long and you can’t finish them even after several clicks of the mouse. It will give beginners a feeling of “Wow, it’s so difficult, there are so many things”, so here I have classified the contents of each part, you just need to follow the order and go down step by step
Local Website
Why do I emphasize “local” here? At the beginning, I also read tutorials and followed other people’s ideas, such as buying a domain name and a server. I have stepped into the pit. This will cause difficulties for beginners in purchasing or choosing. Why don’t we change the way of thinking? Now I build a website on my own computer, and then “send” it out so that others can see it. You see, isn’t this very clear?
To build a website on your computer, you need two things: a browser and development tools . I’m sure everyone has the former, so I won’t go into details (otherwise, how would you read this article? Hehe). We’ll focus on the latter.
Development Tools
WebStorm
WebStorm is a JavaScript development tool from JetBrains. It has been praised by many Chinese JS developers as “Web front-end development tool”, “the most powerful HTML5 editor”, “the smartest JavaScript IDE”, etc. It has the same origin as IntelliJ IDEA and inherits the powerful JS functions of IntelliJ IDEA.
Enough of the crap, come here to download the portal
Here, there is a small problem. This thing is charged. If you are a college student, you can apply for an educational account for free through student certification. If… (I won’t say more, ask Baidu and you will find a way), just install it without any hesitation. Don’t panic.
Vscode
Visual Studio Code (VS Code for short) is a cross-platform source code editor for writing modern Web and cloud applications that runs on Mac OS X, Windows, and Linux. It was officially announced by Microsoft at the Build Developer Conference on April 30, 2015. It runs on the desktop and is available for Windows, macOS, and Linux. It has built-in support for JavaScript, TypeScript, and Node.js, and has a rich ecosystem of extensions for other languages (such as C++, C#, Java, Python, PHP, Go) and runtimes (such as .NET and Unity).
Portal
Specifically, these two tools are: the former is a full-package (it has everything, you don’t have to worry about it, just use it directly), and the latter is a shell company that needs various employees (plug-ins) to implement some functions. So if you are too lazy to configure, just download the first one. The second one may be more convenient for writing blog Markdown syntax, which I will talk about later. If you are a novice here, I suggest you download WebStorm , which will be more convenient for some configurations in the following text
frame
What is “framework”? You are confused, right? Hehe. Don’t panic when you encounter something, and listen to Jason’s explanation. Here we look at the explanation of a certain term:
A framework is a frame, which refers to its constraints, and a frame, which refers to its support. It is a basic conceptual structure used to solve or deal with complex problems.
This broad definition of framework is very popular, especially in software concepts. Framework can also be used for mechanical structures.
What is this equivalent to? For example, if we build a house, how do you build it? We can’t start without drawings and workers. Isn’t this a “fairy tale”? First of all, it must be necessary for the designer to design the drawings according to user needs, and then the workers will start building the house based on this drawing, right? A lot is omitted here, please let the industry experts go, let me give you an example.
The same is true when we build websites. Do you really think that so many websites are written from scratch by programmers working day and night? Emmm, in fact, my answer to this question at the beginning was: Well, yes, of course. It was not until I went to internship that I found that some things in the enterprise were not all developed from scratch. (Open source is good, hahahaha) Do you want to be like this?
A product, project, website… As long as it is something that has been done by predecessors, we can learn from it. Learn good coding, open source, why waste time to do it again when others have already achieved it? Especially WordPress , which is going to be introduced below , is simply a “brainless operation”. You may not know what you have done, but a website that belongs to you will come out just like that.
In layman’s terms, a blog framework is a set of source code written by others. You just need to use it, modify your own configuration, and add the theme you want. That’s enough (big guys, please take a detour). So below I will share with you some frameworks I learned when building my personal website, and briefly analyze them for your selection.
As always, the target audience of this column is new friends, so I will not mention some complicated parameters that you don’t need to know. I will only mention the most critical parts to help you quickly find the one that suits you.
I’d like to state in advance that Jason uses the framework ==Hexo== . You can choose a different one from me, but the configuration is not exactly the same. The same can be achieved.
Hexo (highly recommended)
Hexo is a fast, simple and powerful blogging framework. You write your posts in Markdown (or other markup languages), and Hexo generates static files with beautiful themes in seconds. >Click here to go<
Hexo Features:
Excellent operation effect and low cost
Multi-platform: local, cloud, PC, mobile
Support multiple CDN services (enabling it can increase the speed of web page loading)
Major search engines have a greater advantage in the inclusion and weight of websites (users are more likely to search for the content you publish)
If you like configuration and want to complete certain configurations after operating the code, this one will suit your taste. Here is a screenshot of the configuration for reference:
WordPress
WordPress is a free and open source content management system (CMS) based on PHP and MySQL. It is the most widely used CMS software in the world. From a simple blog system at the beginning, it has developed into a complete CMS system with thousands of plug-ins, widgets and themes. > Click here to go directly<
WordPress Features:
Wide range of commercial applications
Convenient for subsequent backup and transfer, with built-in tool support
Strong scalability (think of Google's plug-in store here)
Very user-friendly for customization (you can definitely build whatever you want)
If you don't want to read the code, you can use this one. WordPress comes with backend management. Select the theme you want, and then drag and drop the required controls (for example, if you want to display the time, there will be something like a mobile desktop widget, just drag it to the location you want to display). In addition, the most important thing is that you need to get a server first to use it
In order to help you find the right one more quickly, I will not give you many options, nor will I tell you what else there is (otherwise you will feel that what I have now may not be the best, and I need to try more. If so, you will waste a lot of time unknowingly. It is better to build one first, and then change to other ones when you are familiar with it in the future.) When you get started independently, you will have a clear idea and will not spend too much time on a certain point.
Local Environment
There is no need to introduce this part too much. You can understand that we need cement, shovels and other tools and raw materials to build a house. The local environment is the shovel we use, which is a tool. And Hexo 's blog framework is the raw material like cement. We need tools to start working, otherwise you can't do it with your hands...
git
Briefly describe what it is used for, Look Here:
Git is an open source distributed version control system that is used to handle any small or large project in an agile and efficient manner. It is an open source version control software developed by Linus Torvalds to help manage Linux kernel development. Git is different from commonly used version control tools such as CVS and Subversion. It uses a distributed version library and does not require server-side software support.
Don't worry about the words you've never heard of above. Here's how it works. Have you used Baidu cloud disk? Is there an automatic backup function? You select a local folder. When the local file changes, as long as the software is running in the background, the cloud will automatically keep the same as the local file. This is the process. However, you can now imagine the operation of git as a cloud. With some commands, you can "send/backup" the local code to the cloud.
I have not elaborated on the distributed features and commands of git . I recommend that beginners can > see here
Exclusive for students (after experiencing it, you can get a free ECS server for half a month. If you publish your experience in the community (post a blog), you can renew for free for two months). For specific rules, please check the official website
Account Center-> Basic Information Complete student authentication
Latest EventsLocation purchase discounts will be greater
deploy
Password setting
Change the remote connection password in the icon position and save it.
Although you can use a browser to connect remotely , it is not recommended because some keyboard shortcuts will be mistaken by the system as browser operations rather than dialog boxes.
remote connection
To avoid such problems, we choose to use a third-party tool, Putty . For specific steps, see Alibaba Cloud’s help document.It has been very detailed, so I won’t repeat it here.
Start watching from here and follow the prompts to complete the operation
Start Putty , connect to the server, log in as root , and use the password set on the server (the password entered in the Linux operating system is not displayed for security reasons, so don’t worry). When the following interface appears, it means the configuration is normal, and you can proceed to the next step
git configuration
1. Enter the command to install git
yum install git
If the installation is paused, enter yes/y/Y as prompted to continue the installation until complete appears, indicating a successful installation.
2. Create a git account
adduser git
3. Add git account permissions
chmod 740 /etc/sudoers
vim /etc/sudoers
4. After executing the last command, click the keyboardiEnter the edit mode and find the position code shown in the figure
Add a line below
git ALL=(ALL) ALL
according toEsckey and enter ==:wq== (meaning: save and exit)
5. Reset permissions
chmod 400 /etc/sudoers
6. Set the git account password
sudo passwd git
Enter the command and press Enter, then enter the password twice in a row (no display, normal), and the icon appears, indicating success
7. Switch to git account
su git
Create ~/.ssh and ~/.ssh/authorized_keys files
mkdir ~/.ssh
vim ~/.ssh/authorized_keys
Click on the keyboardiEnter the edit mode and paste the SSH public key generated by the local computer . The file location is as shown in the figure
After pasting, pressEsckey and enter ==:wq== (meaning: save and exit)
Grant permissions
chmod 600 /home/git/.ssh/authorized_keys
chmod 700 /home/git/.ssh
8. Test whether the password-free login is successful in the local git bash here
ssh -v git@server public IP
The icon appears to indicate a successful connection
9. Create a warehouse in the server and complete the configuration
to switch to the root account
sudo su root
Create a repo repository directory
mkdir /www/repo
Grant permissions
chown -R git:git /www/repo
chmod -R 755 /www/repo
Create the website root directory hexo
mkdir /www/hexo
Grant permissions
chown -R git:git /www/hexo
chmod -R 755 /www/hexo
Create a new blank git repository and initialize it
cd /www/repo
git init –bare hexo.git
10. Create Git hooks for automatic deployment
vim /www/repo/hexo.git/hooks/post-receive
Same as above, enter edit mode, paste the following code and save and exit
#!/bin/bash
git –work-tree=/www/hexo –git-dir=/www/repo/hexo.git checkout -f
Modify permissions
chown -R git:git /www/repo/hexo.git/hooks/post-receive
chmod +x /www/repo/hexo.git/hooks/post-receive
Warehouse built
Install Nginx
Nginx is a lightweight web server/reverse proxy server and email (IMAP/POP3) proxy server, released under the BSD-like protocol. Its characteristics are small memory usage and strong concurrency. In fact, nginx’s concurrency performance is better than that of similar web servers.
Nginx (engine x) is a high-performance HTTP and reverse proxy web server, and also provides IMAP/POP3/SMTP services. It releases its source code in the form of a BSD-like license and is well-known for its stability, rich feature set, simple configuration files, and low system resource consumption.
yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && bash install.sh
Enter y in the middle to continue the installation (same as above) and wait for the installation to complete. The login URL and initial password will be displayed.
Note the red box. If both URLs are inaccessible, please allow port 8888 in the server security group/firewall.
Enter the initial account name and password to log in
After entering, search for Nginx and click Install (I have already installed it here)
Website–> Add site, domain name format xxx.com without any prefix
Settings –> Configuration file, modify the content in the red box
Settings–> Website Directory, change to ==/www/hexo== and save
Server terminal, restart the service
service bt restart
At this point, the server configuration is complete
Hexo configuration modification
Enter the local blog root directory and modify the deployment location of the _config.yml file
GitHub Pages settings
Server Setup
The source code is as follows
# Deployment
## Docs: https://hexo.io/docs/one-command-deployment
deploy: type : git repo: git@yourdomain:/www/repo/hexo.git branch: master # Note the branch setting here, you need to select the default branch in the repository
Open the Putty tool, connect to the server and grant permissions
chown -R git:git /www/repo/
chown -R git:git /www/hexo/
Open git bash here in the local root directory and execute the command
hexo clean //Clear cache
hexo d -g //Quick deployment
The icon appears to indicate that the deployment is successful. Once the filing is completed, you can access it through the domain name.
Record keeping
Jason’s website was only recently filed, so if you can’t wait, look for another way. In China, we dare not act rashly.
You will go through the following stages
After purchasing the server, after binding the domain name, the system will prompt you that you have not registered. Just follow the prompts to complete it.
ICP
English full name: Internet Content Provider, Chinese full name: Internet Content Provider
ICP can be understood as a telecommunications operator that provides Internet information services and value-added services to a large number of users. It is a formal operating enterprise or department approved by the national competent authorities.