连锁当家运维手册


阿里云centos7系统中安装连锁当家软件的步骤2018-01-22

<p>阿里云centos7系统中安装连锁当家软件的步骤 一 用xshall等登陆软件输入ip 帐号密码信息登陆服务器 设置时区</p> <pre><code>timedatectl set-timezone Asia/Shanghai</code></pre> <p>二 数据库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 install postgresql10 yum install 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> <p>三 Apache 安装 默认情况下,选择Y,进行安装</p> <pre><code>yum install httpd</code></pre> <p>安装成功后,默认情况下,是禁止外部IP访问的,需要进行设置</p> <pre><code>vi /etc/httpd/conf/httpd.conf</code></pre> <pre><code>&amp;lt;Directory /&amp;gt; AllowOverride none Require all denied &amp;lt;/Directory &amp;gt; 修改为: &amp;lt;Directory /&amp;gt; AllowOverride none Require all granted &amp;lt;/Directory &amp;gt;</code></pre> <p>systemctl start httpd.service //启动 systemctl stop httpd.service //停止 systemctl status httpd.service //查看状态 systemctl restart httpd.service //重启 systemctl enable httpd.service //开机启动</p> <p>用上传软件(winscp,xshall …..其中之一)上传2.0版本php代码的到服务器/var/www/html/目录 (<strong>目录可以自定义如果有挂载盘挂在data目录下建议把本文所有的/var/www/html/换成 /data/www/html</strong>) 示例给客户配置的域名是:xxx.upyuan.cn 文件夹同一放在2.0版本php代码upyuan目录下; 需要手工在2.0版本php代码下建立upyuan/log文件夹,upyuan/uploadimg文件夹,;</p> <pre><code>mkdir -p /var/www/html/xxx.upyuan.cn/upyuan/uploadimg mkdir -p /var/www/html/xxx.upyuan.cn/upyuan/log</code></pre> <p>并且给予777权限;或者apache用户写这个文件夹权限;</p> <pre><code>chown apache.apache – R /var/www/html/xxx.upyuan.cn</code></pre> <p>数据库配置文件在/var/www/html/xxx.upyuan.cn/common/pg_inc.php中(以后可能会调整); 图片缓存配置放在ossconfig.php中(以后会调整)OSS_TEST_BUCKET 默认是bearsoft;以后会根据不同的用户使用不同的oss子目录</p> <p>虚拟目录的建立 在 /etc/httpd/conf.d/ 下面建立一个 vhost.conf 文件来配置虚拟主机。</p> <pre><code>&amp;lt;VirtualHost *:80&amp;gt; #绑定的主域 ServerName xxx.upyuan.cn #绑定的子域名 #ServerAlias www.test.com #网站主目录 DocumentRoot /var/www/html/xxx.upyuan.cn/ #日志配置 #ErrorLog /home/web_log/xxx.upyuan.cn_error.log #CustomLog /home/web_log/xxx.upyuan.cn_access.log common #ServerSignature Off &amp;lt;/VirtualHost&amp;gt; #测试一的配置 &amp;lt;Directory &amp;quot;/var/www/html/xxx.upyuan.cn/&amp;quot;&amp;gt; Options Indexes FollowSymLinks #Options FollowSymLinks 不允许通过目录访问文件列表 AllowOverride All Require all granted &amp;lt;/Directory&amp;gt;</code></pre> <p>四 PHP7 安装 1.安装epel-release 通过命令:</p> <pre><code>yum -y install epel-release</code></pre> <p>2.安装PHP7 终端再次运行如下命令:</p> <pre><code>rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm</code></pre> <p>成功获取PHP7的yum源,然后再执行:</p> <pre><code>yum install php70w php70w-pgsql php70w-mbstring php70w-pdo_dblib php70w-pdo -y</code></pre> <p>修改php.ini中的默认上传文件的大小为8M</p> <pre><code>vi /etc/php.ini</code></pre> <pre><code>date.timezone = &amp;quot;Asia/Shanghai&amp;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>修改php session过期时间为1天以上; 修改三行如下: 1、session.use_cookies=1 #把这个的值设置为1,利用cookie来传递sessionid 2、session.cookie_lifetime=99999999 #这个代表SessionID在客户端Cookie储存的时间,默认是0,代表浏览器一关闭SessionID就作废…… 就是因为这个所以PHP的session不能永久使用! 那么我们把它设置为一个我们认为很大的数字吧,999999999怎么样,可以的!就这样。 3、session.gc_maxlifetime=99999999 #这个是Session数据在服务器端储存的时间,如果超过这个时间,那么Session数据就自动删除! 那么我们也把它设置为99999999。当然也可以了~ 重启 APACHE</p> <pre><code>systemctl restart httpd </code></pre> <p>五 centos7关闭防火墙 停止firewall</p> <pre><code>systemctl stop firewalld.service</code></pre> <p>禁止firewall开机启动</p> <pre><code>systemctl disable firewalld.service </code></pre> <p>编辑关闭防火墙</p> <pre><code>vi /etc/sysconfig/selinux</code></pre> <p>去掉前面的 SELINUXTYPE=targeted 用#注释掉 改为效果如下</p> <pre><code>#SELINUXTYPE=targeted #注释掉 </code></pre> <p>SELINUX=enforcing#修改为disabled效果如下</p> <pre><code>SELINUX=disabled </code></pre> <p>关闭SELinux,重启永久生效</p> <p>======================================</p> <h1>下面内容待修正</h1> <p>附加内容:(非必选) 配置https非必选 (微信小程序需要配置https协议)</p> <pre><code>yum -y install mod_ssl vi /etc/httpd/conf.d/ssl.conf</code></pre> <p>去掉 # DocumentRoot &quot;/var/www/html&quot; 前面的# 变成为此状态 </p> <pre><code>DocumentRoot &amp;quot;/var/www/html&amp;quot;</code></pre> <p>从阿里云管理后台中证书管理中生成证书文件</p> <ol> <li>例如证书文件是214094441970598.pem,包含两段内容,请不要删除任何一段内容。</li> <li>如果是证书系统创建的CSR,还包含:证书私钥文件214094441970598.key、证书公钥文件public.pem、证书链文件chain.pem </li> </ol> <p>( 1 ) 在Apache的安装目录下创建cert目录,并且将下载的全部文件上传到cert目录中。 ( 2 ) 打开 apache 安装目录下 conf 目录中的 httpd.conf 文件,找到以下内容并去掉“#”: (如果找不到请确认是否编译过 openssl 插件)</p> <pre><code>#LoadModule ssl_module modules/mod_ssl.so #Include conf/extra/httpd-ssl.conf</code></pre> <p>改后的效果为</p> <pre><code>LoadModule ssl_module modules/mod_ssl.so Include conf/extra/httpd-ssl.conf</code></pre> <p>( 3 ) 打开 apache 安装目录下 conf/extra/httpd-ssl.conf 文件 (也可能是conf.d/ssl.conf,与操作系统及安装方式有关), 在配置文件中查找以下配置语句: 添加 SSL 协议支持协议,去掉不安全的协议 SSLProtocol TLSv1 TLSv1.1 TLSv1.2# 修改加密套件如下 vi conf/extra/httpd-ssl.conf </p> <pre><code>SSLCipherSuite ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4 # 证书公钥配置 SSLCertificateFile cert/public.pem # 证书私钥配置 SSLCertificateKeyFile cert/214094441970598.key # 证书链配置,如果该属性开头有 ‘#’字符,请删除掉 SSLCertificateChainFile cert/chain.pem</code></pre> <p>( 4 ) 重启 Apache。</p> <pre><code>systemctl restart httpd</code></pre> <p>( 5 ) 通过 https 方式访问您的站点,测试站点证书的安装配置 微信支持,且只支持ssl_protocols TLSv1 TLSv1.1 TLSv1.2;所以,你需要把SSL V2,SSL V3这些协议都删掉 加密方式ssl_ciphers AES128+EECDH:AES128+EDH:!aNULL;</p> <p>修改/etc/httpd/conf.d/ssl.conf</p> <pre><code>vi /etc/httpd/conf.d/ssl.conf</code></pre> <pre><code>NameVirtualHost 121.41.17.128:443 &amp;lt;VirtualHost 121.41.17.128:443&amp;gt; ServerAdmin webmaster@hoge.com DocumentRoot “/var/www/html/test1” ServerName test1.upyuan.com #SSL Engine Switch: #Enable/Disable SSL for this virtual host. SSLEngine on # Server Private Key: # If the key is not combined with the certificate, use this # directive to point at the key file. Keep in mind that if # you’ve both a RSA and a DSA private key you can configure # both in parallel (to also allow the use of DSA ciphers, etc.) SSLCertificateFile /etc/pki/tls/certs/localhost.crt SSLCertificateKeyFile /etc/pki/tls/private/localhost.key &amp;lt;Directory &amp;quot;/var/www/html/test1&amp;quot;&amp;gt; Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all &amp;lt;/Directory&amp;gt; &amp;lt;/VirtualHost&amp;gt; </code></pre> <p>如果有多个网站网录 重复这个步骤多次</p> <p>要在虚拟目录中把配置重复写一遍;举例;</p> <pre><code>NameVirtualHost 121.41.17.128:443 &amp;lt;VirtualHost 121.41.17.128:443&amp;gt; ServerAdmin webmaster@hoge.com DocumentRoot “/var/www/html/eb3.9isoft.com” ServerName eb3.9isoft.com SSLEngine on SSLProtocol TLSv1 TLSv1.1 TLSv1.2 SSLCipherSuite ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4 SSLCertificateFile cert/public.pem SSLCertificateKeyFile cert/214094441970598.key SSLCertificateChainFile cert/chain.pem &amp;lt;/VirtualHost&amp;gt;</code></pre> <p>如果有多个网站网录 重复这个步骤多次</p>

页面列表

ITEM_HTML