虚拟机vm中centos7环境下安装9i软件服务端
<h3>一、vm安装centos7</h3>
<p>1 从官网下载镜像。如果有镜像直接复制镜像到电脑上</p>
<p>2 vm选择菜单 文件 -> 新建 -> 从光盘或映像中安装 点继续 -> 选择centos7的iso镜像 点继续
-> 点自定义配置
在设置页面 -> 点击处理器和内存 -> 设置内存大小。
在设置页面 -> 点击硬盘 -> 设置硬盘大小
在设置页面 -> 修改网络适配器 -> 在桥接模式网络连接中选择 自动检测 </p>
<p>设置完成后点击这个虚拟机 开机</p>
<p>3 进入安装centos7界面后
选择Install CentOS7 -> 回车</p>
<p>4 进入选择语言页面 选好语言 一般选English -> 点击Continue </p>
<p>5 然后SYSTEM下 点击 INSTALLATION DESTINATION -> 点击Done (注意:图标上的感叹号要消失)</p>
<p>6 点击Begin Installation</p>
<p>7 点击ROOTPASSWORD -> 输入两次密码后 -> 点击 Done</p>
<p>8 等进度条走完说明安装成功,点击Reboot </p>
<p>9 然后输入帐号: root 密码: 刚刚设置的密码 -> 登陆</p>
<p>10 编辑网络配置文件 ifcfg-ens33 文件名ens33不同电脑的可能会不一样</p>
<pre><code>cd /etc/sysconfig/network-scripts/
ls
vim ifcfg-ens33</code></pre>
<p>文件中
ONBOOT=no 改为ONBOOT=yes</p>
<pre><code>systemctl restart network.service</code></pre>
<p>查看本机ip</p>
<pre><code>ip addr </code></pre>
<p>以下示例中ip为192.168.3.252<br />
ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:46:a7:1f brd ff:ff:ff:ff:ff:ff
inet 192.168.3.252/24 brd 192.168.3.255 scope global dynamic ens33
valid_lft 604020sec preferred_lft 604020sec
inet6 fe80::43bf:ad7a:d535:1293/64 scope link
valid_lft forever preferred_lft forever</p>
<pre><code>reboot</code></pre>
<h3>二、 软件环境搭建</h3>
<p>1 用xshall等登陆软件输入ip 帐号密码信息登陆服务器
设置时区</p>
<pre><code>timedatectl set-timezone Asia/Shanghai</code></pre>
<p>2 数据库postgresql 10 安装</p>
<pre><code>yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-1.noarch.rpm
yum -y install postgresql10 postgresql10-server
/usr/pgsql-10/bin/postgresql-10-setup initdb
systemctl enable postgresql-10
systemctl start postgresql-10</code></pre>
<p>编辑# pg_hba.conf文件</p>
<pre><code>vi /var/lib/pgsql/10/data/pg_hba.conf</code></pre>
<p>修改ipv4下host all all 127.0.0.1/32 ident配置为以下内容 然后按:q退出</p>
<pre><code>#IPv4 local connections:
host all all 0.0.0.0/0 md5</code></pre>
<p>编辑# postgresql.conf 文件。</p>
<pre><code>vi /var/lib/pgsql/10/data/postgresql.conf</code></pre>
<p>将 #listen_addresses = ‘localhost’ 修改为 </p>
<pre><code>listen_addresses='*'</code></pre>
<p>重启服务</p>
<pre><code>systemctl restart postgresql-10</code></pre>
<p>设置为开机启动</p>
<pre><code>systemctl enable postgresql-10.service</code></pre>
<p>启动 重启 停止服务操作服务命令
systemctl start postgresql-10 #启动服务
systemctl restart postgresql-10 #重启服务
systemctl stop postgresql-10 #停止服务
为了数据库存在/data目录下,所以需要创建表空间
创建表空间
在/data中创建zgsplace文件夹,赋予用户postgres用户写入和读取权限</p>
<pre><code>mkdir -p /data/zgsplace
chown postgres:postgres /data/zgsplace/</code></pre>
<p>重启服务</p>
<pre><code>systemctl restart postgresql-10 </code></pre>
<p>然后用postgres帐号登陆数据库修改访问密码</p>
<pre><code>su postgres
psql
ALTER USER postgres PASSWORD 'bearsoft';
CREATE TABLESPACE zgsplace LOCATION '/data/zgsplace';
</code></pre>
<p>退出psql</p>
<pre><code>\q </code></pre>
<pre><code>exit</code></pre>
<p>systemctl restart postgresql-10 </p>
<p>3 Apache 安装 </p>
<pre><code>yum -y install httpd</code></pre>
<p>安装成功后,默认情况下,是禁止外部IP访问的,需要进行设置</p>
<pre><code>vi /etc/httpd/conf/httpd.conf</code></pre>
<p><Directory />
AllowOverride none
Require all denied
</Directory >
修改为:</p>
<pre><code>&lt;Directory /&gt;
AllowOverride none
Require all granted
&lt;/Directory &gt;</code></pre>
<p>启动apache</p>
<pre><code>systemctl start httpd.service</code></pre>
<p>设置开机启动</p>
<pre><code>systemctl enable httpd.service</code></pre>
<p>备注: apache常用命令
systemctl start httpd.service //启动
systemctl stop httpd.service //停止
systemctl status httpd.service //查看状态
systemctl restart httpd.service //重启
systemctl enable httpd.service //开机启动</p>
<p>4 PHP7 安装
安装epel-release通过命令:</p>
<pre><code>yum -y install epel-release</code></pre>
<p>安装PHP7源 再次运行如下命令:</p>
<pre><code>rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm</code></pre>
<p>成功获取PHP7的yum源,然后再执行:</p>
<pre><code>yum -y install php70w php70w-pgsql php70w-mbstring php70w-pdo_dblib php70w-pdo</code></pre>
<p>修改php.ini中的默认上传文件的大小为8M</p>
<pre><code>vi /etc/php.ini</code></pre>
<p>修改php配置为</p>
<pre><code>
date.timezone = &quot;Asia/Shanghai&quot;; ##时区一定要设置。 重要。。。。
upload_max_filesize = 32m ; #即允许上传文件大小的最大值。默认为2M
post_max_size = 32m ;#指通过表单POST给PHP的所能接收的最大值,包括表单里的所有值。默认为8M
max_execution_time = 600 ;#每个PHP页面运行的最大时间值(秒),默认30秒
max_input_time = 600 ;#每个PHP页面接收数据所需的最大时间,默认60秒</code></pre>
<p>重启 APACHE</p>
<pre><code>systemctl restart httpd
</code></pre>
<p>5 关闭防火墙</p>
<pre><code> systemctl stop firewalld.service</code></pre>
<p>取消开机启动</p>
<pre><code> systemctl disable firewalld.service</code></pre>
<p>编辑关闭防火墙
vi /etc/sysconfig/selinux
将#SELINUXTYPE=targeted #注释掉
取消开机启动
SELINUX=enforcing 修改为disabled</p>
<h3>三、数据库</h3>
<p>1 新建两个数据库 一个为租户库yanshi 一个为系统库maindb
打开navicat -> 点击连接 -> 点击PostgresSql -> 输入连接名(自定义名称方便记忆) 服务器ip 数据库帐号 端口号 密码 -> 点击确定 </p>
<p>右键点击刚新建的连接 -> 新建数据库 -> 输入数据库名称maindb 拥有者postgres 编码 UTF8 表空间选择zgsplace -> 点击确定</p>
<p>右键点击刚新建的连接 -> 新建数据库 -> 输入数据库名称yanshi 拥有者postgres 编码 UTF8 表空间选择zgsplace -> 点击确定</p>
<p>2 备份maindb的表结构和数据
ssh root@eb3.9isoft.com
输入服务器root密码
进入pg的目录</p>
<pre><code>cd /data/</code></pre>
<p>切换pg用户</p>
<pre><code>su postgres</code></pre>
<p>备份maindb数据</p>
<pre><code>pg_dump maindb &gt; /data/main20180129.sql</code></pre>
<p>用winscp下载下来main20180129.sql
上传到centos7的data目录下</p>
<p>然后登陆centos7
切换pg用户</p>
<pre><code>su postgres</code></pre>
<p>导入manidb数据到数据库</p>
<pre><code>psql -U postgres -d maindb -f /data/main20180129.sql</code></pre>
<p>连接navicat 连接这个演示的centos7修改系统库配置
删除g_cust表 租户id > 10000 的数据
删除g_cust_cert表 租户custid > 10000 的数据
删除g_cust_db表 租户custid > 10000 的数据
删除g_cust_ver表 租户custid > 10000 的数据</p>
<p>示例 本次租户为中国黄金chinahuangjin 的custid为558
修改g_cust_db表 custid为558这行的wt_ip为127.0.0.1 wt_db字段为 yanshi 修改rd_db字段为 yanshi</p>
<p>修改g_cust_ver表 custid为558这行的sev_url1字段为192.168.3.252:80 (此IP为p这次安装centos7的ip)</p>
<p>3 备份要演示数据库的表结构和数据(比如这次要导出的是中国黄金数据库chinahuangjin)
ssh root@47.96.29.35
输入服务器root密码
进入pg的目录</p>
<pre><code>cd /data/</code></pre>
<p>切换pg用户</p>
<pre><code>su postgres</code></pre>
<p>备份maindb数据</p>
<pre><code>pg_dump chinahuangjin &gt; /data/back/yanshi20180129.sql</code></pre>
<p>用winscp下载下来yanshi20180129.sql
上传到centos7的data目录下</p>
<p>然后登陆centos7
切换pg用户</p>
<pre><code>su postgres</code></pre>
<p>导入yanshi数据到数据库</p>
<pre><code>psql -U postgres -d yanshi -f /data/yanshi20180129.sql</code></pre>
<h3>四、php代码部署</h3>
<p>2 配置eb项目</p>
<p>登陆winscp
新建目录 /data/www/html/</p>
<p>下载用来演示的php代码例如:现在演示的代码为 47.96.29.35服务器下/data/www/html/chinagold.9isoft.com
下载代码</p>
<p>用上传软件(winscp等输件)上传2.0版本php代码的到服务器/data/www/html/目录。
最终上传后的项目目录为
/data/www/html/upyuan/
/data/www/html/shopos/</p>
<p>修改数据库配置文件 /data/www/html/upyuan/common/pg_inc.php(以后可能会调整);</p>
<pre><code>define(&quot;connstring_write&quot;, &quot;host=127.0.0.1 port=5432 dbname=yanshi user=postgres password=bearsoft&quot;);
define(&quot;connstring_read&quot;, connstring_write);
define(&quot;connstring_report&quot;, connstring_write);</code></pre>
<p>修改数据库配置文件 /data/www/html/shopos/common/pg_inc.php中(以后可能会调整);</p>
<pre><code>define(&quot;connstring_write&quot;, &quot;host=127.0.0.1 port=5432 dbname=yanshi user=postgres password=bearsoft&quot;);
define(&quot;connstring_read&quot;, connstring_write);
define(&quot;connstring_report&quot;, connstring_write);</code></pre>
<p>虚拟目录的建立
在 /etc/httpd/conf.d/ 下面建立一个 vhost.conf 文件来配置虚拟主机。</p>
<pre><code>&lt;VirtualHost *:80&gt;
#绑定的主域
ServerName bat.9isoft.com
#绑定的子域名
#ServerAlias www.test.com
#网站主目录
DocumentRoot /data/www/html/
#日志配置
#ErrorLog /home/web_log/bat.9isoft.com_error.log
#CustomLog /home/web_log/bat.9isoft.com_access.log common
#ServerSignature Off
&lt;/VirtualHost&gt;
#测试一的配置
&lt;Directory &quot;/data/www/html/&quot;&gt;
Options Indexes FollowSymLinks
#Options FollowSymLinks 不允许通过目录访问文件列表
AllowOverride All
Require all granted
&lt;/Directory&gt;</code></pre>
<p>用winscp登陆系统库的后端服务器下载系统库的php代码
注意这几个目录不要 9internet log shopos shoposback upyuan 这几个目录不要下载
(也可以去sftp服务器下载 sftp/eb_php_sql/appphp.zip)</p>
<p>用上传软件(winscp等输件)上传2.0版本php代码的到服务器/data/www/html/目录。
最终上传后的项目目录为
/data/www/html/common
/data/www/html/origin
/data/www/html/phprs
....
....</p>
<p>修改数据库配置文件/data/www/html/common/pg_inc.php
define("connstring_main", "host=127.0.0.1 port=5432 dbname=maindb user=postgres password=bearsoft");</p>
<p>给予目录777权限;或者apache用户写这个文件夹权限;</p>
<pre><code>chown apache.apache – R /data/www/html/</code></pre>
<pre><code>systemctl restart httpd
</code></pre>
<hr />
<h3>五、 修改EB配置</h3>
<p>修改eb.ini中的ip为
192.168.3.252</p>