将Windows上的ranzhi项目,完整地移植到Linux(CentOS)环境中


将Windows上的ranzhi项目,完整地移植到Linux(CentOS)环境中

*   明确环境要求:
    *   LAMP
        *   1\. L: Linux - CentOS
        *   2\. A: Apache
            *   CentOS系统自带 ( rpm -qi httpd )

                ![image](http://upload-images.jianshu.io/upload_images/10517060-c571617dda14c3a9.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

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

                ![image](http://upload-images.jianshu.io/upload_images/10517060-10189d8632e7910f.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

        *   3\. Mysql

            ![image](http://upload-images.jianshu.io/upload_images/10517060-e05fe15f24383147.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

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

                ![image](http://upload-images.jianshu.io/upload_images/10517060-5473752c3b2ae9f3.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

                *   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包

                        ![image](http://upload-images.jianshu.io/upload_images/10517060-8e7bbeb781228b49.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

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

                            ![image](http://upload-images.jianshu.io/upload_images/10517060-8e1d0e2c2acb9242.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

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

                            ![image](http://upload-images.jianshu.io/upload_images/10517060-58e2d93c04550491.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

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

                            ![image](http://upload-images.jianshu.io/upload_images/10517060-e0ee81647ec36661.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

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

                            ![image](http://upload-images.jianshu.io/upload_images/10517060-934cff80912d85e7.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

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

                                    ![image](http://upload-images.jianshu.io/upload_images/10517060-6091c4e8ed379c0c.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

                                    *   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,安装

                ![image](http://upload-images.jianshu.io/upload_images/10517060-7f4ad643f58835bb.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

                *   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

                ![image](http://upload-images.jianshu.io/upload_images/10517060-19a9f437e1a87478.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

                ![image](http://upload-images.jianshu.io/upload_images/10517060-f6639de57b21e98a.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

                ![image](http://upload-images.jianshu.io/upload_images/10517060-45ae98489d7bd561.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

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

                ![image](http://upload-images.jianshu.io/upload_images/10517060-ecfedfc5a9e5d6ac.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

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

                ![image](http://upload-images.jianshu.io/upload_images/10517060-0dc1885db48ad7ca.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

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

            ![image](http://upload-images.jianshu.io/upload_images/10517060-246c35d984328a2f.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

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

            ![image](http://upload-images.jianshu.io/upload_images/10517060-1e40bb03dea43ba1.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

            ![image](http://upload-images.jianshu.io/upload_images/10517060-47d0a4505d81878c.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

        *   2.3 给 ranzhi 改权限

            ![image](http://upload-images.jianshu.io/upload_images/10517060-5555668bcba26014.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

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

            ![image](http://upload-images.jianshu.io/upload_images/10517060-f8fd191960ef2b7c.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

            *   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

                ![image](http://upload-images.jianshu.io/upload_images/10517060-91a2ec4e0fda19b2.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

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

            ![image](http://upload-images.jianshu.io/upload_images/10517060-3af5d332fa9f316c.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

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

猜你喜欢

转载自blog.csdn.net/weixin_34095889/article/details/87227339