玩客云安装了armbian,开始安装Nginx,MySQL,PHP
换源
编辑suorces.list
nano /etc/apt/source.list然后,在后面添加以下代码
# 这四个是中科大源,我不使用所以注释掉了 #deb http://mirrors.ustc.edu.cn/debian stretch main contrib non-free #deb http://mirrors.ustc.edu.cn/debian stretch-updates main contrib non-free #deb http://mirrors.ustc.edu.cn/debian stretch-backports main contrib non-free #deb http://mirrors.ustc.edu.cn/debian-security/ stretch/updates main contrib non-free # 此处我使用哈工深源,因为有校园网更方便 # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释 deb https://mirrors.osa.moe/debian/ bookworm main contrib non-free non-free-firmware # deb-src https://mirrors.osa.moe/debian/ bookworm main contrib non-free non-free-firmware deb https://mirrors.osa.moe/debian/ bookworm-updates main contrib non-free non-free-firmware # deb-src https://mirrors.osa.moe/debian/ bookworm-updates main contrib non-free non-free-firmware deb https://mirrors.osa.moe/debian/ bookworm-backports main contrib non-free non-free-firmware # deb-src https://mirrors.osa.moe/debian/ bookworm-backports main contrib non-free non-free-firmware # deb https://mirrors.osa.moe/debian-security bookworm-security main contrib non-free non-free-firmware # # deb-src https://mirrors.osa.moe/debian-security bookworm-security main contrib non-free non-free-firmware deb https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware # deb-src https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware编辑/etc/apt/sources.list.d/armbian.list文件
nano /etc/apt/sources.list.d/armbian.list将原来的每一行内容都在开头处用
#号注释掉,然后,添加如下内容deb https://mirrors.tuna.tsinghua.edu.cn/armbian stretch main stretch-utils stretch-desktop因为哈工深镜像站没有armbian,还是要用清华源。
执行更新
apt-get update && apt-get upgrade
安装Nginx/PHP/MySQL
安装Nginx
apt-get -y install nginx安装PHP
apt install -y php php-fpm php-mysql php-gd php-curl php-mbstring说明:
- PHP
核心运行环境,PHP编程语言解释器 - PHP-fpm
负责接受Nginx转发的PHP请求/执行代码 - PHP-MySQL
连接数据库 - PHP-gd
图像处理库 - PHP-curl
网络请求扩展 - PHP-mbstring
多字节字符串扩展,用于处理中文、日文、特殊字符 安装MariaDB
apt install -y mariadb-server- MariaDB是一个能够兼容MySQL的数据库,因为MySQL闭源,对ARM设备兼容差,但作者一样,可以直接替代了
- 修改Nginx配置
打开配置文件
nano -c /etc/nginx/sites-enabled/default这里的
nano -c意思是让nano打开文本时显示行号,方便查找所需要修改的行。这里的行号可能会因nginx的版本不同有所变化,根据自己实际的行号找到图中所对应的行进行修改。
根据提示,在第44行后面加上index.php,注释之后,代码如下:
# Add index.php to the list if you are using PHP index index.html index.htm index.nginx-debian.html index.php;在第56-63行,将第57和61行取消原有#注释,注释后代码如下:
location ~ \.php$ { include snippets/fastcgi-php.conf; # # # With php-fpm (or other unix sockets): fastcgi_pass unix:/run/php/php8.2-fpm.sock; # # With php-cgi (or other tcp sockets): # fastcgi_pass 127.0.0.1:9000; }
注意:代码里面的fastcgi_pass unix:/run/php/php8.2-fpm.sock;的PHP版本要和你安装的一致,比如我的就是8.2,查看版本号可以使用ls /run/php/命令。
重启Nginx
service nginx restart- 配置MySQL
重启服务
service mysqld restart使用配置向导
mysql_secure_installation输出如下,根据提示做即可
Enter current password for root (enter for none):<–初次运行直接回车 Switch to unix_socket authentication [Y/n] 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远程登录,回车, 建议 N Remove test database and access to it? [Y/n] <– 是否删除test数据库,回车 Reload privilege tables now? [Y/n] <– 是否重新加载权限表,回车
测试环境
创建测试文件
echo "<?php phpinfo(); ?>" >/var/www/html/info.php- 打开网址
localhost\info.php其中localhost需要换成服务器IP地址
comment 评论区
star_outline 咱快来抢个沙发吧!