shallow丿ove
LNMP架构介绍
- 和LAMP不同的是,提供web服务的是Nginx
- 并且php是作为一个独立服务存在的,这个服务叫做php-fpm
- Nginx直接处理静态请求,动态请求会转发给php-fpm
安装mysql
删除mysql
[root@localhost ~]# ps aux | grep mysql
root 3059 0.0 0.0 112660 976 pts/0 S+ 08:41 0:00 grep --color=auto mysql
[root@localhost ~]# rm -rf /usr/local/mysql/
[root@localhost ~]# rm -rf /etc/init.d/mysql
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# ls
apr-1.6.3 httpd-2.2.34 mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz php-7.1.6
apr-1.6.3.tar.gz httpd-2.2.34.tar.gz mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz php-7.1.6.tar
apr-util-1.6.1 httpd-2.4.29 php-5.6.30 phpredis-develop
apr-util-1.6.1.tar httpd-2.4.29.tar.gz php-5.6.30.tar
[root@localhost src]# tar zxvf mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz
#拆包解压过程
.
.
.
[root@localhost src]# mv mysql-5.6.36-linux-glibc2.5-x86_64 /usr/local/mysql
[root@localhost src]# ls /usr/local/mysql/
bin COPYING data docs include lib man mysql-test README scripts share sql-bench support-files
[root@localhost mysql]# ls /data/
mariadb mysql wwwroot
[root@localhost mysql]# id mysql
uid=1006(mysql) gid=1009(mysql) groups=1009(mysql)
[root@localhost mysql]# rm -rf /data/mysql/*
[root@localhost mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
#
[root@localhost mysql]# echo $?
0
编辑配置文件
[root@localhost mysql]# vi /etc/my.cnf
1 [mysqld]
2 datadir=/data/mysql
3 socket=/tmp/mysql.sock
4 # Disabling symbolic-links is recommended to prevent assorted security risks
5 symbolic-links=0
6 # Settings user and group are ignored when systemd is used.
7 # If you need to run mysqld under a different user or group,
8 # customize your systemd unit file for mariadb according to the
9 # instructions in http://fedoraproject.org/wiki/Systemd
10
11 [mysqld_safe]
12 #log-error=/var/log/mariadb/mariadb.log
13 #pid-file=/var/run/mariadb/mariadb.pid
14
15 #
16 # include all files from the config directory
17 #
18 #!includedir /etc/my.cnf.d
19
只需指定datadir和socket
拷贝启动脚本
[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld
编辑启动脚本
[root@localhost mysql]# vi /etc/init.d/mysqld
35 # - Add the above to any other configuration file (for example ~/.my.ini)
36 # and copy my_print_defaults to /usr/bin
37 # - Add the path to the mysql-installation-directory to the basedir variable
38 # below.
39 #
40 # If you want to affect other MySQL variables, you should make your changes
41 # in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files.
42
43 # If you change base dir, you must also change datadir. These may get
44 # overwritten by settings in the MySQL configuration files.
45
46 basedir=/usr/local/mysql
47 datadir=/data/mysql
48
49 # Default value, in seconds, afterwhich the script should timeout waiting
50 # for server start.
51 # Value here is overriden by value in my.cnf.
52 # 0 means don't wait at all
53 # Negative numbers mean to wait indefinitely
54 service_startup_timeout=900
55
56 # Lock directory for RedHat / SuSE.
57 lockdir='/var/lock/subsys'
58 lock_file_path="$lockdir/mysql"
其中只需改动basedir和datadir
启动mysql
[root@localhost mysql]# /etc/init.d/mysqld start
Starting MySQL.Logging to '/data/mysql/localhost.localdomain.err'.
SUCCESS!
[root@localhost mysql]# ps aux | grep mysql
root 3372 0.0 0.0 113264 1612 pts/0 S 09:04 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysq --pid-file=/data/mysql/localhost.localdomain.pid
mysql 3509 2.1 24.2 1300784 453088 pts/0 Sl 09:04 0:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/localhost.localdomain.err --pid-file=/data/mysql/localhost.localdomain.pid --socket=/tmp/mysql.sock
root 3535 0.0 0.0 112660 976 pts/0 S+ 09:04 0:00 grep --color=auto mysql
将服务添加到服务列表当中,并且开机启动
[root@localhost mysql]# chkconfig --add mysqld
[root@localhost mysql]# chkconfig on