记录日常点点滴滴,欢迎来到我的小站。

0%

Ubuntu 20.04 安装 AMP系统(Apache, MySQL, PHP7)

Ubuntu 20.04 LTS国内快速更新源

一、源文件位置

备份并替换/etc/apt/sources.list的源内容:

二、更改源文件内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
sudo vi /etc/apt/sources.list
#deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse

安装之前先更新系统

[code]sudo apt update

1
2
3
4
5


#### 安装Apache2
```bash
sudo apt install apache2

安装PHP

1
2
3
sudo apt install php
sudo apt-get install libapache2-mod-php
sudo apt-get install php7.0-cli php7.0-cgi php7.0-fpm php7.0-zip php7.1-xml

安装MySQL

1
2
3
sudo apt install mysql-server php7.1-mysql    #这里注意,如果不使用7.1php是连接不上mysql的
sudo apt-get install mysql-client
mysql_secure_installation

安装phpmyadmin

1
2
3
4
sudo apt-get install phpmyadmin
sudo apt-get install php-mbstring
sudo apt-get install php-gettext
sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin

配置phpmyadmin

nano /etc/php/7.0/apache2/php.ini

1
2
3
4
5
6
7

display_errors = On(显示错误日志,出现两次,都要改,不然无效)
extension=php_mbstring.dll (开启mbstring)


开启rewrie模式
sudo a2enmod rewrite

并在Apache2设置文件中输入以下内容
<Directory “/var/www/html”>
AllowOverride All