LNMP环境搭建
RockyLinux 9.4 ; Nginx 1.20.1; Mariadb 10.5.27 ; PHP 8.0.30
1. Nginx 安装
dnf update dnf install nginx
1.1 Nginx 自启服务配置
systemctl enable nginx.service
1.2 Nginx 启动、停止、重启、状态查看
systemctl start nginx.service systemctl stop nginx.service systemctl restart nginx.service systemctl status nginx.service
2. Mariadb Server 安装
dnf install mariadb mariadb-serve
2.1 Mariadb Server 自启服务配置
systemctl enable mariadb.service
2.2 Mariadb-Server 启动、停止、重启、状态查看
systemctl start mariadb.service systemctl stop mariadb.service systemctl restart mariadb.service systemctl status mariadb.service
3. PHP 安装
dnf install php php-fpm php-mysqlnd php-gd php-xml php-pdo php-pcre php-zlib
3.1 php-fpm自启服务配置
systemctl enable php-fpm.service
3.2 php-fpm Nginx 启动、停止、重启、状态查看
systemctl start php-fpm.service systemctl stop php-fpm.service systemctl restart php-fpm.service systemctl status php-fpm.service
4. Mariadb 常用配置(默认端3306,某些操作需要设置防火墙相关)
4.1 运行安全脚本配置
mysql_secure_installation
设置root密码。
是否删除匿名用户。
是否禁止root远程登录。
是否删除测试数据库和访问权限。
重新加载权限表。
4.2 登录到 Mariadb (以root身份登录)
mysql -u root -p;
4.3 创建数据库、用户、授权
CREATE DATABASE mydatabase; //创建数据库 CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'password'; //创建用户和设置密码,允许本地登录;"localhost" 更换为 "%" :允许从任何位置登录; GRANT ALL PRIVILEGES ON mydatabase.* TO 'myuser'@'localhost'; //授权操作权限 FLUSH PRIVILEGES; //刷新权限
目录 返回
首页