primers

I thought about project Light for a long time and felt ready to start. The first beam of light enters the server:

Servers are to hobbyists what swords are to men

About Linux cloud server to get started, the pit to walk you through. Remember one thing: a server is an always-on, screen-less notebook, a brick remover who never sees the light of day.


Chapter one: Entering the arena

1. Blood

How do you know if something is yours? Yes, it’s a password. So that your artifact is yours alone:


2. Who am I, where am I, and where am I going

Click Login to enter the server

Then speak the first of the three questions of the soul: Who am I?

And then uttered the three questions of the soul: Where am I?

And then the end of the soul’s three questions: Where am I going?

This problem is too difficult, the server says I don’t know.


3. A sword in a scabbard fits a hero

It’s a hassle to use a browser every time you log in, and there’s a lot of terminal connectivity software, like SecureCRT

Downloading stuff, a bunch of them. Click quick Connect in the upper right corner and fill in the host name with your public IP address (IP is the red area in the first image)

Then you’ll be asked to enter your password. Just type it in.

[root@VM_0_4_centos ~]# centos Linux release 7.6.1810 (Core)Copy the code

4. If you want to be rich, build roads

Now the server is a small village with only a steel cable bridge, the first FTP run through, at least can send and receive server files

In the console security group first put the common port open 22,80,21,3306, etc.

[root@VM_0_4_centos ~]# systemctl status firewalld.service # check firewall information ● firewalld.service - firewalld-dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; Vendor preset: enabled) Active: Inactive (dead) # indicates that the default is turned off Docs: Man: firewalld (1)/root @ VM_0_4_centos ~ # RPM - qa | grep VSFTPD # check whether installed VSFTPD/root @ VM_0_4_centos ~ # yum - y install [root@VM_0_4_centos ~]# systemctl start VSFTPDCopy the code

The default FTP file is under /var/ftp. Now you can access and download the server file through a browser.

[root@VM_0_4_centos ~]# cd /var/ftp
[root@VM_0_4_centos ftp]# mkdir projects
[root@VM_0_4_centos ftp]# ls
projects  pub
Copy the code


Here you can use FileZilla to transfer files:

Elder brother is the supreme root Permission, what qualifications do you have denied me?

By default, VSFTPD does not expose FTP for root user. You can change this or create a new user.

Run the following command to restart vsftpd.service: vi /etc/vsftp/ftpusers root vi /etc/vsftp/user_listCopy the code

A song I really like the MV and also audio-visual material: ftp://175.24.44.231/projects/

In this way, the two ends of the road, file interoperability.


Chapter 2: Battle of the Sword (Java)

1. The best sword in the world -Java

Have a look, how can endure without Java, sword out of scabbard, call Java.

[root@VM_0_4_centos local]# java --version
-bash: java: command not found
Copy the code

--[· yum search JDK # search JDK ---->[result]-----/ / a little...
java-1.8. 0-openjdk.x86_64 : OpenJDK Runtime Environment
/ / a little...

---[·  yum install java-1.8. 0# install JDL --[· Java -version openJDK version"1.8.0 comes with _232"
OpenJDK Runtime Environment (build 1.8. 0 _232-b09)
OpenJDK 64-Bit Server VM (build 25.232-b09, mixed mode)
Copy the code

2. The most gorgeous aura of Java Sword –SpringBoot

Now run the SpringBoot project, first to demonstrate, see the SpringBoot series (has been placed in FTP, can download)

Upload the locally written project to the server via FTP and run it using java-JAR

[root@VM_0_4_centos ~]# cd ~
[root@VM_0_4_centos ~]# mkdir project
[root@VM_0_4_centos ~]# ls
project
Copy the code

The server is open and can now be accessed :http://175.24.44.231/

At this point, you can test the server to see if it’s working properly, that it’s connected, and that’s the foundation of everything


3. In the name of the universe – domain name

A domain name maps your server’S IP address to www.toly1994.com. What’s the big deal

Do not need domain name, to others throw an IP also can visit, but with the domain name + put on record is justified, we are good citizens.

It is easy to resolve the domain name and map it to a public IP address

So toly1994.com begins to wake up,

Small broken village for the server to repair the road, and built a small broken room, so far, domain name resolution OK.


4. Your life is protected by me – the firewall
Systemctl start firewald. service # Enable firewall systemctl stop firewald. service # disable firewall systemctl status firewald. service # Checking the Firewall StatusCopy the code

Once the firewall is enabled, access to toly1994.com will not find port 80, you need to open the firewall port

[root@VM_0_4_centos ~]# /sbin/iptables -l -n # Check ports opened by the firewall Chain INPUT (Policy ACCEPT) target prot opt source destination  Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destinationCopy the code
Firewall-cmd --permanent --add-port=80/ TCP # open port 80 firewall-cmd --reload # restart firewallCopy the code

When you need to open a port, just open it yourself. There’s a catch: the application dies when you close the command line

You can use sudo nohup Java -jar n_stack-0.0.1 -snapshot.jar to enable this function

The Java/SpringBoot army is assembled and ready to attack…


Chapter 3: Multimedia – Nginx/Streaming media Server

1. Create a folder
- [CD/usr/local / - [· mkdir nginx - [CD nginx /Copy the code

2. Download and decompress nginx and nginx-rtmp-module
Wget wget HTTP: / / https://nginx.org/download/nginx-1.16.1.tar.gz https://github.com/arut/nginx-rtmp-module/archive/v1.2.1.tar.gz - [· tar - XVF nginx - 1.16.1. Tar. Gz - [, tar - XVF v1.2.1. Tar. Gz - [, ls nginx - 1.16.1 nginx - 1.16.1. Tar. Gz # nginx-rtmp-module-1.2.1 v1.2.1.tar.gz # Nginx-rtmp-module-1.2.1 v1.2.1.tar.gz #Copy the code

3. The compiler nginx
/configure --with-http_ssl_module --add-module=../nginx-rtmp-module-1.2.1 make && /configure --with-http_ssl_module --add-module=../nginx-rtmp-module-1.2.1 make && Make install # install --[· CD.. --[· ls conf HTML logs nginx-1.16.1 nginx-rtmp-module-1.2.1 sbinCopy the code

4.[Modification of configuration]

Port 80 is already in use. You can change port 8080 in conf/nginx.conf

---[·  cd conf
---[·  ls
fastcgi.conf          fastcgi_params          koi-utf  mime.types          nginx.conf          scgi_params          uwsgi_params          win-utf
fastcgi.conf.default  fastcgi_params.default  koi-win  mime.types.default  nginx.conf.default  scgi_params.default  uwsgi_params.default

---[·  vim nginx.conf
Copy the code


5. Start the nginx

There’s nothing out of the console. Don’t panic. If there’s nothing wrong, it’s a success, okay

Note: Tencent cloud console security group and firewall need to open port 8080

- [CD/usr/local/nginx/sbin - [·. / nginx - [, ps - ef | grep nginx at 10:32 root 10043 1 0 # to check the problem? 00:00:00 nginx: master process ./nginx nobody 10044 10043 0 10:32 ? 00:00:00 nginx: worker process root 14035 30742 0 11:03 pts/2 00:00:00 grep --color=auto nginxCopy the code
CD /usr/local/nginx/sbin. /nginx -s stop Disable./nginx -s reload restartCopy the code

6. Stream your media

Remember there’s a video in FTP

--[· CD /var/ftp.projects --[· ls n_stack-0.0.1- snapshot.jar sh.mp4Copy the code
- [vim/usr/local/nginx/conf/nginx. Conf # # # # # # # # # # # # # # # # # # # # modified added with HTTP, the event at the # # # # # # # # # # # # # # # # # # # # RTMP {# RTMP service Application toly {play /var/ftp/projects/projects; // Application toly {play /var/ftp/projects/projects; # / / video folder}}} # # # # # # # # # # # # # # # # # # # # modified # # # # # # # # # # # # # # # # # # # # - [CD/usr/local/nginx/sbin - [· sudo. / nginx - s reload # to restartCopy the code

The following is the effect of local ffplay, which means OK.

So any video under projects can be played on demand, and as for FFmpeg live, pray that the King lives longer…..

ffplay rtmp://toly1994.com:8081/toly/sh.mp4 
Copy the code

Nginx army assembled, FFmpeg army on the way, ready to attack….


Chapter 4: The second sword in the world -MySQL

1. Prepare

Mysql > install mysql

RPM - qa | grep -i mysql # to check whether has the mysql # if RPM -e XXXXX -- nodeps remove CD/usr/local # choose a wget to download files https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.18-linux-glibc2.12-x86_64.tar.xz # download mysql tar XVF. - [root@VM_0_4_centos mysql]# mv mysql-8.0.18-linux-glibc2.12-x86_64.tar.xz # mv mysql-8.0.18-linux-glibc2.12-x86_64 Mysql # rename mysql [root@VM_0_4_centos mysql]# ls bin etc games include lib lib64 libexec mysql qcloud sbin share SRC yd.socket.serverCopy the code

Create mysql users and groups

Mysql > create mysql group useradd -r -g mysql mysql > create mysql group useradd -r -g mysql mysql Chown -r mysql:mysql./ # authorize all filesCopy the code

Initialized mysql

--[· mkdir data --[· bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --[· mkdir data --[· bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data ❌ bin/mysqld: error while loading shared libraries: libnuma.so.1: --[· yum -y install numactl --[· bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data [root@VM_0_4_centos mysql]# bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data 2019-12-05t09:11:42.077017z 0 [Warning] [my-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as 2019-12-05T09:11:42.077121z 0 [System] [my-013169] [Server] / usr/local/mysql/bin/mysqld (mysqld 8.0.18) initializing of server in progress as the process of 31048 2019-12-05T09:11:47.785216z 5 [Note] [my-010454] [Server] A temporary password is generated for root@localhost: 47<:0(pYQs>CCopy the code

⭐️ generates the default password :root@localhost: 47<:0(pYQs>C)


Expose data files only to mysql users

[root@VM_0_4_centos mysql]# chown -R root:root ./ [root@VM_0_4_centos mysql]# chown -R mysql:mysql data [root@VM_0_4_centos mysql]# ll total 552 drwxr-xr-x 2 root root 4096 Sep 20 20:57 bin drwxr-xr-x 6 mysql mysql 4096 Dec 5 17:11 data drwxr-xr-x 2 root root 4096 Sep 20 20:57 docs drwxr-xr-x 3 root root 4096 Sep 20 20:57 include drwxr-xr-x 7 Root root 4096 Sep 20 20:57 lib-rw-r --r-- 1 root root 408918 Sep 20 16:30 LICENSECopy the code

2. The mysql configuration file is related

Configure the mysql

[root@VM_0_4_centos mysql]# cd support-files/ [root@VM_0_4_centos support-files]# ls mysqld_multi.server mysql-log-rotate mysql.server [root@VM_0_4_centos support-files]# touch my-default.cnf [root@VM_0_4_centos support-files]# chmod 777 ./my-default.cnf [root@VM_0_4_centos support-files]# cd .. / [root@VM_0_4_centos mysql]# cp support-files/my-default.cnf /etc/my.cnfCopy the code

Modify the configuration file vim /etc/my.cnf as required

Sock file path socket = / TMP /mysql/mysql.sock default-character-set=utf8 [mysqld] # Maximum number of connections to mysql max_connections=2000 datadir=/wocloud/mysql/data basedir = /usr/local/mysql datadir = /usr/local/mysql/data socket = / TMP/mysql/mysql. The sock log - error = / usr/local/mysql/data/error log pid - file = / usr/local/mysql/data/mysql pid # password is valid, Default_password_lifetime =0 # Speed up source data import innodb_flush_log_at_trx_commit=0 max_ALLOwed_packet =100M user=mysql / TMP /mysql/TMP/mysql. symbolic-links=0 character-set-server=utf8 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES [mysql] no-auto-rehash default-character-set=utf8 [mysqld_safe] default-character-set = utf8 [mysql.server] default-character-set = utf8Copy the code

Boot from the

[root@VM_0_4_centos mysql]# cd support-files/
[root@VM_0_4_centos support-files]# cp mysql.server /etc/init.d/mysql 
[root@VM_0_4_centos support-files]# chmod +x /etc/init.d/mysql
[root@VM_0_4_centos support-files]# chkconfig mysql on 
Copy the code

Enable/disable the service

service mysql start 
service mysql stop
Copy the code

Add the environment variable vim ~/.bash_profile:

#MYSQL ENVIRONMENT
export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib
Copy the code

Source ~/. Bash_profile. You can run the $PATH command to check whether the configuration succeeds.


– Maybe you are curious to write the my.cnf configuration in etc

Mysql defaults to my.cnf:

[root@VM_0_4_centos mysql]# mysql --verbose --help | grep my.cnf
                      order of preference, my.cnf, $MYSQL_TCP_PORT,
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf 
Copy the code

3. Log in to the mysql database and change the password

Use the random password above to log in and then change the password.

[root@VM_0_4_centos mysql]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 8.0.18 Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help; ' or '\h' for help. Type '\c' to clear the current input statement. mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH  mysql_native_password BY 'ooxxooxxooxx'; Mysql > SHOW DATABASES; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | + -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + 4 rows in the set (0.00 SEC) Grant all privileges on *. * to 'root' @ '%' identified by 'toly1994' with grant option; GRANT ALL PRIVILEGES ON . TO 'root'@'%' IDENTIFIED BY 'toly1994' WITH GRANT OPTION; GRANT ALL ON *.* TO 'root'@'%';Copy the code

The MySQL army is assembled and ready to attack…


Chapter 5: Two Swords -NodeJS + Python

1. The node and the environment
CD/usr/local wget tar XVF - https://npm.taobao.org/mirrors/node/v12.13.1/node-v12.13.1-linux-x64.tar.xz The node - v12.13.1 - Linux - x64. Tar. Xz mv node - v12.13.1 - Linux - x64 nodejs ln -s/usr/local/nodejs/bin/node/usr/sbin/node ln -s / usr/local/nodejs/bin/NPM/usr/sbin/NPM v12.13.1 [· node - v - [, NPM -v 6.12.1Copy the code

Node is filled, front army ready to attack…


2. The Python environment

Python 2.7.5 and Python 3

To compile PIp3, we need to install a few things, otherwise the compiler will not generate PIp3:

yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel
Copy the code
- [, python -v python 2.7.5 - [CD/usr/local/wget tar at https://www.python.org/ftp/python/3.7.5/Python-3.7.5.tar.xz /configure --prefix=/usr/local/python3 # configure make && make install #Copy the code

Check to see if PYTHon3 and PIp3 are generated

--[· CD /usr/local/python3/bin --[· ls 2to3 2to3-3.7 easy_install-3.7 idle3 idle3.7 pip3 pip3.7 pyDoc3 pyDoc3.7 Python3 pythON3.7 python3.7-config python3.7m python3.7m-config python3-config pyvenv pyvenv-3.7Copy the code

Establishing a soft connection

Ln -s/usr/local/python3 / bin/python3 / usr/sbin/python3 ln -s/usr/local/python3 / bin/pip3 / usr/sbin/pip3 - [python3 - V Python 3.8.0 [· pip3 - V PIP 19.2.3 from/usr/local/python3 / lib/python3.7 / site - packages/PIP (Python 3.7)Copy the code

Python is assembled and ready to attack…


Appendix: Operating system

If you accidentally choose a lower version, or want to switch from a Windows server to Linux, it takes 10 seconds


The end of the

For the record, I’m not advertising Tencent cloud, just using it. You can use any virtual server

Even the Linux virtual machine on the computer can also simulate play, through the LAN can access if there is a public IP, can make their own computer into a high-performance server….

Now I announce :Light project officially opened – December 5, 2019.

@ZhangFengjietele 2019.12.05 not allowed to transfer

My official number: King of programming contact me – email :[email protected] – wechat :1994328zdl ~ END ~