近几天从Cent os更换到Ubuntu,在重新部署环境的这个过程中遇到了不少的问题,在成功调通后把自己的方法记录一下.
1.Apache2+Php的安装
1)使用apt进行安装即可
sudo apt update //更新源
sudo apt install apache2 //安装apache2
sudo apt install php //安装php
sudo apt install libapache2-mod-php //安装apache的扩展php
2)测试
首先在浏览器中输入localhost查看Apache是否正常运行.
如果Apache运行正常,前往/var/www/下,重命名index.html为index.html.bak,然后创建index.php,向文件中写入<?php echo phpinfo();
保存退出,如果能看到phpinfo页面则成功
2.MariaDB的安装
1)使用国内源安装
首先前往MariaDB官网的下载页面:https://downloads.mariadb.org/
这里选择稳定版的10.2.8版本
点击下载,进入下载页面.
在页面下方,选择Ubuntu的安装方式.
点击Instructions.
进入Instructions页面后,查看 repository configuration tool.
进入数据库配置工具,根据提示分别选择'发行商','发行版本','数据库版本','镜像源'.
依次选择后网页下方会生成安装方法,这里以Ubuntu 16.04 LTS + MariaDB 10.2为例:
然后根据下方的提示信息进行安装即可:
sudo apt-get install software-properties-common
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
sudo add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://mirrors.tuna.tsinghua.edu.cn/mariadb/repo/10.2/ubuntu xenial main'
sudo apt update
sudo apt install mariadb-server
2)关联php与Mariadb
sudo apt install php-mysql
apt已经为我们打包好各种php的扩展,需要的时候只要使用apt即可安装,以下为gd库为例:
sudo apt install php-gd