nginx 新增模块缺失,
nginx: [emerg] unknown directive "more_clear_headers"
https://blog.csdn.net/chunyuan314/article/details/81737303
安装
https://github.com/openresty/headers-more-nginx-module
cd /usr/local/src
wget https://github.com/openresty/headers-more-nginx-module/archive/v0.33.tar.gz
tar -xzvf v0.33.tar.gz
cd headers-more-nginx-module-0.33
新增模块
# 先准备曾经的配置,找到 configure arguments 后边的配置。
nginx -V
# 找到曾经的包文件
cd /usr /local/src/nginx
# 再配置后追加 add-module 指向headers-more-nginx-module-0.33
./configure --user=nginx --group=nginx --prefix=/alidata/service/nginx --pid-path=/alidata/service/nginx/run/nginx.pid --with-http_stub_status_module --with-threads --with-file-aio --with-pcre-jit --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-http_sub_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_realip_module --with-http_addition_module --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-stream_realip_module --with-http_slice_module --with-pcre --with-openssl=/usr/local/src/base/1-openssl/openssl-1.1.1f --with-openssl-opt=enable-tls1_3 --add-module=/opt/ngx_brotli/ --add-module=/usr/local/src/nginx/headers-more-nginx-module-0.33
# 再make (千万不要 make install)
make
# 然后复制 nginx 文件覆盖之前安装包里的 nginx 文件,覆盖安装之前 ,先备份一个
nginx stop
cp /alidata/service/nginx/sbin/nginx /alidata/service/nginx/sbin/nginx.back
cp -r objs/nginx /alidata/service/nginx/sbin/nginx
# 启动
/alidata/service/nginx/sbin/nginx
参考
https://segmentfault.com/a/1190000018418253?utm_source=coffeephp.com
可参考:
https://blog.vini123.com/107
###
wget http://download.redis.io/releases/redis-5.0.8.tar.gz
tar -xzvf redis-5.0.8.tar.gz
cd redis-5.0.8
# 安装依赖
yum install tcl
# 继续
make
make test
# 没有问题就安装
make install PREFIX=/alidata/service/redis
# 配置并启动redis
mkdir /alidata/service/redis/etc/
cp /usr/local/src/redis/redis-5.0.8/redis.conf /alidata/service/redis/etc/
vim /alidata/service/redis/etc/redis.conf #编辑redis.conf
daemonize yes #将此行对应的no改成yes。
# 启动
/alidata/service/redis/bin/redis-server /alidata/service/redis/etc/redis.conf
# 连接 redis
/alidata/service/redis/bin/redis-cli
配置开机自启动
# 开机自启动
cp /usr/local/src/redis/redis-5.0.8/utils/redis_init_script /etc/init.d/redis
vim /etc/init.d/redis
# 然后修改EXEC、REDIS_CLI、CONF对应的值。分别对应服务端位置、客户端位置、配置文件位置。保存,退出。修改后的脚本如下;
# 修改
#!/bin/sh
#
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.
### BEGIN INIT INFO
# Provides: redis_6379
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Redis data structure server
# Description: Redis data structure server. See https://redis.io
### END INIT INFO
REDISPORT=6379
EXEC=/alidata/service/redis/bin/redis-server
CLIEXEC=/alidata/service/redis/bin/redis-cli
PIDFILE=/var/run/redis_${REDISPORT}.pid
CONF=/alidata/service/redis/etc/redis.conf
case "$1" in
start)
if [ -f $PIDFILE ]
then
echo "$PIDFILE exists, process is already running or crashed"
else
echo "Starting Redis server..."
$EXEC $CONF
fi
;;
stop)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE does not exist, process is not running"
else
PID=$(cat $PIDFILE)
echo "Stopping ..."
$CLIEXEC -p $REDISPORT shutdown
while [ -x /proc/${PID} ]
do
echo "Waiting for Redis to shutdown ..."
sleep 1
done
echo "Redis stopped"
fi
;;
*)
echo "Please use start or stop as first argument"
;;
esac
执行权限,并开启服务重启自启动
chmod +x /etc/init.d/redis #执行权限
chkconfig redis on #系统服务中启动redis服务
chkconfig --list #系统服务启动列表
/etc/init.d/redis start #启动redis
安装 php redis 扩展
cd /usr/local/src
mkdir php-redis
cd php-redis
wget http://pecl.php.net/get/redis-5.2.1.tgz
tar -xizvf redis-5.2.1.tgz
cd redis-5.2.1
# 编译安装
phpize
./configure
make && make install
# 配置
vim /alidata/service/php/etc/php.ini
在末尾加上 extension=redis.so 保存。
# 重启
/etc/init.d/php-fpm restart
# 查看
php -m | grep redis
mysql8忘记密码有点不一样。其实很坑的,明明密码没错误,偏偏说错误。就算错误了,使用 skip-grant-tables 这玩意也进不去 mysql。那现在使用一个简单的方法来搞定这个问题。
这里使用 --init-file 方式重启 mysql 可以设置 root 用户的密码。亲测有效。
--init-file 干啥子的呢。就是 mysql 启动的时候,执行 --init-file对应的文件里的语句。
那么操作吧。
vim /usr/local/temp/resetPd.txt
# 加入下边命令,重新设置 root 密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '@¥#abcd1234';
:wq 保存
# 然后重启 mysql
service mysqld restart --init-file=/usr/local/temp/resetPd.txt --console
# 再用新密码登录 mysql
mysql -u root -p
# 发现果然好使,果然可以登录上去了
mysql 设置 root 用户密码以及禁用远程登录 root 用户后,需要设置一些其他账户密码使用。
mysql 常见的用户密码权限类型:
- 本地用户访问。
- 外网用户任意ip访问。
- 外网特定ip访问。
- 指定访问数据库。
- 指定数据库表的增删改查权限。
创建用户
创建本地用户
create user shenqi@localhost identified by '33441314';
# 这样就会在 mysql 库的 user 表中,就插入了一条用户数据。退出 root 用户,使用该账户就可以登录进来了。但进来只有一个数据库 information_schema 。因此需要给用户分配数据库权限以及刷新权限。
https://www.jianshu.com/p/5903e8c002ed
创建外网访问的用户
create user shenqi@'%' identified by '33441314';
设置本地服务器对数据库的全部权限
grant all privileges on dbname.* to shenqi@localhost;
设置外网服务器对数据库的全部权限
grant all privileges on dbname.* to shenqi@'%';
如果想要指定的外网ip 才可以访问,可以将 % 改成允许访问的 ip,也就是外网其他 ip 是不可以访问的。
设置用户访问所有的数据库
grant all on *.* to 'shenqi'@'%';
使得更改生效
flush privileges;
例子:
create user feipool@'%' identified by '_Sq123456';
grant all on feipool.* to feipool@'%';
ALTER USER feipool@'%' IDENTIFIED WITH mysql_native_password BY '_Sq123456';
flush privileges;
其他操作
# 删除用户
drop user 'shenqi';
# 修改用户账号名
rename user 'shenqi' to 'vini';
# 修改用户密码
alter user 'shenqi'@'%' identified by '98589958';
# 显示某个用户的权限
show grants for shenqi;
# 设置单独的权限
grant EXECUTE,INSERT,SELECT,UPDATE, DELETE on dbname.* to shenqi@'%';
# execute 执行存储过程的权限
# insert 插入
# select 查询
# update 修改
# delete 删除
# dbname.* 是所有的表的权限,也可以具体某个表
# 权限回收
revoke update on dbname.* from shenqi;
# revoke取消的意思,后面跟权限,多个权限的时候使用逗号隔开,on 后面跟对象,from 后面跟用户,前面赋权的时候跟to,现在取消使用from,不要搞错了,全部权限的话可以使用all
测试
create database shenqi
grant all on shenqi.* to 'shenqi'@'%';
flush privileges;
# shenqi 用户登录, 看看 database;
show databases;
还可以建立角色,设置角色权限,将用户和角色绑定在一起就可以。这种在数据库账号多的情况下实在好用。
在CentOS8下编译安装MySQL8可能会出现Could not find rpcgen错误,而CentOS8默认的yum源下不提供rpcgen的安装包。所以需要到rpcgen的GitHub仓库上找,地址如下:
https://github.com/thkukuk/rpcsvc-proto/releases
参考:
http://www.linuxfromscratch.org/blfs/view/svn/basicnet/rpcsvc-proto.html
下载安装
wget https://github.com/thkukuk/rpcsvc-proto/archive/v1.4.1.tar.gz
tar -xzvf v1.4.1.tar.gz
./configure --sysconfdir=/etc
先下载:
当前最新版本 8.0.19
cd /usr/local/src/
mkdir mysql
cd mysql
wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-boost-8.0.19.tar.gz
tar -xzvf mysql-boost-8.0.19.tar.gz
创建用户组以及相关目录
groupadd mysql #创建mysql用户组
useradd -s /sbin/nologin -g mysql -M mysql #创建mysql用户归属mysql组
mkdir /alidata/service/mysql/mysql #创建安装目录
mkdir -p /alidata/service/mysql/data #创建数据库存放目录
chown -R mysql:mysql /alidata/service/mysql/data #给予权限
mkdir /alidata/service/mysql/log
touch /alidata/service/mysql/log/mysql-error.log
touch /alidata/service/mysql/log/mysql-slow.log
chmod 777 /alidata/service/mysql/log -R
开始编译安装
cd mysql-8-0-19
cmake ../ -DCMAKE_INSTALL_PREFIX=/alidata/service/mysql/mysql -DMYSQL_DATADIR=/alidata/service/mysql/data -DWITH_BOOST=boost -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/src/mysql/mysql-8.0.19/ -DSYSCONFDIR=/etc -DFORCE_INSOURCE_BUILD=1 -DDEFAULT_CHARSET=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_general_ci -DENABLED_LOCAL_INFILE=ON -DWITH_INNODB_MEMCACHED=ON -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1
发现报错: Please do not build in-source. Out-of source builds are highly
这个时候这样处理
mkdir build
cd build
再 cmake .. 后边各种参数
继续报错:
报 Could NOT find Curses 这个。缺少 ncurses-devel , 装个就可以了。
yum install ncurses-devel
然后,再重新 camke,再报错,报 Package 'libtirpc', required by 'virtual:world', not found
继续安装
yum install libtirpc-devel
继续报错 Could not find rpcgen。 在CentOS8下编译安装MySQL8可能会出现Could not find rpcgen错误,而CentOS8默认的yum源下不提供rpcgen的安装包。所以需要到rpcgen的GitHub仓库上找,
继续报错 Could NOT find BISON
yum install bison
继续报错 Could NOT find Doxygen,然后编译安装 doxygen
git clone https://github.com/doxygen/doxygen.git
cd doxygen
cmake .. -G "Unix Makefiles"
make -j2
sudo make install
然后继续报错Could NOT find FLEX
yum install flex
安装好 doxygen 后,继续编译 mysql。
make -j2
make install
初始化数据库
cd /alidata/service/mysql/mysql
./mysqld --initialize-insecure --user=mysql --basedir=/alidata/service/mysql/mysql --datadir=/alidata/service/mysql/data
设置mysqld
cd /usr/local/src/mysql/superfiles
cp mysql.server.sh /etc/init.d/mysqld
vim /etc/init.d/mysqld
# 修改 dir 配置保存
basedir=/alidata/service/mysql/mysql
datadir=/alidata/service/mysql/data
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld #添加到系统服务
chkconfig mysqld on #设置开机自启动
更改环境变量
vim /etc/profile
PATH=$PATH:/alidata/service/mysql/mysql/bin
export PATH
source /etc/profile
设置 my.cnf
vim /etc/my.cnf
# 内容如下
[client]
port=3306
#user=root
#password=123
[mysqld]
# sql_mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
# sql_mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
server-id=1
#skip-grant-tables
port=3306
user=mysql
max_connections=400
basedir=/alidata/service/mysql/mysql
datadir=/alidata/service/mysql/data
socket=/alidata/service/mysql/data/mysql.sock
pid-file=/alidata/service/mysql/data/mysql.pid
init-connect='SET NAMES utf8mb4'
character-set-server=utf8mb4
default-storage-engine=INNODB
log_error=/alidata/service/mysql/log/mysql-error.log
slow_query_log_file=/alidata/service/mysql/log/mysql-slow.log
[mysqldump]
quick
max_allowed_packet=128M
EOF
授权,设置用户组
chown -R mysql.mysql /alidata/service/mysql/mysql
chown -R mysql.mysql /alidata/service/mysql/data
chmod -R 755 /alidata/service/mysql/mysql
chmod -R 755 /alidata/service/mysql/data
启动 mysql
/etc/init.d/mysqld start
执行安全初始化脚本
# 执行,然后回车
mysql_secure_installation
Securing the MySQL server deployment.
Connecting to MySQL using a blank password.
The 'validate_password' component is installed on the server.
The subsequent steps will run with the existing configuration
of the component.
Please set the password for root here. # 设置root用户密码
如果报错 `Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)`
可以执行: ln -s /alidata/service/mysql/data/mysql.sock /tmp/mysql.sock
New password:
Re-enter new password:
Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
#是否删除匿名用户,生产环境建议删除
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.
#是否禁止root远程登录,根据自己的需求选择Y/n并回车,建议禁止
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
#是否删除test数据库
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
#是否重新加载权限表,直接回车
Reload privilege tables now? (Press y|Y for Yes, any other key for No) :
... skipping.
All done!
到此,设置了 root 用户密码,以及禁用远程登录 root 用户,也删除了匿名用户。那么需要创建一个新用户来使用mysql了。
请看这里: https://blog.vini123.com/382
远程连接 mysql
创建新用户,然后远程连接。
create user shenqi@'%' identified by '33441314';
# 创建 shenqi 用户,并设置密码。但这样远程连接会报错。
caching_sha2_password' cannot be loaded: dlopen(/usr/local/lib/plugin/caching_sha2_password.so,
# 使用 mysql_native_password 方式设置密码就好了。
ALTER USER 'shenqi'@'%' IDENTIFIED WITH mysql_native_password BY '33441314';
请看这里: https://www.iteye.com/blog/binary-space-2412769
参考
安装
github 地址:
https://github.com/kkos/oniguruma/
过程:
点击 tags,找到最新版本,寻找下载
cd /usr/local/src/php/
wget https://github.com/kkos/oniguruma/archive/v6.9.5_rc1.zip
unzip v6.9.5_rc1.zip
./autogen.sh && ./configure --prefix=/usr
# 错误
./autogen.sh: line 6: autoreconf: command not found
# 解决错误,
yum install autoconf automake libtool
make && make install
参考:
https://www.cnblogs.com/architectforest/p/12433640.html
24kplus.com/linux/1614.html
参考版本
https://www.24kplus.com/linux/400.html
却的依赖,然后安装:
yum install sqlite-devel
# centos8 安装 oniguruma ,yum 不行。
yum install oniguruma
yum 不行,就编译安装个哈。看这里
https://blog.vini123.com/379
configure 后会出警告如下:
php 7.4 --enable-gd 代替 --with-gd
configure: WARNING: unrecognized options: --with-freetype-dir, --with-libxml-dir, --with-pcre-regex, --with-png-dir, --with-jpeg-dir, --enable-libxml, --enable-zip, --enable-gd
不管它,安装吧。
最后:
Wrote PEAR system config file at: /alidata/service/php/etc/pear.conf
You may want to add: /alidata/service/php/lib/php to your php.ini include_path
/usr/local/src/php/php-7.4.4/build/shtool install -c ext/phar/phar.phar /alidata/service/php/bin
ln -s -f phar.phar /alidata/service/php/bin/phar
Installing PDO headers: /alidata/service/php/include/php/ext/pdo/
如果之前没安装 gd库,则需要安装
https://www.php.net/manual/zh/image.installation.php
安装 gd jpeg:
cd /usr/local/src/php
wget http://www.ijg.org/files/jpegsrc.v9c.tar.gz
tar -xzvf jpegsrc.v9c.tar.gz
# 我们安装到 /usr/local/lib/jpeg 目录
./configure --prefix=/usr/local/lib/jpeg --enable-shared --enable-static
make && make install
再 安装 freetype2
git clone https://github.com/aseprite/freetype2.git
cd freetype2
../autogen.sh
./configure --prefix=/usr/local/lib/freetype
make && make install
# 查看之前的,然后接上现在的,继续编译安装,然后重启
php -i |grep configure
./configure … --with-jpeg-dir=/usr/local/lib/jpeg --with-freetype-dir=/usr/local/lib/freetype
然后,最终的 configure。
./configure --prefix=/alidata/service/php --with-config-file-path=/alidata/service/php/etc --with-config-file-scan-dir=/alidata/service/php/etc/php.d --with-fpm-user=nginx --with-fpm-group=nginx --with-curl --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-mysqli --with-openssl --with-external-pcre --with-pdo-mysql --with-pdo-sqlite --with-pear --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --enable-bcmath --with-libxml --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --with-zip --enable-fpm --enable-gd --with-jpeg=/usr/local/lib/jpeg --with-freetype=/usr/local/lib/freetype
发现有报错,libzip 木有。那就安装吧。
wget https://libzip.org/download/libzip-1.7.3.tar.gz
tar -xzvf libzip-1.7.3.tar.gz
cd libzip-1.7.3
mkdir build
cd build
cmake ..
make && make install
whereis libzip
出现结果,ok
# 进入到 php 文件目录
cd php
export PKG_CONFIG_PATH="/usr/local/lib64/pkgconfig/"
#上面命令的作用就是告诉configure程序,去/usr/local/lib64 目录下找库文件,这样他就能找到libzip.so
此时,你继续./configure将会很顺利的看到
再进行 configure 出现 thanks 时才表示各种都准备好了。如果没有,还得继续处理问题。 然后 make && make install
参考
https://segmentfault.com/q/1010000022601109
https://www.php.net/manual/zh/migration74.other-changes.php#migration74.other-changes.pkg-config
编译安装 gcc gcc-c++
安装文档:
https://gcc.gnu.org/install/
安装包镜像:
https://gcc.gnu.org/mirrors.html
https://bigsearcher.com/mirrors/gcc/releases/
发现 yum 源上的是 8.3版本,而 9.3版本已经在2020年3月12日发布了。
cd /usr/local/src/
mkdir gcc
cd gcc
wget https://bigsearcher.com/mirrors/gcc/releases/gcc-9.3.0/gcc-9.3.0.tar.gz
tar -xzvf gcc-9.3.0.tar.gz
# 哎呀 ,不熟悉。还是 yum 安装吧。强迫症郁闷。
