当前位置:网站首页>The first thing with a server
The first thing with a server
2022-06-12 11:41:00 【Jioho_】
Preface
As a program ape ,linux It is always something that cannot be bypassed , In fact, the server has been bought for a long time , They never started , This time I will record my first server
The server is also from 0 Start building , Then I started to install software for my friends ( Useless pagoda , Fully manual installation ) The installation process will also be mentioned later
Install the software
The front end needs to run the project. In fact, it doesn't need many things ,nginx、nodejs、git. It's enough to play
git install
git The installation is actually very simple , Because it uses centos Server for , So direct yum install git Just a matter of , There are not many fancy things
nginx install
Check out the previous blog links , Personally, I think it is very detailed
linux install Nginx Detailed tutorial , Including installation package link
Establish a soft connection , Let the whole world use nginx command
ln -s /usr/local/nginx/sbin/nginx /usr/local/bin
nodejs
With the above foundation , install nodejs It's very simple
First Get into /usr/local Catalog , Finally, we put node Install in this directory
download (wget Is to download the command , Download the content of the network link )
# download
wget https://nodejs.org/dist/v14.16.0/node-v14.16.0-linux-x64.tar.gz
# decompression
xz -d node-v14.16.0-linux-x64.tar.xz
# After executing the command, unzip
tar -xf node-v14.16.0-linux-x64.tar
# Delete compressed package
rm -f node-v14.16.0-linux-x64.tar
# Perform the move operation , In fact, it is the operation of renaming
mv node-v14.16.0-linux-x64/ /usr/local/nodejs
The step of establishing a soft connection is to node and npm The command allows them to use globally
# Establish a soft connection
ln -s /usr/local/nodejs/bin/node /usr/local/bin
ln -s /usr/local/nodejs/bin/npm /usr/local/bin
To configure nginx Set up your blog
The first step is to find the file of your blog , Find a place to settle down . So I put all my projects in /data Under the table of contents .
Then change nginx Configured with . Here is a pit worth recording :
The pit of domain name secondary directory
Because my blog was built on the service of code cloud jioho.gitee.io/blog/. So package the configuration
base: '/blog/'It was also specially changed . What we are actually visiting isjioho.gitee.io/blog/Actually, the accessed folder is the root directory ( It may be a little difficult to understand , But this is the truth ). In this case nginx To configure , You need a tool calledaliasConfiguration of
- nginx Default configuration
Simply put, this configuration , monitor 80 port , The domain name monitored is localhost(ip Address ), And then the first one location Matching mode , Is access ip:8080/ The first one on the match /, Will use {} The configuration inside
On the match /50x.html The website of , It will jump to nginx default The status value is 500+ A web page of shows
In particular root, This is the root directory of the project , My project entrance is in /data/blog/dist/index.html. That means we visit the domain name domain name .com/ From the beginning, you can understand the directory hierarchy of the resource manager , therefore root To configure to :/data/blog/dist/. Let him go into our project directory
And then the back index Configuration means index The default search entry file name . There are some index It may be followed by index.php It's the same thing , Is to find the default file .
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
The above description is suitable for general project construction , Due to the domain name of the code cloud ( It should have been / Of , One more for no reason /blog/), So we have to continue to change the configuration
Add a new one locatiion Revised as follows :root.root It is amended as follows alias. The configuration is /blog. Then use an alias to put domain name /blog Map to the root directory of the project .
location /blog {
alias /data/blog/dist/;
index index.html index.htm;
}
Just briefly root and alias difference
- root The result of the treatment is :root route + location route
- alias The result of the treatment is : Use alias Path replacement location route
- Use alias when , The directory name must be followed by "/".
- alias When using regular matching , You must capture the content you want to match and use... At the specified content .
- alias Can only be in location In block .(root It can be left out of location in )
except alias , There's another way , It's the agent (proxy_pass), The configuration is as follows :
location /blog/ {
proxy_pass http://blog.jioho.cn/;
}
nginx To configure 404 page
The second one is 404 page , Because I'm using vuepress-theme-reco This topic framework , therefore 404 There is a link to find someone , For example, you can visit a website that does not exist under my domain name jioho.gitee.io/blog/bucunzaidewanzhi.html It's just one. 404 Interface This 404 Well , It also points to us index.html, Let the front end handle it by itself , Rather than using nginx default 404 Interface
404 The interface configuration is also very simple , Namely 404 The page will be led to index.html Go to , Then let the routing processing of the framework be done
error_page 404 /404.html;
location = /404.html {
alias /data/blog/dist/index.html;
}
nginx To configure https
https It is also the standard configuration of the site , Free of charge ssl Certificates are also available , I use Alibaba cloud Alibaba cloud is free SSL Certificate application method and process ( Text course )
Now nginx I can also be a demon , But I was subdued a few years ago , All kinds of errors are reported in this article ,Linux Next nginx To configure ssl Certificate implementation https visit
Last
In fact, I have been waiting for a long time , For example, buy a domain name , Server filing , And so on , After you have your own server , Future output may be more fun !
边栏推荐
- Relatively rare exception records in UI automation test
- Architecture training module 7
- 【深度学习基础】反向传播法(1)
- Mysql45 lecture 01 | infrastructure: how is an SQL query executed?
- Logrotate log rotation method create and copyruncate principles
- 正则表达式 | 浅解
- Les humains veulent de l'argent, du pouvoir, de la beauté, de l'immortalité, du bonheur... Mais les tortues ne veulent être qu'une tortue.
- 邻居子系统之ARP协议数据处理过程
- Go sends SMS based on alicloud
- ARM指令集之杂类指令
猜你喜欢

Lambda and filter, index of list and numpy array, as well as various distance metrics, concatenated array and distinction between axis=0 and axis=1

manuscript手稿格式准备

多普勒效应的基本原理

C# 35. Select default network card

Face recognition PIP failed to install Dlib Library

Using stairs function in MATLAB

UML系列文章(31)体系结构建模---部署图

C# 37. textbox滚动条与多行

ReentrantLock源码分析

套接字实现 TCP 通信流程
随机推荐
M-arch (fanwai 10) gd32l233 evaluation -spi drive DS1302
go基于腾讯云实现发送短信
Relation entre les classes et à l'intérieur des classes de classification vidéo - - Régularisation
Google Earth Engine(GEE)——Kmeans聚类快速进行土地分类(双for循环快速调参)
QT based travel query and simulation system
Using stairs function in MATLAB
Pytorch笔记
Manuscript manuscript format preparation
ReentrantLock源码分析
一个人必须不停地写作,才能不被茫茫人海淹没。
Arm cross compilation chain download address
Reentrantlock source code analysis
K59. Chapter 2 installing kubernetes V1.23 based on binary packages -- cluster deployment
890. find and replace mode
UML系列文章(30)体系结构建模---制品图
Summary of rosbridge use cases_ Chapter 26 opening multiple rosbridge service listening ports on the same server
One must keep writing, so as not to be submerged by the vast crowd.
C# 35. Select default network card
logrotate日志轮转方式create和copytruncate原理
Unity connect to Microsoft SQLSERVER database