一.搭建LNMP基本架构
1.L(http) N(nginx) M(mysql) P(php)
2.安装顺序 Mysql-->PHP-->Nginx
3.安装包
Discuz_3.2.0_SC_GBK
nginx-1.4.4 httpd-2.4.27 php-5.3.22
mysql-5.6.38-linux-glibc2.12-i686
4.安装mysql数据库
(1)解压mysql压缩包
tar zxvf mysql.tar.gz
(2)将mysql目录移动/usr/下。
mv mysql目录 /usr/local/mysql
(3)在mysql目录下,创建目录,作为datadir(数据目录)
mkdir /data/mysql
(4)创建mysql用户,不允许登陆,不创建家目录。
useradd -s /sbin/nologin -M mysql
(5)将/data/mysql/目录所属组所属主给mysql用户。
chown -R mysql:mysql /data/mysql/
(6)将配置文件存放到/etc/my.conf覆盖。
cp /mysql目录/support-files/my-large.cnf /etc/my.cnf
(7)修改配置文件
vim进入/etc/my.conf
# For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the # *** default location during install, and will be replaced if you # *** upgrade to a newer version of MySQL. [mysqld] port = 3306 socket = /usr/local/mysql/mysql.sock datadir = /data/mysql pid-file = /data/mysql/mysql.pid # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M ------------------------------------------ 常用参数: Port #监听端口 Socket #通信方式 Key_buffer_size #mysql内存使用大小 Log-bin=mysql-bin #记录二进制日志,注释掉。 Binlog_format=mixed #日志相关参数,注释掉。 Server_id=1 #主从复制参数,注释掉。
(8)将服务的启动脚本放入/etc/init.d/下。
cp /mysql目录/support-files/mysql.server /etc/init.d/mysqld
(9)修改启动文件。
vi /etc/init.d/mysqld
# The following variables are only set for letting mysql.server find things. # Set some defaults mysqld_pid_file_path= if test -z "$basedir" then basedir=/usr/local/mysql bindir=/usr/local/mysql/bin
mysqld_pid_file_path=/data/mysql/master.pid ------------------------------------------ basedir #定义程序所在路径 bindir #定义数据库启动路径
(10)在mysql目录下初始化mysql服务,看到两个ok就没问题。
mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
报错1:Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory 解决:yum install –y libai* 报错2:Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory 解决:yum install –y numactl-*