1、准备一台全新Linux虚拟机(我将使用CentOS7进行实验操作),并使用finalshell远程软件与虚拟机连接。
2、使用yum命令下载 lrzsz和vim安装包
yum -y install vim lrzsz
3、使用rz上传文件
rz
4、使用touch命令创建一个shell脚本
touch qqfarm.sh
5、使用vim 命令打开脚本编辑器
vim qqfarm.sh
6、开始编写脚本之前先关闭防火墙和SELinux。
systemctl stop firewalld
setenforce 0
7、使用yum命令下载httpd,php服务。
yum -y install httpd php php-mysql
8、下载完成后,启动httpd服务。
systemctl start httpd
9、将文件/etc/httpd/conf/httpd.conf中DirectoryIndex index.html 修改为 DirectoryIndex index.html index.php
sed -ri 's/DirectoryIndex index.html/DirectoryIndex index.html index.php/' /etc/httpd/conf/httpd.conf
10、重启httpd服务
systemctl restart httpd
11、安装mariadb数据库
yum -y install mariadb-server mariadb
12、启动数据库服务
systemctl start mariadb
13、使用yum 命令下载unzip
yum -y install unzip
14、解压文件
unzip qqfarm-ucenter1.5.zip
15、把解压出来的upload文件移动到/var/www/html/目录下
mv upload /var/www/html/
16、给文件授权
chmod -R 777 /var/www/html/upload/
17、给数据库改密码
mysqladmin -uroot password "123"
18、免交互创建数据库
mysql -uroot -p123 -e "create database qqfarm"
19、把数据导入数据库
mysql -uroot -p123 qqfarm < /var/www/html/upload/qqfarm.sql
20、将文件/etc/php.ini中的short_open_tag = Off修改为short_open_tag = On
sed -ri s'/short_open_tag = Off/short_open_tag = On/' /etc/php.ini
21、重启httpd服务
systemctl restart httpd
保存以上脚本运行没有报错的话,就完成部署。
22、使用浏览器进入192.168.197.151/upload(192.168.197.151为虚拟机服务器地址)
看到上面的界面一步一步完成安装即可。
脚本原码:
#!/bin/bash
systemctl stop firewalld
setenforce 0
yum -y install httpd php php-mysql unzip
systemctl start httpd
sed -ri 's/DirectoryIndex index.html/DirectoryIndex index.html index.php/' /etc/httpd/conf/httpd.conf
systemctl restart httpd
yum -y install mariadb-server mariadb
systemctl start mariadb
unzip farm-ucenter1.5.zip
mv upload /var/www/html/
chmod -R 777 /var/www/html/upload/
mysqladmin -uroot password "123"
mysql -uroot -p123 -e "create database qqfarm"
mysql -uroot -p123 qqfarm < /var/www/html/upload/qqfarm.sql
systemctl restart httpd