一、Nginx安装
sudo apt update
sudo apt install nginx #安装nginx
安装完成后执行:
sudo systemctl enable nginx.service #设置 Nginx 开机运行
sudo systemctl start nginx.service #启动 Nginx 服务
二、PHP安装(Debian默认php7.3)
1、设置源
wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -
sudo echo "deb https://packages.sury.org/php/ buster main" | tee /etc/apt/sources.list.d/php.list
2、安装PHP
sudo apt update
sudo apt install php7.3 php7.3-fpm #安装php和php-fpm,必须nginx下必须安装php-fpm
php要支持nginx的话必须安装 php7.3-fpm,如果执行不安装php-fpm的话,即执行 sudo apt install php7.3 的话,php默认支持apache,所以必须执行 sudo apt install php7.3 php7.3-fpm
3、设置PHP开机运行和启动
sudo systemctl enable php7.3-fpm #设置开机运行
sudo systemctl start php7.3-fpm #启动 Mariadb 服务
4、其它组件自行安装
三、Mariadb安装
sudo apt install mariadb-server #安装 Mariadb
sudo systemctl enable mariadb.service #设置开机运行
sudo systemctl start mariadb.service #启动Mariadb服务
mysql_secure_installation #进入初始化设置
按提示根据实际情况进行设置
Enter current password for root (enter for none): #初次运行直接回车
Set root password? [Y/n] #是否设置root用户密码,输入y并回车或直接回车
New password: #设置root用户的密码
Re-enter new password: #再输入一次你设置的密码
Remove anonymous users? [Y/n] #是否删除匿名用户
Disallow root login remotely? [Y/n] #是否禁止root远程登录
Remove test database and access to it? [Y/n] #是否删除test数据库
Reload privilege tables now? [Y/n] #是否重新加载权限表
其他设置
mysql #进入mysql
mysql>create user 'username'@'localhost' identified by 'password'; #创建用户命令
mysql>grant all on *.* to 'username'@'localhost' indentified by 'password'; #直接创建用户并授权的命令
mysql>grant all privileges on *.* to 'username'@'%' identified by 'password'; #授予外网登陆权限
mysql>grant all privileges on *.* to 'username'@'hostname' identified by 'password' with grant option; #授予权限并且可以授权
mysql> show variables like "%character%"; #MariaDB查看字符集
mysql>show variables like "%collation%"; #MariaDB查看字符集
<参考>
https://tecadmin.net/install-nginx-php-fpm-debian-10/
http://www.linuxidc.com/Linux/2016-03/128880.htm
网友评论