将Windows上的ranzhi项目,完整地移植到Linux(C
2018-09-27 本文已影响0人
嫩牛_软件测试_笔记
将Windows上的ranzhi项目,完整地移植到Linux(CentOS)环境中
* 明确环境要求:
* LAMP
* 1\. L: Linux - CentOS
* 2\. A: Apache
* CentOS系统自带 ( rpm -qi httpd )

* 开启 Apache 服务器 ( service httpd start )

* 3\. Mysql

* CentOS自带的Mysql版本5.1,我们需要卸载5.1版本,安装5.7版本

* 3.1 卸载老版本Mysql
* yum remove mysql* -y
* yum list installed | grep mysql
* rm -fr /var/lib/mysql/ ( 删除旧的Mysql数据文件)
* 3.2 安装5.7新版本Mysql
* 3.2.1.进入[http://www.mysql.com](http://www.mysql.com)下载 RHEL 6 或 CentOS6版本,下载mysql57-community-release-el6-11.noarch.rpm, 使用rz命令,上传到Linux上,并且rpm方式安装该rpm包

* 3.2.2.安装 MySQL-Community-Server
* yum install mysql-community-server -y
* 3.2.3\. 启动Mysql服务
* service mysqld start

* 3.2.4\. 修改Mysql的 root@localhost 密码
* 3.2.4.1.查看Mysql的临时密码

* grep 'temporary password' /var/log/mysqld.log
* 3.2.4.2\. 使用刚才查看到的临时密码进入

* mysql -u root -p
* 3.2.4.3\. 修改数据库密码

* alter user 'root'@'localhost' identified by '123456';
* 有可能修改为‘123456’密码时报错,解决方法如下:

* set global validate_password_policy=0;
* set global validate_password_length=1;
* 3.2.4.4\. 创建测试用户并赋予权限
* 进入数据库
* mysql -u root -p
* 输入刚才修改的root密码 123456
* 创建测试用户
* create user 'tester'@'%' identified by '123456';
* 添加权限
* grant all privileges on *.* to tester@'%';
* 刷新权限
* flush privileges;
* 退出Mysql
* exit;
* 重启Mysql
* service mysqld restart
* 4\. 安装PHP
* 4.1\. 默认CentOS6.8版本没有安装PHP
* 可以通过命令 yum list installed | grep php 查看
* 如果有系统默认有安装PHP,则可以卸载:
* yum remove php* -y
* 4.2\. 准备PHP5.6的安装文件,一共2个,并上传到 Linux,安装

* epel-release-6-8.noarch.rpm & remi-release-6.rpm
* 4.3\. 添加依赖
* yum install -y --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof php-pdo php-mysql php-gd
* 4.4\. 重启Apache
* service httpd restart
* 然之数据移植及配置修改
* 1\. 将Windows上的 ranzhi 数据库迁移到 CentOS系统上
* 1.1\. SQLYog连接上Windows上的ranzhi数据库 和 CentOS系统上的Mysql
* 1.1.1 SQLYog连接XAMPP里的Mysql
* 这个大家都知道怎么连了吧?!
* 1.1.2 SQLYog连接CentOS上的Mysql



* 1.2\. 复制XAMPP里的 ranzhi 数据库到 CentOS 里的ranzhi数据库
* 1.2.1\. 先在CentOS的Mysql里新建个 ranzhi 数据库,并修改字符集格式为 utf8

* 1.2.2 复制XAMPP里的 ranzhi 数据库到 CentOS 里的ranzhi数据库

* 2\. 将Windows 下XAMPP里的ranzhi打包,上传到CentOS,修改ranzhi数据库配置,Apache配置等
* 2.1 打包XAMPP里的ranzhi文件夹

* 2.2 上传刚才打包的 ranzhi.zip 到CentOS下的 /var/www/html 目录下,并解压


* 2.3 给 ranzhi 改权限

* chmod -R 777 ranzhi
* 2.4 修改 ranzhi 配置文件

* vi /var/www/html/ranzhi/config/my.php,修改数据库的用户名和密码,主机
* 2.5 删除ranzhi移植的临时文件
* rm -rf /var/www/html/ranzhi/tmp
* 2.6 配置Apache
* 2.6.1 备份httpd.conf
* cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd_bak.conf
* 2.6.2 修改httpd.conf

* vi /etc/httpd/conf/httpd.conf
* :set nu
* 找到第 338行
* AllowOverride None → AllowOverride All
* 保存退出
* 2.6.3 重启Apache
* service httpd restart
* 2.7 浏览器中访问 ranzhi

* [http://192.168.1.30/ranzhi/www](http://192.168.1.30/ranzhi/www)
* 其中,192.168.1.30为我的 CentOS 系统的IP