1、环境准备
此处使用两台虚拟机搭建测试平台,分别为:
Samba服务器:192.168.0.81,Centos7
Lamp服务器:192.168.0.83,Centos7
2、搭建samba服务
安装samba服务:
[root@localhost ~]# yum install samba -y
下载phpMyadmin:
[root@localhost ~]# wget https://files.phpmyadmin.net/phpMyAdmin/4.8.0.1/phpMyAdmin-4.8.0.1-all-languages.zip
解压缩phpMyadmin将phpMyadmin目录复制到/var/www/目录下并创建软链接pma:
[root@localhost ~]# unzip phpMyAdmin-4.8.0.1-all-languages.zip
[root@localhost ~]# cp -a phpMyAdmin-4.8.0.1-all-languages /var/www/
[root@localhost ~]# ln -sv /var/www/phpMyAdmin-4.8.0.1-all-languages/ /var/www/pma
"/var/www/pma" -> "/var/www/phpMyAdmin-4.8.0.1-all-languages/"
[root@localhost ~]# ll /var/www/
总用量 8
drwxr-xr-x. 2 root root 6 10月 20 2017 cgi-bin
drwxr-xr-x. 3 root root 16 5月 9 17:50 html
drwxr-xr-x. 12 root root 4096 4月 19 09:11 phpMyAdmin-4.8.0.1-all-languages
lrwxrwxrwx. 1 root root 42 5月 9 20:20 pma -> /var/www/phpMyAdmin-4.8.0.1-all-languages/
编辑/etc/samba/smb.conf文件:
[root@localhost ~]# vim /etc/samba/smb.conf
[pma]
comment= shared pma
path=/var/www/pma
writable=yes
[root@localhost ~]# testparm
创建samba用户:
[root@localhost ~]# useradd samba -s /sbin/nologin
[root@localhost ~]# smbpasswd -a samba
New SMB password:
Retype new SMB password:
启动smb服务:
[root@localhost ~]# systemctl start smb
[root@localhost ~]# ss -tnl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 50 *:139 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 50 *:445 *:*
LISTEN 0 25 *:514 *:*
LISTEN 0 50 :::139 :::* #监听端口已经启
LISTEN 0 32 :::21 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 50 :::445 :::* #监听端口已经启用
LISTEN 0 25 :::514 :::*
3、搭建Lamp服务器
安装mariadb服务:
[root@test ~]# yum install mariadb-server
安装httpd服务器:
[root@test ~]# yum install httpd -y
由于phpMyadmin要求的php版本至少在5.5以上,因此需要安装这以上的版本:
[root@test ~]# yum install epel-release
[root@test ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm #更新PHP的rpm源
[root@test ~]# yum install php56w php56w-mysql -y #安装php5.6版本
挂载samba共享的pma目录:
[root@test ~]# mkdir /var/www/pma
[root@test ~]# mount -t cifs //192.168.0.81/pma /var/www/pma -o username=samba,password=123456
编辑mariadb的/etc/my.cnf文件后启动mariadb服务并进行初始化加固:
[root@test ~]# vim /etc/my.cnf
[mysqld]
skip-name-resolve=ON #跳过mysql账号的名称解析
innodb-file-per-table=ON
[root@test ~]# systemctl start mariadb
[root@test ~]# mysql_secure_installation
编辑/etc/httpd/conf.d/pma.conf文件后启动httpd服务:
[root@test ~]# vim /etc/httpd/conf.d/pma.conf
<virtualhost *:80>
Servername www.a.com
Documentroot /var/www/pma
<Directory "/var/www/pma">
options none
allowoverride none
require all granted
</Directory>
</virtualhost>
[root@test ~]# httpd -t
Syntax OK
[root@test ~]# systemctl start http
编辑phpMyadmin的配置文件:
[root@test ~]# cp /var/www/pma/config.sample.inc.php /var/www/pma/config.inc.php
[root@test ~]# vim /var/www/pma/config.inc.php
$cfg['blowfish_secret'] = 'qwk123)@*@K897vhui4'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */ #添加相应的加固短语
$cfg['Servers'][$i]['host'] = '127.0.0.1'; #找到对应的选项,修改host值为对应的主机IP
登录页面测试访问:
phpMyadmin登录页面
输入本地数据库登录账号密码后成功登录
网友评论