This is the second day of my participation in Gwen Challenge

preparation

Preparations: One Alicloud ECS server (centos) and one domain name

Purchase the domain name to configure SSL and enable resolution to your own server
  1. Buy a domain name, WHAT I bought is ali cloud student domain name. Top, a piece, choose a domain name, and then authenticate, put on record, wait for a few days, did not put on record can not visit.

  2. Buy an SSL certificate and verify it. www.bilibili.com/video/BV17t…

  3. Download the corresponding server certificate, I use nginx to choose

  4. Download and unzip two files, one with a.key suffix and the other with a.pem suffix, and upload them to the server folder via FTP or other software, and configure them in nginx. Nginx will cover this later.

A Record: The domain name points to an IPv4 address (for example, 100.100.100.100, which is the public IP address of the server you purchased). You need to add A record. You need to add A record to the domain name resolution and write the record value to the public IP address of the server.

Open port

Select CentOS7 for the ECS cloud server, go to the console to configure security group rules, and enable port 80 (HTTP service) and port 443 (HTTPS service). Ports are like assuming that the server is an exhibition, and there are many different pavilions, the ports corresponding to the open pavilions can only be seen by others. If you don’t open the port, no one can see what’s in your house.

Install Vuepress

Installation Node. Js

Reference: www.cnblogs.com/qiushuiwany…

yum install -y nodejs
Copy the code

Update the NPM

npm install -g npm
Copy the code
Install Vuepress-Reco (or any theme you like)

www.oschina.net/p/vuepress-…

Download it and upload it to a server using software like XFTP. (It should be able to install it directly, but I don’t know why I can only upload it from Windows to use it.)

Connect to the server using Xshell or command line SSH

Have the server use the CD command to go to the root directory where you uploaded the Vuepress project.

Execute the NPM run docs:build command. See package.json for the specific build command, which may vary by project. Make the project a public file (or dist, a static file generated by the construction of the project)

Configure Nginx

Install and configure Nginx

Configuration problem: blog.csdn.net/luomao2012/…

Compile the installation

  1. Install the required plug-ins

    yum -y install gcc
    yum install -y pcre pcre-devel
    yum install -y zlib zlib-devel
    yum install -y openssl openssl-devel
    Copy the code
  2. Download Nginx and unzip it

    Installation Reference: blog.csdn.net/weixin_4139…

    This download is downloaded to your current directory. /usr/local/

    Wget HTTP: / / http://nginx.org/download/nginx-1.9.9.tar.gzCopy the code

    Unpack to usr/local/server

    Tar -zxvf nginx-9.9.tar. gz -c usr/local/serverCopy the code

    Compile and install (this place should pay attention to install SSL module!!)

    ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_gzip_static_module --with-http_ssl_module
    make
    make install
    Copy the code

    Configure to environment variables

    vim ~/.bash_profile
    Copy the code
    export NGINX_HOME=/usr/local/nginx
    export PATH=$PATH:$NGINX_HOME/sbin
    Copy the code

    source ~/.bash_profile
    Copy the code

    Start the nginx

    nginx
    Copy the code

    Access IP (Enter your IP address in the browser address bar)

    The default is to access index.html in the corresponding HTML file configured in niginx (just like starting Tomcat with a default page).

    Configure nginx.conf (nginx main configuration file) Multiple sites you can also control through include configuration files.

    #user  nobody;
    worker_processes  1;
    
    #error_log  logs/error.log;
    #error_log  logs/error.log  notice;
    #error_log  logs/error.log  info;
    
    #pid        logs/nginx.pid;
    
    
    events {
        worker_connections  1024;
    }
    
    
    http {
        include       mime.types;
        default_type  application/octet-stream;
    
        #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
        #                  '$status $body_bytes_sent "$http_referer"The '#'"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 443 ssl ; server_name anblog.top www.anblog.top; SSL certificate pem and key SSL on; ssl_certificate /usr/local/nginx/conf/blog/blogpem.pem; ssl_certificate_key /usr/local/nginx/conf/blog/blogkey.key; ssl_session_timeout 5m; Ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:! aNULL:! MD5:! RC4:! DHE; ssl_prefer_server_ciphers on; Projects generate static file path of the # you point to the location / {root/var/lib/Jenkins/workspace/vuepress/public; index index.html; } # caching strategy the location ~ ^ / javascript (images' | | js flash | | | CSS media | static) / {expires 30 d; } } server { listen 80; server_name anblog.top www.anblog.top; Return 301 HTTPS://$server_name$request_uri;}}Copy the code

    If nginx can access the Jenkins server, you can select “public” from the directory where your blog is stored, as long as nginx can access it

    Restart the nginx service

    nginx -t 
    nginx -s reload
    Copy the code

    Visit your domain name to see the page

    Some common Nginx commands

    Nginx -s reload # Restart nginxCopy the code

    Nginx automatic configuration website: www.digitalocean.com/community/t…

Update the blog

Every time you need to update your Vuepress blog, build first and then start it.

npm run docs:build
npm run docs:dev
Copy the code

In the pit of

The images in images cannot be accessed.

# can't access to the location of the images in the delete () it's good that the location ~ ^ / (javascript | js flash | | | CSS media | static) / {expires 30 d; }Copy the code

NPM error

Just update NPM.

npm install -g npm
Copy the code

Just installed 6.1.37, update to 7.8.0