Nginx环境搭建
sudo apt install nginx -y
sudo nano /etc/nginx/nginx.conf
####配置文件存放处
cd /etc/nginx/conf.d
####配置示例文件
sudo nano /etc/nginx/sites-enabled/default
systemctl status nginx
sudo nginx -t
sudo service nginx stop
sudo service nginx restart
sudo nginx -s reload
PHP环境搭建
##安装 MySQL 8.0 所需的软件包
sudo apt install dirmngr software-properties-common apt-transport-https curl lsb-release ca-certificates -y
##自动脚本导入和安装 GPG 密钥和存储库
curl -sSL https://packages.sury.org/php/README.txt | sudo bash -x
##刷新系统的软件包列表
sudo apt update
##选择以下 PHP 版本之一为 Nginx 安装 PHP 和 PHP-FPM
sudo apt install php{version} php{version}-fpm php{version}-cli
sudo apt install php7.4 php7.4-fpm php7.4-cli
##安装 PHP 扩展
sudo apt install phpx.x-{cli,fpm,curl,mysqlnd,gd,opcache,zip,intl,common,bcmath,imagick,xmlrpc,readline,memcached,redis,mbstring,apcu,xml,dom,memcache}
sudo apt install php7.4-{cli,fpm,curl,mysqlnd,gd,opcache,zip,intl,common,bcmath,imagick,xmlrpc,readline,memcached,redis,mbstring,apcu,xml,dom,memcache}
##PHP-FPM 服务开始运行
sudo systemctl start php{version}-fpm
sudo systemctl restart php{version}-fpm
##配置 Nginx 服务器块
location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php{version}-fpm.sock;
}
Mysql环境搭建
#注意(一):
host:域名 / localhost
username:用户名
password:密码
port:端口,默认3306
DatabaseName:数据库名称
#注意(二):
##PHP5.6无法连接MySQL解决
###[php.ini]配置修改
/etc/php/5.6/cli/php.ini
/etc/php/5.6/fpm/php.ini
###删除分号
;always_populate_raw_post_data
###MySQL的[mysqld]配置修改
sudo nano /etc/mysql/mysql.conf.d/
###[mysqld]配置修改
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
default_authentication_plugin=mysql_native_password
#MySQL 8.0开始安装
##安装 MySQL 8.0 所需的软件包
sudo apt install dirmngr software-properties-common apt-transport-https curl lsb-release ca-certificates -y
##导入 MySQL 社区存储库
##导入 GPG 密钥
###注意:显示unsigned,请修改RPM-GPG-KEY-mysql-xxxx
curl -fsSL https://repo.mysql.com/RPM-GPG-KEY-mysql-2023 | gpg --dearmor | sudo tee /usr/share/keyrings/mysql.gpg > /dev/null
##添加 MySQL 8.0 APT 存储库
echo "deb [signed-by=/usr/share/keyrings/mysql.gpg] http://repo.mysql.com/apt/debian $(lsb_release -sc) mysql-8.0" | sudo tee /etc/apt/sources.list.d/mysql.list
##导入开发 MySQL 8.0 工具
echo "deb [signed-by=/usr/share/keyrings/mysql.gpg] http://repo.mysql.com/apt/debian $(lsb_release -sc) mysql-tools" | sudo tee -a /etc/apt/sources.list.d/mysql.list
echo "deb-src [signed-by=/usr/share/keyrings/mysql.gpg] http://repo.mysql.com/apt/debian $(lsb_release -sc) mysql-tools" | sudo tee -a /etc/apt/sources.list.d/mysql.list
##刷新系统的软件包列表
sudo apt update
##通过 APT 命令安装 MySQL 8.0
sudo apt install mysql-community-server
##设置 MySQL 8.0 数据库根密码:图形化界面 TAB + Enter
#MySQL 5.7开始安装
##注意:MySQL 5.7 存储库尚不可用于 Debian 11 (Bullseye)
##下载并安装 mysql 存储库设置包
###下载
wget https://repo.mysql.com/mysql-apt-config_0.8.18-1_all.deb
##安装
###安装依赖软件
sudo apt install gnupg
###安装命令
sudo dpkg -i mysql-apt-config_0.8.18-1_all.deb
###图形界面设置
debain buster => MySQL Server & Cluster(Currently selected:mysql-8.0) => mysql-5.7 => ok
###导入GPG 密钥
注:... the public key is not available: NO_PUBKEY xxxxxx
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys xxxxxx
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B7B3B788A8D3785C
###安装 MySQL 5.7 服务器包
sudo apt update
sudo apt install -y mysql-community-server
#MySQL操作
##常规操作
mysql -V
sudo service mysql start
sudo service mysql restart
sudo service mysql stop
##登录mysql
mysql -u用户名 -p密码
##连接远程数据库
mysql -h <host> -P <port> -u<username> -p<password>
##用户管理
###创建
###默认创建
create user 'username' @'host' identified by 'password';
##适配PHP5.x
CREATE USER 'username'@'host' IDENTIFIED WITH mysql_native_password BY 'password';
##查看
select user,host from mysql.user;
##删除
drop user 'username'@'host';
#数据库操作
##创建
create database DatabaseName;
##删除
drop database DatabaseName;
##查看
show databases;
use DatabaseName;
show tables;
SELECT * FROM tableName;
##导出SQL文件
mysqldump -u 'username' -h 'host' -p DatabaseName > /../Other_DatabaseName.sql
##导入SQL文件
mysql -u 'username' -h 'host' -p DatabaseName < /../Other_DatabaseName.sql
##权限管理
###开放权限
GRANT all ON DatabaseName.* TO 'uername'@'host';
###立即生效
flush privileges;
SSl证书申请
lsof -i:端口
sudo service nginx stop
sudo service nginx restart
安装acme软件
curl https://get.acme.sh | sh
/.acme.sh/acme.sh --register-account -m xxxxx@gmail.com
80 端口空闲的验证申请
/.acme.sh/acme.sh --issue -d mydomain.com --standalone
安装证书到指定文件夹
/.acme.sh/acme.sh --installcert -d mydomain.com --key-file /ssl/mydomain.com/private.key --fullchain-file /ssl/mydomain.com/cert.crt
评论区