LAMP环境搭建(Linux+Apache+Mariadb+PHP)
- 实验环境
- lamp server:Centos7.6 192.168.10.121
- client:windows 10 192.168.10.1
环境配置
-
关闭防火墙


-
关闭selinux


-
配置yum源(需要能够确保连接外网)



cd /etc/yum.repos.d/
mv CentOS-Base.repo CentOS-Base.repo.bak
wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
yum makecache
-
安装epel源

wget -O epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum clean all
yum makecache
安装所需服务
-
安装httpd 2.4(Apache)

-
安装php与Mariadb

-
安装所需的库及服务

yum install -y php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt
- 检查是httpd中否存在php模块libphp5.so

修改相关配置文件
-
修改httpd主配置文件/etc/httpd/conf/httpd.conf中的NameServer与DirectoryIndex


-
在/var/www/html/下创建php测试页


<?php
phpinfo();
?>
- 重启httpd服务

- 测试

- 使用mariadb的模板创建配置文件

cat /usr/share/mysql/my-medium.cnf > /etc/my.cnf
#注:提供的配置模板有my-small.cnf, my-medium.cnf, my-large.cnf, my-huge.cnf
#my-small.ini是为了小型数据库而设计的,内存 <= 64M
#my-medium.ini是为中等规模的数据库而设计的,内存 128M
#my-large.ini是为专用于一个SQL数据库的计算机而设计的,内存 512M
#my-huge.ini是为企业中的数据库而设计的,内存 1G-2G
#my-innodb-heavy-4G.cnf针对4G内存系统(主要运行只有InnoDB表的数据库)而设计,内存 4GB
- 启动Mariadb

- 检查监听端口是否开启

- 登录mysql并删除空账号,添加管理账号和密码






delete from mysql.user where user='';
update mysql.user set password=password('12345') where user='root';
grant all on *.* to 'root'@'%' identified by '12345';
flush privileges;
quit
- 重启mariadb服务

- 修改测试页,测试php与mariadb的连接


<?php
$link=mysqli_connect('192.168.10.121','root','12345');
if($link)
echo "^_^ ok ^_^";
else
echo "T_T not ok T_T";
?>
- 客户端测试

使用LAMP部署 discuz
- 创建discuz所使用的数据库并创建管理员,设置密码



mysql -u root -p
create database discuzdb;
grant all on discuzdb.* to 'discuzadmin'@'%' identified by '123456';
flush privileges;
quit
-
修改php主配置文件开启短格式支持


-
重启htpd服务

-
上传至服务器

-
将文件中的upload/复制到/var/www/html/目录下,重命名为discuz

-
修改目录权限

-
部署







-
后台管理登录界面


-
默认下访问/discuz/install能够直接进入该目录下

-
注意修改该目录的权限


安装phpMyadmin
- 安装软件

- 修改httpd下phpMyadmin相关配置,允许远端主机访问


注:apache2.4只需要修改两处Require 即可 apache2.2及以前的版本修改Allow form - 修改phpMyadmin配置


- 重启http服务,使配置生效

- 访问测试

- 输入Mariadb用户名密码登录就可以对数据库进行增删改操作

数据库密码重置
- 修改配置文件跳过密码验证


- 重启服务

- 以管理员身份进入数据库(密码空或输入任意字符)

- 设置密码

mysql -u root -p
update mysql.user set password=password('12345') where user='root';
flush privileges;
quit
#注:更改密码后记得将配置文件改回并重启
