下载mysql源码文件,解压
依赖项:
- cmake
- gcc,g++
进入解压后的目录
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/data/mysql \
-DSYSCONFDIR=/etc/mysql \
-DMYSQL_UNIX_ADDR=/var/run/mysqld/mysqld.sock \
-DENABLED_LOCAL_INFILE=1 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_DEBUG=0 \
-DWITH_BOOST=/usr/local/boost
没有boost或者boost版本不正确
解决方法:
下载相应的boost版本,解压到指定目录,然后添加编译命令DWITH_BOOST=指定目录。例如我的1-66-0下载地址
没有找到相应的ssl库
解决方法
yum -y install openssl openssl-devel
缺少依赖库Curses
解决方法:
错误写的很清楚,移除CMakeCache.txt文件,然后安装依赖包:yum -y install ncurses-devel
内存不足,mysql5.9以上的版本安装需要至少1G的内存,云主机一共才1G。
解决办法:
先删除之前的编译文件:make clean && rm -f CMakeCache.txt
dd if=/dev/zero of=/data/swap_add bs=1M count=2048
mkswap /data/swap_add
swapon /data/swap_add
swapon -s
# 添加mysql组和用户
groupadd mysql
useradd -g mysql mysql
# 将mysql配置的目录更换到mysql组中
chown -R mysql:mysql /data/mysql /var/run/mysqld
# 配置环境变量
vim /etc/profile
# 添加以下两行
export MYSQL_HOME="/usr/local/mysql"
export PATH="$PATH:$MYSQL_HOME/bin"
source /etc/profile
# 查看mysql默认加载配置文件
mysqld --verbose --help| grep -A 1 "Default options"
# 初始化数据库
mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql
### 如果报错
Can't find error-message file 'asedir=/usr/local/mysql/share/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive
修改mysql配置文件,在mysqld段下加入
lc-message-dir = /usr/local/mysql/share
lc-message = en-US
然后再执行初始化命令
官方文档
ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘MyNewPass’;// 注意一定有结尾的分号
# 新增组。同时加入组ID号,低于499的系统账号
groupadd -r nginx
# 创建用户指定登录shell,用户组,并且是系统账号
useradd -s /sbin/nologin -g nginx -r nginx
# 查看用户,组id号
id nginx
创建nginx需要指定的目录
./configure \
--prefix=/usr/local/nginx \
--sbin-path=/usr/sbin \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/usr/local/nginx/log/error.log \
--pid-path=/usr/local/nginx/log/nginx.pid \
--http-log-path=/usr/local/nginx/log/access.log \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_gzip_static_module \
--http-client-body-temp-path=/usr/local/nginx/tmp/client \
--http-proxy-temp-path=/usr/local/nginx/tmp/proxy \
--http-fastcgi-temp-path=/usr/local/nginx/tmp/fcgi \
--with-http_stub_status_module
make && make install
yum -y install libxml2 libxml2-devel libcurl libcurl-devel autoconf
# ./configure \
--prefix=/usr/local/php/ \
--with-curl \
--with-pdo-mysql \
--with-mysqli \
--with-openssl
# make && make install
在path中加入/usr/local/php/bin
进入php源码文件目录下的ext目录,里面有各个扩展的文件夹,进入mbstring
# phpize # 生成configure文件
# ./configure --help 查看帮助
# ./configure --with-php-config=/usr/local/php/bin/php-config --enable-mbstring
# make
# make install
# vim php.ini # 打开mbstring的注释
# make -j
# make install
# ldconfig
# ./configure --with-php-config=/usr/local/php/bin/php-config --enable-async-redis
# make clean
# make
# make install
# 编辑
以nginx,centos7为例
yum -y install python2-certbot-nginx
certbot --nginx
## 出现以下错误
ImportError: No module named 'requests.packages.urllib3'
## 解决办法
安装request库
pip install --upgrade --force-reinstall 'requests==2.6.0' urllib3
certbot --nginx
按照提示一步步操作
## 直到出现"Congratulations! You have successfully enabled"说明配置成功
## 更新证书 - 该免费证书的有效期只有90天,但是,可以通过定时脚本更新证书
0 0 1 * * /usr/bin/certbot renew --force-renewal
5 0 1 * * /usr/sbin/service nginx restart