Alibaba cloud server records

0903 work record

Install java

View installable java versions

yum -y list java*

Install Java 8 version

yum install -y java-1.8.0-openjdk-devel.x86_64

View java jdk version

java -version

Deploy tomcat server

Download a software apache-tomcat-9.0.0.M1.tar.gz
If the server does not support rz function, you need to install

yum -y install lrzsz 

Unzip tomcat

 tar -xzvf  apache-tomcat-9.0.0.M1.tar.gz

Start tomcat and enter the bin directory in tomcat

  • Execute:. / startup. Sh -- > start tomcat
  • Execute:. / shutdown. Sh -- > Close tomcat

09-04

Installing nginx

Install Compilation Rules and library files

yum -y install make zlib zlib-devel gcc-c++ libtool  openssl openssl-devel pcre-devel

GCC and gcc-c + + # are mainly used for compiling
openssl and openssl devel # are generally required when configuring https services
Zlib and zlib devel # are mainly used for file decompression
PCRE regular expression syntax is used in the rewrite Module of PCRE devel # nginx and HTTP core module

Create nginx folder in usr/local folder, and download and install nginx

wget https://nginx.org/download/nginx-1.18.0.tar.gz

decompression

tar -zxvf nginx-1.18.0.tar.gz

4. Enter the installation package directory, compile and install nginx, and install it in / usr/local/nginx by default

cd  /usr/local/nginx/nginx-1.18.0
./configure
make && make install

6. Enter / usr/local/nginx/sbin directory and start nginx

./nginx

7. View the started nginx process

ps -ef|grep nginx

8. See if you can access

curl localhost:80

Install unzip

yum list | grep zip/unzip 
yum install zip
yum install unzip

Deploy front end project to server

Package front end Engineering

npm run build

After packaging, a dist file will be produced in the project path, and the dist file will be renamed dist ATP (the name can be customized)
Upload the dist ATP file to the / usr/local/nginx/html path of the server
Configure nginx.conf

cd /usr/local/nginx/conf
vim nginx.conf
#Number of processes started
worker_processes  1;
events {
#Single process concurrency
    worker_connections  1024;#Total concurrency = concurrency of a single process * number of processes started
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;#Timeout duration of connecting to server: 65s
    #Virtual host configuration

    server {#If one virtual host is configured, multiple virtual machines are configured
        listen       8888;
        server_name  123.57.1.35; #Domain name resolution
        location / {#Configure default access page
            root   /usr/local/nginx/html/dist;
            index  index.html index.htm;#Visit your home page
            try_files $uri $uri/ @router;
        }
        location ./ {
           # The agent forwards to the background service interface. Pay attention to the English semicolon behind it; No less
           proxy_pass http://123.57.1.35:8090/jeecg-boot/swagger-ui.html;
        }
    location @router{
    #rewrite ^.*/index.html last;
    rewrite ^(.+)$ /index.html last;
    }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

Check whether nginx.conf is configured correctly

/usr/local/nginx/sbin/nginx -t

Upload dist project package in / usr/local/nginx/html directory and decompress the project package
Restart nginx in the / usr/local/nginx/sbin directory

./nginx -s reload 

[the external chain image transfer fails. The source station may have an anti-theft chain mechanism. It is recommended to save the image and upload it directly (img-8nxas11h-1630845026174) (C: \ users \ administrator \ appdata \ roaming \ typora \ user images \ image-20210904090236456. PNG)]

Deploy successfully, sprinkle flowers...

MySql

Download and install mysql

yum -y install mysql mysql-server mysql-devel

Start service

service mysqld start

Change Password

/usr/bin/mysqladmin -u root password '1234'

Enter mysql

mysql -u root -pxxxx

The problem of nginx cross domain configuration was encountered during deployment

I've been looking for a blog all day, but I still haven't solved the problem

Access to XMLHttpRequest at 'http://47.96.147.252:8888/articles/hot' from origin 'http://47.96.147.252:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

09-05

Install redis

1. Obtain redis resources

wget http://download.redis.io/releases/redis-4.0.8.tar.gz

2. Decompression

tar -xzvf redis-4.0.8.tar.gz

3. Installation

cd redis-4.0.8
make
cd src
make install PREFIX=/usr/local/redis

4. Move the configuration file to the installation directory

cd ../
mkdir /usr/local/redis/etc
mv redis.conf /usr/local/redis/etc

5. Configure redis to start in the background

vi /usr/local/redis/etc/redis.conf #Change daemon no to daemon yes

6. Add redis to startup

vi /etc/rc.local #Add content to it: / usr / local / redis / bin / redis server / usr / local / redis / etc / redis.conf (meaning to call this command to start redis after startup)

7. Enable redis

/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf

8. Copy redis CLI and redis server to bin so that redis cli instructions can be used directly in any directory

cp /usr/local/redis/bin/redis-server /usr/local/bin/
cp /usr/local/redis/bin/redis-cli /usr/local/bin/

9. Set redis password

a. Run command: redis cli

b. View the existing redis password (optional)

Run the command: config get requirepass

c. Set redis password

Run the command: config set requirepass * * * * (* * * * is the password you want to set). If the setting is successful, the word "OK" will be returned

d. Test connection

Restart redis service

//(redis cli - H 127.0.0.1 - P 6379 - A * * * * (* * * * password set for you))

Enter redis cli to enter the command mode and log in with auth '*****' (**** password set for you)

10. Common commands

redis-server /usr/local/redis/etc/redis.conf #Start redis
pkill redis #Stop redis

The different port numbers used at the front and rear ends lead to cross domain configuration problems

After searching the blog all day today, the first major problem is that I can't understand the front-end code. When modifying its configuration file, it is divided into local configuration and production configuration. What has been modified before is the local configuration, which makes the server front-end code unable to effectively access the back-end interface.

After modifying the first problem, I encountered the problem of CORS cross domain configuration. I searched many solutions before. Because the card failed to work on the first problem, but there was still CORS error after modifying nginx.conf. Later, I felt that it might be the problem of cross domain configuration of back-end code. After changing the localhost of back-end code to my ip address, I was OK.

Sprinkle flowers at the end

[the external chain image transfer fails. The source station may have an anti-theft chain mechanism. It is recommended to save the image and upload it directly (img-uzh1hu2i-1630845026179) (C: \ users \ administrator \ appdata \ roaming \ typora \ user images \ image-20210905193925511. PNG)]

Tags: Operation & Maintenance Nginx Tomcat

Posted on Sun, 05 Sep 2021 21:52:08 -0400 by Wayne Herbert