lamp环境配置
Posted 果然朝辉
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了lamp环境配置相关的知识,希望对你有一定的参考价值。
一.配置虚拟域名
![](https://image.cha138.com/20210610/15e4bf4dc8034d97bf9745b9941d9793.jpg)
![](https://image.cha138.com/20210610/8a6918f0e7164d9f924bda2e213663de.jpg)
1.为了模拟DNS,在本地hosts文件中设置一下
![](https://image.cha138.com/20210610/b5c72ef83f5341dd94b623203713e7a2.jpg)
2.模拟三个项目
![](https://image.cha138.com/20210610/2160b0456f15428695b2a0189a47984e.jpg)
3.在apache中配置虚拟主机
去到apache的sites-available目录里复制三次default文件,然后在复制的文件里修改三个地方:![](https://image.cha138.com/20210610/05215691b5af45eca03a1ff0ee705506.jpg)
![](https://image.cha138.com/20210610/e60ad218c5754e37b5f182b0112e3dd3.jpg)
![](https://image.cha138.com/20210610/05215691b5af45eca03a1ff0ee705506.jpg)
![](https://image.cha138.com/20210610/e60ad218c5754e37b5f182b0112e3dd3.jpg)
![](https://image.cha138.com/20210610/050caf7b05e6464eb8b7e5b9a711d4fb.jpg)
去到sites-enable目录里复制default文件三次,然后利用ln -s把复制的文件分别指向sites-available里对应的文件![](https://image.cha138.com/20210610/39be0566e8fe4eecb683ccc818a18333.jpg)
![](https://image.cha138.com/20210610/39be0566e8fe4eecb683ccc818a18333.jpg)
4.重启apache,然后去浏览器验证
二、mysql数据库存储目录迁移
1.停止mysql
![](https://image.cha138.com/20210610/197e19ca662f448abbddff1ed8c6aad0.jpg)
2.查看mysql的所属用户组、所属用户和操作权限,然后创建一个同用户组同所属用户同操作权限的目录
![](https://image.cha138.com/20210610/cccde2f1a50e4eb896b0951bda06ca2c.jpg)
![](https://image.cha138.com/20210610/0d8d4645104b42b0b06de81786537677.jpg)
3.复制数据
![](https://image.cha138.com/20210610/4ae4f56ec08b441b9b8fa24bff952211.jpg)
4.修改mysql的配置文件my.cnf
![](https://image.cha138.com/20210610/a602faffb3f74b9a8b1b43ca8639c50a.jpg)
5.在ubuntu里需要修改apparmor
![](https://image.cha138.com/20210610/e0ba918224b84ebca4d9f0638440fbcc.jpg)
![](https://image.cha138.com/20210610/c8f384299a61488d9efe54177f1bd2a8.jpg)
6.重启apparmor和apache
![](https://image.cha138.com/20210610/3ece82531d9b47db866113ea8819588a.jpg)
7.测试是否迁移成功,新建一个数据库然后查看迁移目录是否有新建的数据库文件即可证明
8.删除原文件目录的文件
![](https://image.cha138.com/20210610/3f9639eea4204f31a4e175343ea66822.jpg)
三、配置安装phpmyadmin
![](https://image.cha138.com/20210610/31758987b73849ba946d3a97979deabe.jpg)
四、mysql的远程访问
1.注释mysql配置文件my.cnf里的bind-address参数(该参数对于整个服务器而言)
![](https://image.cha138.com/20210610/2d40dbf829944ee695398cb9e4bc1332.jpg)
2.在phpmyadmin里创建一个用户(这里对于某个用户而言)
![](https://image.cha138.com/20210610/1004f291838d4c64b0b60a70808a8437.jpg)
![](https://image.cha138.com/20210610/efeeda632edc4c8ebc4747fafaa57183.jpg)
3.重启mysql
注意:1.也可以通过命令行进行设置
![](https://image.cha138.com/20210610/f0ca70db5a5f4d1da9d0dc39d79cfe8c.jpg)
以上是关于lamp环境配置的主要内容,如果未能解决你的问题,请参考以下文章