linux +Nginx +mysql/mariadb +PHPphp
是一個web服務器,提供HTTP服務的css
是一個關係型數據庫,是用來存數據的( 用戶名、密碼、文章、內容)mysql
是一個編程語言,經常使用來作網站linux
用戶先會先訪問Nginx (靜態請求 ,會處理圖片,JS,CSS,接收php的請求,可是不處理)把php的請求轉發到後面的php-fpmweb
php-fpm 會處理php相關的請求(叫作動態的請求)sql
靜態: 指的是Nginx能夠直接處理圖片、js、css 視頻、音頻、flash等等數據庫
動態: 指的是這些請求須要和數據庫打交道,好比 ,用戶登錄過程,好比查看一篇文章,或者寫一篇文章編程
MariaDB是MySQL的一個分支。 MySQL -- SUN --- Oraclevim
官網 https://mariadb.org服務器
[root@localhost src]# wget https://downloads.mariadb.org/interstitial/mariadb-10.3.11/bintar-linux-x86_64/mariadb-10.3.11-linux-x86_64.tar.gz
[root@localhost src]# tar zxvf mariadb-10.3.11-linux-x86_64.tar.gz
tar zxvf XXX.tar.gz z:針對gz壓縮 tar jxvf XXX.tar.bz2 j:針對bz2壓縮 tar Jxvf XXX.tar.xz J:針對xz壓縮
tar zcvf XXX.tar.gz XXX/ tar jcvf XXX.tar.bz2 XXX/ tar Jcvf XXX.tar.xz XXX/
[root@localhost src]# mv mariadb-10.3.11-linux-x86_64 /usr/local/mysql
[root@localhost mysql]# mkdir -p /data/mysql [root@localhost mysql]# useradd -M -s /sbin/nologin mysql [root@localhost mysql]# grep mysql /etc/passwd mysql:x:1000:1000::/home/mysql:/sbin/nologin [root@localhost mysql]# chown -R mysql:mysql /data/mysql
[root@localhost mysql]# ./scripts/mysql_install_db --datadir=/data/mysql --usr=mysql
[root@localhost mysql]# echo $? 0
[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[root@localhost mysql]# vim /etc/init.d/mysqld basedir=/usr/local/mysql datadir=/data/mysql
[root@localhost mysql]# /etc/init.d/mysqld start
chkconfig --list rhel6 systemctl list-unit-files rhel7
/etc/init.d/下有mysqld 而且權限是755
[root@localhost init.d]# pwd /etc/init.d [root@localhost init.d]# ll |grep mys -rwxr-xr-x. 1 root root 12193 Jan 24 00:39 mysqld [root@localhost mysql]# chkconfig --add mysqld
chkconfig mysqld off chkconfig mysqld on
# 25. Mariadb安裝(下) ## 修改配置文件my.cnf
[root@localhost init.d]# vim /etc/my.cnf
datadir=/data/mysql socket=/tmp/mysql.sock log-error=/data/mysql/mariadb.log pid-file=/data/mysql/mariadb.pid
## 啓動服務
[root@localhost mysql]# service mysqld start Starting mysqld (via systemctl): [ OK ]
## 查看是否啓動成功
[root@localhost mysql]# netstat -lnp |grep 3306 tcp6 0 0 :::3306 :::* LISTEN 5822/mysqld [root@localhost mysql]# netstat -lnp |grep 3306 tcp6 0 0 :::3306 :::* LISTEN 5822/mysqld
[root@localhost mysql]# ls -l /tmp/mysql.sock srwxrwxrwx. 1 mysql mysql 0 Jan 24 01:32 /tmp/mysql.sock
## 鏈接
[root@localhost mysql]# /usr/local/mysql/bin/mysql -uroot Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 9 Server version: 10.3.11-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
##
[root@localhost mysql]# ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
## 系統環境變量 (不建議用)
[root@localhost mysql]# echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[root@localhost mysql]# PATH=$PATH:/usr/local/mysql/bin [root@localhost mysql]# echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/mysql/bin [root@localhost mysql]#echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile source /etc/profile
## 設置密碼
[root@localhost mysql]# mysqladmin -uroot password "123"
## 登錄
[root@localhost mysql]# mysql -uroot -p123 Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 14 Server version: 10.3.11-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]>
[root@localhost mysql]# mysql -uroot -p123 -S/tmp/mysql.sock Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 15 Server version: 10.3.11-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
[root@localhost mysql]# mysql -uroot -p123 -h192.168.222.128 -P3306