1. 更新系统
sudo apt update -y && sudo apt upgrade -y
2. 安装apache
sudo apt install apache2
启动必要模块
sudo a2enmod rewrite
sudo a2enmod ssl
sudo systemctl restart apache2
3. 安装php8
A. 执行如下命令启用 ondrej/php 的 PHP 存储库
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
B. 使用apache安装php8
sudo apt-get update
sudo apt install php8.3 -y
sudo apt install libapache2-mod-php libapache2-mod-fcgid php8.3-common php8.3-cli php8.3-mbstring php8.3-bcmath php8.3-fpm php8.3-mysql php8.3-zip php8.3-gd php8.3-curl php8.3-xml php8.3-dom php8.3-imagick php8.3-intl php8.3-soap -y
//可能会有很多版本,如果不是8.3可以用下面的命令切换
sudo update-alternatives --config php
sudo systemctl restart apache2
4. 在apache中启用PHP-FPM
sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php8.3-fpm
sudo systemctl restart apache2
5. 安装mysql8
sudo apt-get install mysql-server -y
mysql8默认无密码需创建密码
sudo mysql_secure_installation (部分版本已经弃用了这种修改密码的方式)
或者
$ sudo mysql -u root
myslq> use mysql;
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '你的密码';
mysql> flush privileges;
mysql> exit;
6. 安装phpmyadmin
sudo apt install phpmyadmin -y
关于E: Sub-process /usr/bin/dpkg returned an error code (1)错误解决
sudo mv /var/lib/dpkg/info /var/lib/dpkg/info_old
sudo mkdir /var/lib/dpkg/info
sudo apt-get update
sudo apt-get -f install
sudo mv /var/lib/dpkg/info/* /var/lib/dpkg/info_old
sudo rm -rf /var/lib/dpkg/info
sudo mv /var/lib/dpkg/info_old /var/lib/dpkg/info
文章评论