CentOs7 system Typical applications - the basic building services systems

CentOs7 basic system building LAMP / LNMP;

First, the preparatory work:

  1. ip addr 
  2. vi  /etc/sysconfig/network-scripts/ifcfg-enp0s3 设置onroot=yes
  3. service network restart restart
  4. yum install net-tools net-tools download tool you can use commands such as ifconfig
  5. Set the bridge card (get public IP, ssh remote connection), restart the virtual machine
  6. Alternatively default source   http://mirrors.163.com/.help/centos.html (in accordance with the address instructions)
  7. Install vim: yum install vim

Two, ssh tools:

  1. Ssh server installation services
    1. 安装SSH: yum install openssh-server
    2. Start SSH: service sshd start
    3. Setting a power run: chkconfig sshd on (the server version the default setting)
    4. The client install ssh client
      1. Linux platforms: (already installed automatically when you install openssh-server) yum install openssh-clients
    5. Ssh client connect to the server
      1. ssh [email protected]
    6. Ssh config Detailed Usage
      1. Config File Location: ~ / .ssh / config.
      2. Content Settings way:

          host "root"

              HostName 192.168.1.100

              User root

                      Port 22

  1. Free ssh key password scheme of
    1. Linux platform to generate ssh key: ssh-keygen -t rsa
    2. Linux platform: ssh-add ~ / .ssh / XX_rsa (Load key)
    3. ~ / .Ssh / authoried_keys generated files into the server's key
    4. Ssh Port Security: Modify / etc / ssh / sshd_config configuration

 

Third, the package manager: yum

  1. Installation: yum install XX
  2. Uninstall: yum remove XX
  3. Search: yum search XX
  4. Clean the cache: yum clean packages
  5. Lists installed: yum list
  6. Package information: yum info XX

 

Fourth, the server hardware resource information:

1. Memory: free -m

2. Hard disk: df -h

3. Load: w / top

 

Five, Linux file directory structure:

  1. Root directory:/
  2. Configuration directory: / etc
  3. Home directory: / home
  4. User program directory: / usr
  5. Temporary directory: / tmp

Sixth, the file command:

  1. tail: start reading from the end of the file
  2. head: read from the file header
  3. cat: read the entire file
  4. more: page read
  5. less: a controlled pagination
  6. grep: search keywords
  7. find: Find Files
  8. wc: counting the number
  9. echo to create a file with the content,
  10. Create an empty file touch
  11. cp copy
  12. mv move or rename
  13. rm delete files
  14. Create a directory mkdir
  15. rmdir remove directory
  16. pwd displays the current directory path
  17. create links in files

Seven, unzip command:

         taking:  

                   -c archive

                   Unzip the file -x

                   -z gzip / tar.gz compressed file

                   -j bzipz compressed files

                   -v display compression or decompression process

                   -f Use filename

                   -t display content in the compressed file

Eight, the user operates the system command :

  1. useradd: Add User
  2. adduser: add users
  3. userdel: Delete User
  4. passwd: password

Nine, firewall settings:

  1. Installation: yum install firewalld
  2. Start: service firewalld start
  3. Check the status: service firewalld status
  4. Turn off or disable the firewall: service firewalld stop / disable
  5. Firewall rule set: 80/22 open port, firewall-cmd --add-port = 22 / tcp;
  6. Open a query firewall services: firewall-cmd --query-service = ** (service name)
  7. Turn off the firewall open a service: firewall-cmd --remove-service = ** (service name)
  8. Add a firewall service: firewall-cmd -add-service = ssh (service name)
  9. Permanently open port or service parameters: - permanent

Ten, put right, and file upload and download operations:

  1. Mention the right: sudo operations, methods: visudo user settings are loaded into the file:

 

  1. Download: wget, curl
  2. File upload (linux):

A) scp zgx.txt [email protected]: / tmp /  can be uploaded to tmp directory

b) scp   [email protected]: /tmp/zgx.txt  path to download the file to the current system

  1. xshell (windows) Upload: sudo yum install lrzsz use sz rz upload and download commands after installation

a) sudo yum install lrzsz install windows and linux file upload and download commands

b) rz: perform file upload

c) sz zgx.txt: executable file download command

 

 

Eleven, Apache basic operations:

1. Installation: yum install httpd

2. Start: service httpd start

3. Close: service httpd stop

Eleven, Nginx basic operations:

  1. Installation: yum install nginx (no default nginx, a need for operation)

    a) add CentOS 7 Nginx yum repository command: sudo RPM -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

    b) Sudo yum install -y nginx to install

  1. Start: service nginx start
  2. Close: service nginx stop
  3. Overload: service nginx reload

Twelve, reverse proxy and load balancing:

        

 

 

 

Thirteen, Mysql basic operations: Account: root password: zgx_mysql

  1. Installation server: yum install mysql-community-server

    a) yum remove mariadb-libs.x86_64 (centos7 MariaDB database default installation) removed

    b) download mysql Source: https://dev.mysql.com/downloads/repo/yum/ address location

    c) the installation source: yum localinstall mysql57-community-release-el7-8.noarch.rpm

    d) install mysql service

    e) default password: cat /var/log/mysqld.log | grep "password"

    f) set the password: ALTER USER 'root' @ 'localhost' IDENTIFIED BY 'your password';

  1. Start: service mysqld start / restart
  2. Close: service mysqld stop
  3. Remote Connection:

    a)       show databases;

    b)       use mysql;

    c)       show tables;

    d) update user set host = '%' where host = 'localhost' and user = 'root'; l (to allow access to all hosts)

    e) sudo service mysqld restart; (service restart, refresh permission)

  1. Open Genelog (record CRUD sql statements) execution trace data:

    a) set global general_log_file = '/ tmp / general.log'; (set save path general log)

    b) set global general_log = on; (open general log mode)

  1. New user and privileged operations:

    a) create a user: CREATE USER 'root' @ '%' IDENTIFIED BY '123456';

    b) given all privileges: grant all privileges on * * to 'root' @ '%' indentified by '123456' with grant option; (* * for all the tables in all databases, all privileges:.. All rights)

    c) Individual rights: grant select, insert on * * to 'root' @ '%' indentified by '123456' with grant option;.

    d) resume database;

    e) to recover the permissions: revoke all privileges on * * from root;.

  1. Forget the root password rescue:

    a) adding a skip-grant-tables in /etc/my.cnf skip password authentication;

    b)       use mysql;

    c)       update user set authentication_string=password(‘123456’) where user=’root’;

 

XIV caching service (Redis / memcached ):

         Memcached basic operations:

    a)       安装: yum install memcached

    b) Start: memcached -d -l -m -p

    c) Stop: kill pid;

Redis basic operations:

  a) source compiler installation;

    1) Get the source: wget http://download.redis.io/releases/redis-5.0.4.tar.gz

    2) Extract: tar xvzf redis-5.0.4.tar.gz

    3)  安装: yum install gcc ; make MALLOC=libc ; sudo make install。

    4) enter to start the service directory: cd src; ls; (see Service)

  b) to start the service: ./ redis-server;

  c) client starts: ./redis-client;

Reids expand knowledge:

  a) simultaneous Redis support belongings k / v types of data. Also provided list, set, hash and other data storage structure;

  Data backup b) Redis data backup support, i.e., master-slave mode,

  c) Redis supports data persistence, data in memory can be saved to disk;

 

Fifteen, GIT:

  1. Git installed: yum install git
  2. Git command auto-completion feature set
  3. ~/.ssh中生成 ssh key:ssh-keygen;
  4. Git常用命令:git config;  git init;  git clone;  git remote;  git fetch;  git commit;  git rebase;  git push;

Sixteen, PHP service:

  1. The default version 5.4 to version 7.2 upgrade is too low:

    a) Check the currently installed php package: yum list installed | grep php

    b) If you have installed php packages, first remove the following: yum remove php.x86_64 php-cli.x86_64 php-common.x86_64 php-gd.x86_64 php-ldap.x86_64 php-mbstring.x86_64 php-mcrypt.x86_64 php- mysql.x86_64 php-pdo.x86_64

  1. Configuration Source:

    a) Sudo rpm Uvh http://mirror.webtatic.com/yum/el7/epel-release.rpm

    b) Sudo rpm Uvh http://mirror.webtatic.com/yum/el7/webtatic-release.rpm

    c) If you want to remove the installation of the above packages, reinstall:

      rpm -qa | grip webtatic; 

      rpm -e above can be searched for a packet;

  Installation and operation of the basic 2.fpm

    a) installation: yum install php72w-fpm (may php70w-fpm)

    b) Basic operation: service php-fpm start / restart / stop

  3.安装php扩展:yum install  php72w.x86_64  php72w-cli.x86_64  php72w-common.x86_64 php72w-gd.x86_64  php72w-mbstring.x86_64 php72w-mcrypt.x86_64  php72w-mysql.x86_64  php72w-pdo.x86_64 php72w-bcmath.x86_64  php72w-devel.x86_64  php72w-ldap.x86_64  php72w-odbc.x86_64  php72w-pecl-memcached.x86_64 php72w-pecl-redis.x86_64  php72w-mongodb.x86_64  php72w-pecl-xdebug.x86_64      php72w-opcache.x86_64

  1. Nginx environment configuration:

 

 

Seventeen, Linux commonly used services:

  1. crontab: crontab -e regular tasks
  2. Ntpdate: Date synchronization ntpdate cn.pool.ntp.org
  3. Time zone settings:

    a) delete the default Americas: Sudo rm / etc / localtime

    b) set the default time zone Shanghai: ln -s / usr / share / zoneinfo / Asia / Shanghai / etc / localtime

  1. Logrotate: log cutting
  2. Supervisor: Process Management

    a)       安装:sudo pip install supervisor

    b)       新建配置目录:sudo mkdir /etc/supervisor

    c)       生成配置文件:echo_supervisord_conf > /etc/supervisor/supervisor.conf

         6.监控系统Zabbix

        

Guess you like

Origin www.cnblogs.com/zgxblog/p/10962561.html