CentOs7 basic system building LAMP / LNMP;
First, the preparatory work:
- ip addr
- vi /etc/sysconfig/network-scripts/ifcfg-enp0s3 设置onroot=yes
- service network restart restart
- yum install net-tools net-tools download tool you can use commands such as ifconfig
- Set the bridge card (get public IP, ssh remote connection), restart the virtual machine
- Alternatively default source http://mirrors.163.com/.help/centos.html (in accordance with the address instructions)
- Install vim: yum install vim
Two, ssh tools:
- Ssh server installation services
- 安装SSH: yum install openssh-server
- Start SSH: service sshd start
- Setting a power run: chkconfig sshd on (the server version the default setting)
- The client install ssh client
- Linux platforms: (already installed automatically when you install openssh-server) yum install openssh-clients
- Ssh client connect to the server
- Ssh config Detailed Usage
- Config File Location: ~ / .ssh / config.
- Content Settings way:
host "root"
HostName 192.168.1.100
User root
Port 22
- Free ssh key password scheme of
- Linux platform to generate ssh key: ssh-keygen -t rsa
- Linux platform: ssh-add ~ / .ssh / XX_rsa (Load key)
- ~ / .Ssh / authoried_keys generated files into the server's key
- Ssh Port Security: Modify / etc / ssh / sshd_config configuration
Third, the package manager: yum
- Installation: yum install XX
- Uninstall: yum remove XX
- Search: yum search XX
- Clean the cache: yum clean packages
- Lists installed: yum list
- 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:
- Root directory:/
- Configuration directory: / etc
- Home directory: / home
- User program directory: / usr
- Temporary directory: / tmp
Sixth, the file command:
- tail: start reading from the end of the file
- head: read from the file header
- cat: read the entire file
- more: page read
- less: a controlled pagination
- grep: search keywords
- find: Find Files
- wc: counting the number
- echo to create a file with the content,
- Create an empty file touch
- cp copy
- mv move or rename
- rm delete files
- Create a directory mkdir
- rmdir remove directory
- pwd displays the current directory path
- 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 :
- useradd: Add User
- adduser: add users
- userdel: Delete User
- passwd: password
Nine, firewall settings:
- Installation: yum install firewalld
- Start: service firewalld start
- Check the status: service firewalld status
- Turn off or disable the firewall: service firewalld stop / disable
- Firewall rule set: 80/22 open port, firewall-cmd --add-port = 22 / tcp;
- Open a query firewall services: firewall-cmd --query-service = ** (service name)
- Turn off the firewall open a service: firewall-cmd --remove-service = ** (service name)
- Add a firewall service: firewall-cmd -add-service = ssh (service name)
- Permanently open port or service parameters: - permanent
Ten, put right, and file upload and download operations:
- Mention the right: sudo operations, methods: visudo user settings are loaded into the file:
- Download: wget, curl
- 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
- 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:
- 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
- Start: service nginx start
- Close: service nginx stop
- Overload: service nginx reload
Twelve, reverse proxy and load balancing:
Thirteen, Mysql basic operations: Account: root password: zgx_mysql
- 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';
- Start: service mysqld start / restart
- Close: service mysqld stop
- 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)
- 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)
- 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;.
- 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:
- Git installed: yum install git
- Git command auto-completion feature set
- ~/.ssh中生成 ssh key:ssh-keygen;
- Git常用命令:git config; git init; git clone; git remote; git fetch; git commit; git rebase; git push;
Sixteen, PHP service:
- 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
- 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
- Nginx environment configuration:
Seventeen, Linux commonly used services:
- crontab: crontab -e regular tasks
- Ntpdate: Date synchronization ntpdate cn.pool.ntp.org
- 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
- Logrotate: log cutting
- Supervisor: Process Management
a) 安装:sudo pip install supervisor
b) 新建配置目录:sudo mkdir /etc/supervisor
c) 生成配置文件:echo_supervisord_conf > /etc/supervisor/supervisor.conf
6.监控系统Zabbix