A

armbian 设置 lnmp

HB 网络电脑 2022-06-20

1、安装 nginx:

apt install nginx

2、安装 php:

apt install -y php7.3 php7.3-cli php7.3-common php7.3-fpm php7.3-json php7.3-opcache php7.3-readline

3、安装 mariadb:

apt install -y mariadb-server

4、配置 nginx:

vim /etc/nginx/sites-enabled/default

#index加入index.php
index index.php index.html index.htm index.nginx-debian.html;
#location ~ \.php$ {
#    include snippets/fastcgi-php.conf;
#
#    # With php-fpm (or other unix sockets):
#    fastcgi_pass unix:/run/php/php7.3-fpm.sock;
#    # With php-cgi (or other tcp sockets):
#    fastcgi_pass 127.0.0.1:9000;
#}

#修改为:
location ~ \.php$ {
    include snippets/fastcgi-php.conf;

    # With php-fpm (or other unix sockets):
    fastcgi_pass unix:/run/php/php7.3-fpm.sock;
#    # With php-cgi (or other tcp sockets):
#    fastcgi_pass 127.0.0.1:9000;
}

重启 nginx 服务

service nginx restart

5、配置 mariadb

@配置向导

mysql_secure_installation

解决 mysql 远程连接、移动 mysql data 目录(内置空间太小,保存到移动硬盘)

编辑 /etc/mysql/mariadb.conf.d/50-server.cnf

#修改
service mysql stop
bind-address = 127.0.0.1 改为 bind-address = 0.0.0.0
datadir    = /var/lib/mysql 改为 datadir    = /mnt/u_disk/lnmp/mysql/data

#复制数据:
cp -R /var/lib/mysql/* /mnt/u_disk/lnmp/mysql/data
service mysql start
设置密码登录:
#auth_socket,用密码登陆的plugin应该是mysql_native_password
use mysql;
select user, plugin from user;
如果为:
+------+-------------+
| user | plugin      |
+------+-------------+
| root | unix_socket |
+------+-------------+
#修改
update mysql.user set authentication_string=PASSWORD('密码'), plugin='mysql_native_password' where user='root';

flush privileges;

1130 解决方案:

mysql -u用户名 -p密码
mysql>use mysql;
mysql>update user set host = '%' where user = 'root';
mysql>flush privileges;
mysql>select host, user from user;

如果出错:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
flush privileges;
set password for 'root'@localhost  = password('12345678');
PREV
解决0x0000011b共享打印机无法连接
NEXT
玩客云docker版openwrt 玩客云刷入openwrt