ubuntu20.0.4安装lamp+phpmyadmin

2022-02-07  本文已影响0人  道翼

1.更换软件源,使用国内软件源速度更快

#添加阿里源
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

2.更新软件

sudo apt-get update

3.安装apache2

sudo apt install apache2 -y
sudo systemctl status apache2   #查看Apache运行状态
sudo service apache2 restart      #可以使用sever命令重启

4.安装mariadb,mysql被收购后,社区担心之后会商业收费,基于mysql源码由MySQL的创始人和开发人员带人重新开发的,适用mysql命令

sudo apt install mariadb-server
sudo systemctl status mariadb
● mariadb.service - MariaDB 10.3.22 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2020-05-20 16:52:07 UTC; 12s ago
     ...

以root用户身份登录MariaDB服务器:

sudo mysql

将为您提供MariaDB shell,如下所示:

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 61
Server version: 10.3.22-MariaDB-1ubuntu1 Ubuntu 20.04

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> Bye

如果您想使用外部程序(例如phpMyAdmin)以root用户身份登录MariaDB服务器
创建一个新的专用管理用户,该用户可以访问所有数据库:

GRANT ALL PRIVILEGES ON *.* TO 'administrator'@'localhost' IDENTIFIED BY 'very_strong_password';

您可以使用任何想要的名称来命名管理用户,但请确保使用强密码(为了方便,我直接把root设为了root密码,但不建议这么做)

5.安装php,新公司使用多个不同php版本,使用了多个版本软件源

Ondřej Surý, 一个 Debian 开发者,维护了一个包含多个 PHP 版本的软件源。想要启用这个软件源,运行:

sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php

现在你可以通过在软件包后面添加版本号来安装任何版本的 PHP:

sudo apt install php[version]

例如,想要安装 PHP 7.1 和 几个通用的 PHP 模块,你可以运行:

sudo apt install php7.1 php7.1-common php7.1-opcache php7.1-mcrypt php7.1-cli php7.1-gd php7.1-curl php7.1-mysql
sudo apt-get install libapache2-mod-php[version]
sudo apt-get install php[version]-mysql

6.安装phpmyadmin

sudo apt install phpmyadmin
sudo ln -s /usr/share/phpmyadmin/ /var/www/phpmyadmin

7.1 以root用户登录phpadmin页面,访问127.0.0.1/phpmyadmin

8.额外修改,新公司数据库包比较大,需要修改php.ini文件才能正常导入

sudo vim /etc/php/[version]/apache2/php.ini

修改在 PHP 安装的 php.ini 中(注意:取决于你是否希望它用于 CLI、Apache 或 Nginx,找到正确的 php.ini 来操作)的这三个配置

post_max_size=500M

upload_max_filesize=500M

memory_limit=900M

sudo service apache2 restart      #重启可以了

引用链接:
如何在 Ubuntu 20.04 上安装 PHP
如何在Ubuntu 20.04上安装MariaDB
ubuntu20.4安装 mariadb 最新版

上一篇 下一篇

猜你喜欢

热点阅读