Ubuntu deployment record

Time:2021-12-5

For Ubuntu 16.04

Apt get source switching

System settings
->Software and updates
->Download from
->Select Chinese
->mirrors.aliyun.com/ubuntu

Selecting a domestic source and then updating the language library and other update operations will be faster!

Convert to Chinese and add Chinese input method

System settings
->Language support
->[the new system will prompt that the language support needs to be updated first]
->Add or remove languages
->Select China (Simplified) or [Chinese Simplified]
->Apply to the whole system
->Keyboard input method system selection fcitx
->Restart complete

command line

process

#Means to view the process information in which CMD is Java in all processes, - aux displays all States, and grep is search
ps -aux | grep java

#Kill process
kill [pid]
killall [name]
## example
killall nginx

#Add new directory
mkdir

#Delete all files in the directory
rm -R [dir] 

#Create file
touch [filename]

#Current path
pwd

#Use root privileges
sudo

#Switch users
su [user]

#View user groups
groups 

#Add user groups and user permissions
sudo groupadd -g 315 mysql  
sudo useradd -u 315 -g mysql -d /var/lib/mysql -M mysql

#Download a file with the same name
curl -O https://raw.github.com/emmetio/pyv8-binaries/master/pyv8-linux64-p3.zip
#Download and name the file
curl -o newname.zip https://raw.github.com/emmetio/pyv8-binaries/master/pyv8-linux64-p3.zip

#This command is to make all. JPG files into a tar package and compress them with gzip to generate a gzip compressed package named all.tar.gz 
tar -czf all.tar.gz *.jpg 
 
#This command unlocks the package generated above.
tar -xzf all.tar.gz

Solve the problem of running shell\rProblem, the document edited under win will contain\r
In fact, it installs two tools: todos (equivalent to UNIX 2 dos) and fromdos (equivalent to DOS 2 Unix)
After installation, you can now convert the text format.

sudo apt-get install tofrodos 

Installing proxychains

For agents, type before the command line you want to useproxychainsthat will do

# install 
sudo apt-get proxychains
# use 
proxychains curl http://uxfeel.com

Install Mongo

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
#Ubuntu 16.04
echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
sudo apt-get update
sudo apt-get install -y mongodb-org

Add service
(Ubuntu 16.04-only) Create systemd service file
Create a new file at /lib/systemd/system/mongod.service with the following contents:

[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target
Documentation=https://docs.mongodb.org/manual

[Service]
User=mongodb
Group=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf

[Install]
WantedBy=multi-user.target

Allows Mongo to connect remotely

View IP usage

$ sudo netstat -nputl

Modify mongodb.conf

$ vi /etc/mongodb.conf

Configure the following

bind_ip: 127.0.0.1
port: 27017

Change to

bind_ip: 0.0.0.0
port: 27017
auth: true

Restart Mongo

$ sudo service mongodb restart
$ sudo service mongodb status

Startup and shutdown of mongodb
https://docs.mongodb.com/mast…

Add administrative permissions

by mongoDB 3.0
Add administrator

$ mongo
> use admin
> db.createUser(
  {
    user: "buru",
    pwd: "12345678",
    roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
  }
)

View user

> show users

Modify service, add--authParameter allows Mongo to start with permission management

# /lib/systemd/system/mongod.service
ExecStart=/usr/bin/mongod --quiet --auth --config /etc/mongod.conf

Restart Mongo

$ sudo service mongodb restart
$ sudo service mongodb status

http://ibruce.info/2015/03/03…

Installing nginx

create a file/etc/apt/sources.list.d/nginx.listAnd type

deb http://nginx.org/packages/ubuntu/ xenial nginx
deb-src http://nginx.org/packages/ubuntu/ xenial nginx

Update and install nginx

sudo apt-get update
sudo apt-get install nginx

If promptedW: GPG error: http://nginx.org/packages/ubuntu xenial Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY $key
You need to run the following code ($key is mentioned in the error prompt)

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys $key
sudo apt-get update
sudo apt-get install nginx

The scene and necessity of building a layer of nginx in front of nodejs

When port 80 has been occupied by nginx and there are multiple websites and services on the server, it is still necessary to use nginx

Edit nginx configuration

# vi /etc/nginx/nginx.conf

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;


    server {
        listen       80;
        server_name  uxfeel.com www.uxfeel.com;

        location / {
            proxy_pass   http://localhost:8080;
        }
    }

}

View nginx status

$ systemctl status nginx.service

start nginx

$ systemctl start nginx.service

Reverse proxy WebSockets

http {

    //... omitted

    map $http_upgrade $connection_upgrade {
        default upgrade;
        ''      close;
    }

    server {

        listen       3102;  # Monitor 3102 
        server_name localhost;

        location / {
            proxy_ pass  http://localhost:3100 # Agent 3100 

            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
    }

    //... omitted
}

Install PHP

Add source using PPA:
$ sudo apt-get install python-software-properties
$ sudo add-apt-repository ppa:ondrej/php
$ sudo apt-get update
$ sudo apt-get install -y php7.0 php7.0-mysql php7.0-curl php7.0-json php7.0-cgi

You can then view the PHP version:
php -v

About php5.4 -- php5.6
$ sudo apt-get install python-software-properties
$ sudo add-apt-repository ppa:ondrej/php
$ sudo apt-get update
$ sudo apt-get -y install php5.6 php5.6-mcrypt php5.6-mbstring php5.6-curl php5.6-cli php5.6-mysql php5.6-gd php5.6-intl php5.6-xsl php5.6-zip

Install MySQL

$ sudo apt-get install mysql-server

When nothing is filled in, including root password setting, the default user and password will be generated in the following file

$ cat /etc/mysql/debian.cnf

Install NVM

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.29.0/install.sh | bash
#Reopen terminal
#View online node version
nvm ls-remote
#Install node
nvm install v6.11.0
#Set as default
nvm alias default v6.11.0
#Show local version
nvm ls
#Use other versions if you remember to install them
nvm install v4.4.4
nvm use v4.4.4

NVM acceleration

NVM defaults to fromhttp://nodejs.org/dist/Download, foreign servers, must be very slow,

Fortunately, NVM supports downloading packages from the image server, so we can easily download them from the node dist image of Taobao:

$ NVM_NODEJS_ORG_MIRROR=https://npm.taobao.org/mirrors/node nvm install 0.12.7
#Then you will see a very fast progress bar:
######################################################################## 100.0%
Now using node v0.12.7

If you don’t want to enter the environment variable NVM every time_ NODEJS_ ORG_ Mirror, then I suggest you add it to the. Bashrc file:

# nvm
export NVM_NODEJS_ORG_MIRROR=https://npm.taobao.org/mirrors/node
source ~/git/nvm/nvm.sh

Install chrome stable

wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
sudo apt-get update
sudo apt-get install google-chrome-stable

Summary of tar.gz, tar, bz2, zip and other decompression and compression commands under Linux
Quickly build node.js development environment and accelerate NPM
Nginx reverse proxy websocket
Nginx configuration location summary and rewrite rule writing method
nginx proxy_ The difference between adding / and not adding / to the URL after pass
Absolutely detailed! Nginx basic configuration and performance optimization guide
Nginx configuration of nodejs blog
(to) the nginx reverse proxy setting changes from port 80 to other ports
Nginx configuring upstream for load balancing

Build hexo blog

Hexo server
How do I configure pm2 to run hexo?

Problems encountered’s

NPM installed global commands are not available

The reason is that the path of node is not added to the system variable

//Get node path
$ npm config get prefix
$ vim /etc/profile
//At the end of the document, add:
export PATH="/opt/STM/STLinux-2.3/devkit/sh4/bin:$PATH"
//Save, exit, and then run:
$ source /etc/profile

http://www.520bu.com/index.ph…

Mongod cannot start using service

Ubuntu deployment record
sudo service mongod startCannot take effect effectively. The problem may be the folder/var/log/mongodband/var/lib/mongodbNot setmongodb:mongodbUser group permissions
Just set the estimation

cd /var/log/mongodb
sudo chown -R mongodb:mongodb .
cd /var/lib/mongodb
sudo chown -R mongodb:mongodb .

http://stackoverflow.com/ques…

Recommended Today

The real problem of Alibaba IOS algorithm can’t hang up this time

More and more IOS developers continue to enter the peak of job hopping in 2020 Three main trends of interview in 2020: IOS bottom layer, algorithm, data structure and audio and video development Occupied the main battlefield. Data structure and algorithm interview, especially figure, has become the main reason for the failure of most first-line […]