如何用两台虚拟机搭建LAMP架构访问qq农场

发布于:2023-01-20 ⋅ 阅读:(11) ⋅ 点赞:(0) ⋅ 评论:(0)

一、准备事项:

1、准备两台干净的虚拟机,关闭防火墙,并已安装yum的base仓库和epel附加仓库,建议用阿里云仓库。

Last login: Fri Aug 12 17:22:26 2022
[root@localhost ~]# cd /etc/yum.repos.d
[root@localhost yum.repos.d]# ls
CentOS-Base.repo  epel.repo
[root@localhost yum.repos.d]#

2、清理yum仓库缓存,和重新加载缓存。

[root@mariadb-server ~]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: base epel extras updates
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
[root@mariadb-server ~]# rm -rf /etc/cache/yum/
[root@mariadb-server ~]# yum makecache fast

2、一台命名为apache-server,用来安装apache服务和php服务;另外一台命名为mariadb-server,安装mariadb数据库服务。

3、准备好qq农场数据包。

二、安装Apache、php服务

1、yum -y install httpd mariadb mariadb-server php php-fpm php-mysql php-gd gd

(备注:php:主包,php-fpm:php管理进程的包,php-mysql:php连接数据库的包,这三个为必须安装,其他插件根据情况安装)

2、启动Apache和php服务:systemctl satart httpd php-ftm    systmctl anable httpd php-ftm

3、删除apache启动欢迎页面(可选)

4、在/etc/httpd/conf.d下面创建QQ农场子目录:vim qqfarm.conf

5、编辑子配置文件

<VirtualHost *:80>
        Servername localhost
        DocumentRoot /qqfarm
</VirtualHost>
<Directory "/qqfarm">
        AllowOverride All
        Require all granted
</Directory>

6、创建访问目录:mkdir /qqfarm

7、修改php配置文件:vim /etc/php.ini,将short_open_tag= off改为short_open_tag=On(搜索第二个)

三、安装mariadb数据库服务

1、安装软件:yum -y install mariadb

2、启动mariadb服务:systemctl start mariadb

3、给数据库设置密码:mysqlsdmin -u root password "123"

4、进入数据库,创建QQ农场数据库,存放数据:mysql -u root -p123,

create database farm;(注意这里有分号),最后exit

[root@mariadb-server ~]# mysql -u root -p123
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 5.5.68-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database farm;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> exit

四、产品上线

1、在web服务端,上传QQ农场压缩包,解压,并把解压后目录复制到发布目录下。

anaconda-ks.cfg  farm-ucenter1.5.zip  upload
[root@web-server ~]# cp -r upload/* /qqfarm
[root@web-server ~]#

2、在web服务端,通过远程传输,将解压后的数据库文件复制给数据库服务端。

[root@web-server ~]# scp upload/qqfarm.sql 192.168.30.136:/root/
The authenticity of host '192.168.30.136 (192.168.30.136)' can't be established.
ECDSA key fingerprint is SHA256:T3R06luIjq+WtTjh1RJdtWrFLN6wjh1XrI5ulwb3Bhk.
ECDSA key fingerprint is MD5:2d:e4:62:13:f6:57:4c:e5:32:0f:6a:6c:ed:65:e1:e0.
Are you sure you want to continue connecting (yes/no)? yse
Please type 'yes' or 'no': yes
Warning: Permanently added '192.168.30.136' (ECDSA) to the list of known hosts.
root@192.168.30.136's password:
qqfarm.sql                                                            100% 3363     1.9MB/s   00:00

3、在数据库服务端,账号登陆并将传输的数据文件导入到新建的farm文件中

[root@mariadb-server ~]# mysql -u root -p123 farm < qqfarm.sql

4、允许web服务端登陆数据库,需要数据库更改授权,然后重新加载授权表,注意数据库登陆进去以后,命令结尾都要加上;

[root@mariadb-server ~]# mysql -u root -p123
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 7
Server version: 5.5.68-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> grant all on *.* to 'root'@'%' identified by '123';
Query OK, 0 rows affected (0.02 sec)

MariaDB [(none)]> flush privileges;

MariaDB [(none)]> exit
Bye
[root@mariadb-server ~]#

5、web服务器端重新启动

五、浏览器访问

1、在浏览器端输入服务端地址访问,根据提示修改权限

 2、根据提示输入相关内容,数据库服务器写数据库服务端地址

3、一路确认,安装flash插件,进入QQ农场。

部署安装完成。