LNMP安装笔记

安装Nginx

1
2
# apt update 
# apt install nginx

控制服务状态

1
2
3
4
5
# systemctl start nginx
# systemctl restart nginx
# systemctl stop nginx
# systemctl reload nginx
# systemctl status nginx

安装MariaDB

1
# apt install mariadb-server

安全配置全部Yes

1
# mysql_secure_installation

安装PHP-FPM (Fast Process Manager)

1
# apt install php-fpm php-mysqli

查看启动状态

1
# systemctl status php7.3-fpm

修改PHP-FPM配置文件/etc/php/7.3/fpm/php.ini
取消如下内容的注释,并改为0

1
cgi.fix_pathinfo=0

修改Nginx配置文件/etc/nginx/sites-available/default
取消如下内容的注释

1
2
3
4
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
}

同时添加主页index.php
重启服务

1
2
# systemctl restart php7.3-fpm
# systemctl restart nginx

/var/www/html/下编写测试页

1
<?php phpinfo(); ?>

测试正常后继续
下载phpMyAdmin,并解压到/var/www/html/目录下
进入mysql命令行创建phpmyadmin用户

1
2
3
CREATE USER 'phpmyadmin'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;

使用phpmyadmin登录成功即可

引用
https://www.tecmint.com/install-lemp-on-debian-10-server/
https://www.centos.bz/2017/07/mysql5-7-phpmyadmin-access-denied-for-user-rootlocalhost/