安装前准备
注意:对于raspberry pi原生系统,采用apt-get 安装程序(本人采用buster版本系统测试过)
1、先切换到root用户,root账户权限高不用总输入sudo
su root
2、更换镜像源
镜像源文件位置/etc/apt/sources.list
备份镜像文件
cp /etc/apt/sources.list /etc/apt/sources.list.bak
用nano打开镜像文件删除里面的内容,把我们的中科大镜像源复制进去,替换掉原来的源
sudo nano cp /etc/apt/sources.list
中科大源
deb https://mirrors.ustc.edu.cn/ubuntu-ports/ disco main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu-ports/ disco main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu-ports/ disco-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu-ports/ disco-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu-ports/ disco-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu-ports/ disco-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu-ports/ disco-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu-ports/ disco-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu-ports/ disco-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu-ports/ disco-proposed main restricted universe multiverse
3、更新一下服务器
获取最新资源包
apt-get update
更新软件
apt-get upgrade
更新系统
apt-get dist-upgrade
一、安装apache
1、安装
apt install apache2 -y
2、检测是否开启apache,一般会默认开启
systemctl status apache2 //检测是否开启apache2
开启、关闭和重启服务器
service apache2 start
service apache2 stop
service apache2 restart
安装net-tools
,可以查看ip地址
apt install net-tools
在浏览器输入IP地址,可以看到Apache的界面表示安装成功
二、安装MySQL
MySQL Server 5.7或者MariaDB,选择其中一种安装
1、MySQL安装:
apt install mysql-server mysql-client -y
如果是原生系统,会提示你安装mariadb,具体安装哪个版本看提示即可
在安装的过程中,设置mysql服务器root账户的密码
2、开启mysql服务:
service mysql start
3、检测是否安装成功:
netstat -tap | grep mysql
4、登陆数据库:
mysql -u root -p
-u登陆用户名 -p用户密码
退出数据库:
quit
三、安装php
1、安装 PHP 7.2:
apt install php7.2-mysql php7.2-curl php7.2-json php7.2-cgi php7.2 libapache2-mod-php7.2 -y
安装后查看版本PHP版本:
php –version
输出phpinfo
2、配置Apache,告知其PHP的存在
打开/etc/apache2/mods-enabled/dir.conf
文件在第二行添加index.php。
<IfModule mod_dir.c>
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
</IfModule>
3、重新启动Apache服务器。
systemctl restart apache2
4、 创建phpinfo.php
nano /var/www/html/phpinfo.php
写入以下内容
<?php
echo phpinfo();
?>
http://你的服务器地址/phpinfo.php
输入ifconfig
可查看ip地址
如果安装是出错E: Sub-process /usr/bin/dpkg returned an error code (1)
那么执行以下步骤
cd /var/lib/dpkg
sudo mv info info.bak
sudo mkdir info
结束战斗。。。