麒麟V10离线安装Laravel环境

551 阅读11分钟

#0 系统配置相关

0.1 修改IP地址

ls -al /etc/sysconfig/network-scripts/
vi /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
#BOOTPROTO=dhcp
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=2fb1257c-c562-445d-bd37-b89987db582c
DEVICE=ens33
#ONBOOT=no
ONBOOT=yes
IPADDR=192.168.40.111
GATEWAY=192.168.40.1
NETMASK=255.255.255.0
DNS1=223.5.5.5
DNS2=114.114.114.114
#重启
nmcli c reload

#1 安装nginx

新建nginx用户和组

## 可不用此步骤:直接用系统用户作为user
[top@localhost html]$ sudo groupadd nginx
[top@localhost html]$ sudo useradd nginx -g nginx -s /sbin/nologin -M

安装

下载地址

# 安装依赖
sudo yum install pcre-devel

# 安装文件 nginx-1.20.2.tar.gz
mkdir nginx
# 解压
tar -zxvf nginx-1.20.2.tar.gz -C nginx
cd nginx/nginx-1.20.2/
#./configure --with-user=nginx --with-group=nginx
./configure
sudo make && sudo make install

./configure结果

Configuration summary
  + using system PCRE library
  + OpenSSL library is not used
  + using system zlib library

  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx modules path: "/usr/local/nginx/modules"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

防火墙开放80端口

sudo firewall-cmd --zone=public --list-all                          # 查看开放的端口
sudo firewall-cmd --zone=public --add-port=80/tcp --permanent       # 永久开放80端口
sudo firewall-cmd --reload                                          # 重新加载

firewalld 防火墙错误

# err: Firewall is not running
# 查找是否有安装包
rpm -qa firewalld
# 安装
sudo yum install firewalld
# 查状态
systemctl status firewalld
# 重启
sudo systemctl restart firewalld

nginx命令

# 启动nginx 
/usr/local/nginx/sbin/nginx 
# 立即停止Nginx服务 
/usr/local/nginx/sbin/nginx -s stop 
# 完成当前任务后停止 
/usr/local/nginx/sbin/nginx -s quit

制作服务,开机启动

/etc/systemd/system/路径下创建nginx.service文件

cd /etc/systemd/system/ 
sudo vim nginx.service

写入如下内容

[Unit]
Description=nginx - high performance web server
After=nginx.service
[Service]

Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop
Execenable=/usr/local/nginx/sbin/nginx

[Install]
WantedBy=multi-user.target

保存并退出

nginx命令

# 设置开机启动
sudo systemctl enable nginx

# 取消开机自启动
#sudo systemctl disable nginx

# 查看服务当前状态
sudo systemctl status nginx

# 启动nginx服务
sudo systemctl start nginx

# 停止nginx服务
sudo systemctl stop nginx

# 重启nginx服务
sudo systemctl restart nginx

其他设置

# 设置nginx文件夹权限
sudo chmod 777 /usr/local/nginx -R
# 查看nginx运行用户 
ps -ef | grep nginx
# 在conf/nginx.conf 修改user
# user top;

#2 安装php8

先安装需要的类库

## libmcrypt-devel 找不到
sudo yum -y install libxml2 libxml2-devel curl-devel libjpeg-devel libpng-devel freetype-devel  sqlite-devel oniguruma-devel openssl-devel autoconf

sudo yum install -y autoconf

安装

下载地址

cd ~/tools
tar zxvf php-8.1.5.tar.gz
cd php-8.1.5/
# configure命令
 ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --enable-json --with-fpm-user=www --with-fpm-group=www --with-mysqli --enable-pdo   --with-pdo-mysql --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl-dir=/usr/bin/curl --enable-mbregex --enable-mbstring --enable-ftp --with-gd --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-dom --enable-soap --enable-pcre --without-pear --with-gettext --enable-fileinfo --enable-maintainer-zts
./configure --prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--enable-fpm \
--enable-json \
--with-fpm-user=www \
--with-fpm-group=www \
--with-mysqli \
--enable-pdo   \
--with-pdo-mysql \
--with-iconv-dir \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl-dir=/usr/bin/curl \
--enable-mbregex \
--enable-mbstring \
--enable-ftp \
--enable-gd \
--with-external-gd \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-dom \
--enable-soap \
--enable-pcre \
--without-pear \
--with-gettext \
--enable-fileinfo \
--enable-maintainer-zts
# 安装命令
sudo make && sudo make install

# 设置权限
sudo chmod 777 /usr/local/php -R

重新编译自来的php插件

tar zxvf  php-8.0.18.tar.gz
cd php-8.0.18/ext/exif/
phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install

后台安装命令

# 后台安装
nohup sudo make &
# 查看后台运行的任务列表
jobs -l

生成php配置文件

[top@localhost php-8.1.5]$ cp php.ini-production /usr/local/php/etc/php.ini

生成www配置文件

[top@localhost php-8.1.5]$ cd /usr/local/php/etc/php-fpm.d/
[top@localhost php-fpm.d]$ cp www.conf.default www.conf

生成php-fpm配置文件

[top@localhost php-fpm.d]$ cd /usr/local/php/etc/
[top@localhost etc]$ cp php-fpm.conf.default  php-fpm.conf

生成php-fpm服务启动文件

sudo mkdir /usr/local/php/daemon
[top@localhost fpm]$ sudo cp /home/top/tools/php8/php-8.1.5/sapi/fpm/init.d.php-fpm /usr/local/php/daemon/php-fpm
# 设置权限
sudo chmod 777 /usr/local/php -R
[top@localhost fpm]$ sudo chmod 740 /usr/local/php/daemon/php-fpm

配置开机启动php-fpm

sudo vim /etc/rc.local

添加以下内容

# 开机启动php-fpm
/usr/local/php/daemon/php-fpm

添加环境变量

sudo vim /etc/profile

加入以下内容

# php加入环境变量
export PATH=$PATH:/usr/local/php/bin
# 刷新配置
source /etc/profile

测试启动php-fpm

[top@localhost local]$ /usr/local/php/daemon/php-fpm start
Starting php-fpm [30-Apr-2022 19:27:33] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
[30-Apr-2022 19:27:33] NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root
 done

#3 补安装php扩展

先安装autoconf

sudo yum install -y autoconf

安装php-gd扩展

安装zlib

# 下载地址:wget http://www.zlib.net/zlib-1.2.12.tar.gz
tar zxvf zlib-1.2.12.tar.gz
cd zlib-1.2.12
./configure --prefix=/usr/local/lib/zlib
sudo make && sudo make install

安装libpng

# 下载地址:wget http://prdownloads.sourceforge.net/libpng/libpng-1.6.37.tar.gz
tar zxvf libpng-1.6.37.tar.gz
cd libpng-1.6.37
./configure --prefix=/usr/local/lib/libpng
sudo make && sudo make install

安装 jpegsrc

# 下载地址:wget http://www.ijg.org/files/jpegsrc.v9e.tar.gz
tar zxvf jpegsrc.v9e.tar.gz
cd jpeg-9d
./configure --prefix=/usr/local/lib/libjpeg --enable-shared
sudo make && sudo make install

安装 freetype

# 下载地址:wget https://mirror.yongbok.net/nongnu/freetype/freetype-2.12.0.tar.gz
tar zxvf freetype-2.12.0.tar.gz
cd freetype-2.12.0
./configure --prefix=/usr/local/lib/freetype
sudo make && sudo make install

安装 GD 库扩展

configure 语句和以前略有不同,没有 with-zlib-dir 和 with-png-dir,取而代之是–with-libdir,需要指定到安装 libpng 和 zlib 的目录,with-jpeg-dir 和 with-freetype-dir 也改为 with-jpeg 和 with-freetype

  1. 进入 php source 目录下 ext 下的 gd 目录下\
  2. 执行 phpize\
  3. 执行 configure 与 make\
  4. 在 php.ini 中加入 gd.so\
  5. 重启 php 进程\

我的 php source~/tools/php8/php-8.1.5 php 安装目录在/usr/local/php

[top@localhost gd]$ cd /home/top/tools/php8/php-8.1.5/ext/gd/
phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-libdir=/usr/local/lib --with-freetype=/usr/local/lib/freetype --with-jpeg=/usr/local/lib/libjpeg
make && make install
# sudo find / -name "gd.so"
# /usr/local/php/lib/php/extensions/no-debug-non-zts-20210902/gd.so
echo extension=gd.so >> /usr/local/php/etc/php.ini
/usr/local/php/daemon/php-fpm reload
## 或者重启
/usr/local/php/daemon/php-fpm restart

#4 部署laravel

## 设置文件夹以及文件权限
[top@localhost www]$ sudo find /var/www/html/ -type d -exec chmod 2775 {} \;
[top@localhost www]$ sudo find /var/www/html/ -type f -exec chmod 664 {} \;
[top@localhost www]$ cd html/
[top@localhost html]$ chmod -R 777 storage
[top@localhost html]$ chmod -R 777 bootstrap/cache/
[top@localhost conf]$ sudo chown nginx:nginx -R /var/www/html/
[top@localhost nginx]$ vim conf/nginx.conf
#user  nobody;
#user nginx nginx;
# 直接用系统用户,不然文件上传后有权限问题
user top;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;
        #access_log  logs/host.access.log  main;

        root /var/www/html/public;
        add_header X-Frame-Options "SAMEORIGIN";
        add_header X-XSS-Protection "1; mode=block";
        add_header X-Content-Type-Options "nosniff";
        index index.html index.htm index.php;

        charset utf-8;

        # 重導所有請求至 index.php
        location / {
            try_files $uri $uri/ /index.php?$query_string;
        }

        location = /favicon.ico { access_log off; log_not_found off; }
        location = /robots.txt  { access_log off; log_not_found off; }

        error_page 404 /index.php;

        location ~ \.php$ {
            root           /var/www/html/public;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }


        location ~ /\.(?!well-known).* {
            deny all;
        }
        #location / {
        #    root   html;
        #    index  index.html index.htm;
        #}

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        #error_page   500 502 503 504  /50x.html;
        #location = /50x.html {
        #    root   html;
        #}

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}                                            

#5 安装composer

#download
#https://getcomposer.org/download/
#ftp传到~/tools
cd ~/tools/
[top@localhost tools]$ sudo mv composer.phar  /usr/local/bin/composer
[top@localhost local]$ sudo ln -s /usr/local/php/bin/php /usr/local/bin/php
[top@localhost tools]$ sudo chmod 755 /usr/local/bin/composer

#6 卸载php8.1并且重装php8.0

ERROR: unable to bind listening [socket] for address '127.0.0.1:9000': Address already in use

# 1查看是否php-fpm 处于开启状态,服务器并未杀死php-fpm的进程。
netstat -lntup | grep 9000
# 2 停止原来php-fpm的进程,重启开启
[root@localhost ~]# killall php-fpm 
[root@localhost ~]# /etc/init.d/php-fpm start 
Starting php-fpm done

Starting php-fpm [07-May-2022 16:40:32] ERROR: [pool www] cannot get uid for user 'www' [07-May-2022 16:40:32] ERROR: FPM initialization failed failed

[top@localhost etc]$ vim /usr/local/php/etc/php-fpm.d/www.conf
[top@localhost etc]$ sudo /usr/local/php/daemon/php-fpm start

usergroup更改为当前系统用户即可

; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
;       will be used.
;user = www
user = top
;group = www
group = top

#7 安装phpredis

# 下载 https://github.com/phpredis/phpredis/tags
# 解压
tar -zxvf phpredis-5.3.7.tar.gz
cd phpredis-5.3.7/
phpize 
./configure --with-php-config=/usr/local/php/bin/php-config
sudo make && sudo make install
echo extension=redis.so >> /usr/local/php/etc/php.ini 
/usr/local/php/daemon/php-fpm reload 
## 或者重启 
/usr/local/php/daemon/php-fpm restart

#8 安装wkhtmltopdf

# 1、下载 
# https://wkhtmltopdf.org/downloads.html
# https://github.com/wkhtmltopdf/wkhtmltopdf/releases/

# 2、在外网环境CentOS下载依赖rpm安装包
[top@localhost wkhtmltopdf]$ sudo yum install --downloadonly --downloaddir=/home/top/tools/wkhtmltopdf/ fontconfig libX11 libXext libXrender libjpeg libpng xorg-x11-fonts-75dpi xorg-x11-fonts-Type1

# 第二步可以直接尝试安装
# sudo yum install fontconfig libX11 libXext libXrender libjpeg libpng xorg-x11-fonts-75dpi xorg-x11-fonts-Type1

# 3、将wkhtmltopdf rpm安装包与依赖rpm安装包上传至内网环境,分开不同的目录

# 4、批量安装依赖rpm安装包
cd 依赖包文件夹
[top@localhost wkhtmltopdf]$ sudo rpm -Uvh --force --nodeps *rpm
cd wkhtmltopdf文件夹
[top@localhost wkhtmltopdf]$ sudo rpm -ivh wkhtmltox-0.12.6-1.centos8.x86_64.rpm

# 5、查看安装目录
whereis wkhtmltopdf

# 6、修改.env 加入如下信息
WKHTML_PDF_BINARY=/usr/local/bin/wkhtmltopdf

#9 安装字体

# 1、从windows  C:\Windows\Fonts 拷贝需要安装的字体打包成fonts.zip
# 2、建立一个专门放中文字体的文件夹
[top@localhost fonts]$ sudo mkdir /usr/share/fonts/zh
# 3、解压拷贝并直接覆盖
[top@localhost fonts]$ sudo unzip -o fonts.zip -d /usr/share/fonts/zh
# 或者解压后拷贝
[top@localhost fonts]$ sudo mv fonts/* /usr/share/fonts/zh/
# 4、设置权限
cd /usr/share/fonts/
[top@localhost fonts]$ sudo chmod 755 /usr/share/fonts/ -R
# 5、更新字体缓存
[top@localhost fonts]$ sudo fc-cache -fv
# 6、查看已安装字体
[top@localhost fonts]$ fc-list :lang=zh

#10 备份与恢复MariaDB数据库

# 备份
vagrant@homestead:~/code/gdj/database/bak$ mysqldump -uhomestead -p gdj > ~/code/gdj/database/bak/gdj_db.sql
# 恢复
vagrant@homestead:~/code/gdj/database/bak$ mysql -uhomestead -p gdj < ~/code/gdj/database/bak/gdj_db.sql

#11 安装达梦客户端 [如果是麒麟V10直接用第12部的方法更简单]

# 多个文件的zip需要先修复到一个新的zip文件然后再解压
[top@localhost dm]$ zip -F DMInstall.zip --out DMInstallFile.zip
[top@localhost dm]$ unzip -o DMInstallFile.zip -d DMInstall
[top@localhost DMInstall]$ sudo su
[sudo] top 的密码:
[root@localhost DMInstall]# groupadd oinstall
[root@localhost DMInstall]# usermod -g oinstall -G gzodb gzodb
# usermod:“gzodb”组不存在
[root@localhost DMInstall]# useradd gzodb
[root@localhost DMInstall]# usermod -g oinstall -G gzodb gzodb
[root@localhost DMInstall]# groups gzodb
# gzodb : oinstall gzodb

sudo su - root

groupadd oinstall

usermod -g oinstall -G gzodb gzodb

vi /etc/security/limits.conf
底部输入:
gzodb soft nofile 4096
gzodb hard nofile 65536
gzodb hard core unlimited
gzodb soft core unlimited

切换gzodb用户 su - gzodb

[gzodb@novalocal dmdb]$ ./DMInstall.bin -i
## 如果报 安装程序临时目录(/tmp)可用空间为726M. 安装程序需要至少800M的临时空间, 请调整临时目录的空间或设置环境变量DM_INSTALL_TMPDIR来指定安装程序的临时目录.
sudo mkdir /var/www/install -p
sudo mv /tmp/DMInstall.bin /var/www/install/DMInstall.bin
sudo chmod 777 /var/www/install -R
cd ~
vi .bash_profile
export DM_INSTALL_TMPDIR=/var/www/install
source .bash_profile
cd /var/www/install
./DMInstall.bin -i

Please select the installer's language (E/e:English C/c:Chinese) [E/e]:c
解压安装程序.........
core file size          (blocks, -c) unlimited
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 29694
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 4096
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 29694
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

可打开文件数过少,建议至少设置为65536或更多。

欢迎使用达梦数据库安装程序

是否输入Key文件路径? (Y/y:是 N/n:否) [Y/y]:n

是否设置时区? (Y/y:是 N/n:否) [Y/y]:
设置时区:
[ 1]: GTM-12=日界线西
[ 2]: GTM-11=萨摩亚群岛
[ 3]: GTM-10=夏威夷
[ 4]: GTM-09=阿拉斯加
[ 5]: GTM-08=太平洋时间(美国和加拿大)
[ 6]: GTM-07=亚利桑那
[ 7]: GTM-06=中部时间(美国和加拿大)
[ 8]: GTM-05=东部部时间(美国和加拿大)
[ 9]: GTM-04=大西洋时间(美国和加拿大)
[10]: GTM-03=巴西利亚
[11]: GTM-02=中大西洋
[12]: GTM-01=亚速尔群岛
[13]: GTM=格林威治标准时间
[14]: GTM+01=萨拉热窝
[15]: GTM+02=开罗
[16]: GTM+03=莫斯科
[17]: GTM+04=阿布扎比
[18]: GTM+05=伊斯兰堡
[19]: GTM+06=达卡
[20]: GTM+07=曼谷,河内
[21]: GTM+08=中国标准时间
[22]: GTM+09=汉城
[23]: GTM+10=关岛
[24]: GTM+11=所罗门群岛
[25]: GTM+12=斐济
[26]: GTM+13=努库阿勒法
[27]: GTM+14=基里巴斯
请选择设置时区 [21]:

安装类型:
1 典型安装
2 服务器
3 客户端
4 自定义
请选择安装类型的数字序号 [1 典型安装]:
所需空间: 1045M

请选择安装目录 [/home/gzodb/dmdbms]:/dmdb/dmdbms
可用空间: 99G
是否确认安装路径(/dmdb/dmdbms)? (Y/y:是 N/n:否)  [Y/y]:

安装前小结
安装位置: /dmdb/dmdbms
所需空间: 1045M
可用空间: 99G
版本信息:
有效日期:
安装类型: 典型安装
是否确认安装? (Y/y:是 N/n:否):y
2020-11-23 15:04:33
[INFO] 安装达梦数据库...
2020-11-23 15:04:34
[INFO] 安装 基础 模块...
2020-11-23 15:04:35
[INFO] 安装 服务器 模块...
2020-11-23 15:04:35
[INFO] 安装 客户端 模块...
2020-11-23 15:04:36
[INFO] 安装 驱动 模块...
2020-11-23 15:04:36
[INFO] 安装 手册 模块...
2020-11-23 15:04:36
[INFO] 安装 服务 模块...
2020-11-23 15:04:37
[INFO] 移动ant日志文件。
2020-11-23 15:04:37
[INFO] 安装达梦数据库完成。

请以root系统用户执行命令:
/dmdb/dmdbms/script/root/root_installer.sh

安装结束

[gzodb@novalocal dmdb]$ sudo su -
Last login: Mon Nov 23 14:47:43 CST 2020 on pts/0
hosts is set
[root@novalocal ~]# /dmdb/dmdbms/script/root/root_installer.sh
移动 /dmdb/dmdbms/bin/dm_svc.conf 到/etc目录
修改服务器权限
创建DmAPService服务
Created symlink /etc/systemd/system/multi-user.target.wants/DmAPService.service → /usr/lib/systemd/system/DmAPService.service.
创建服务(DmAPService)完成
启动DmAPService服务


建立实例:
./dminit path=路径 db_name=数据库文件目录名称 instance_name=实例名 page_size=16 port_num=数据连接端口
./dminit path=/dmdb/dmdata db_name=DM8 instance_name=DM8TEST page_size=16 port_num=2621

[gzodb@novalocal bin]$ ./dminit path=/dmdb/dmdata db_name=DM8 instance_name=DM8TEST page_size=16 port_num=2621
initdb V8
db version: 0x7000b
file dm.key not found, use default license!
License will expire on 2021-11-06

 log file path: /dmdb/dmdata/DM8/DM801.log


 log file path: /dmdb/dmdata/DM8/DM802.log

write to dir [/dmdb/dmdata/DM8].
create dm database success. 2020-11-23 15:13:22

启动:
在service_template里面拿出DmService 到bin

vi DmService
修改:
DM_HOME="/dmdb/dmdbms"
INI_PATH=/dmdb/dmdata/DM8/dm.ini

[gzodb@novalocal bin]$ ./DmService start
Starting DmService:                                        [ OK ]

登录:./disql sysdba/SYSDBA:2621


完成。

#12 配置php.ini

mkdir dmDB && cd dmDB
mv /tmp/dmmbj1028.tar.gz /home/top/tools/dm/dmDB/dmmbj1028.tar.gz
tar zxvf dmmbj1028.tar.gz
# 这一步应该是可以省略的
vim ~/.bash_profile
# 写入
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/top/tools/dm/dmDB/bin

# 直接这一步即可
[top@localhost ld.so.conf.d]$ cd /etc/ld.so.conf.d
[top@localhost ld.so.conf.d]$ sudo vim dm.conf
# 写入
/usr/lib64/
/home/top/tools/dm/dmDB/bin
# 执行
[top@localhost ld.so.conf.d]$ sudo ldconfig
# ldconfig: /home/top/tools/dm/bin/libxerces-c-3.1.so 不是符号链接  这个可以忽略

sudo vim /usr/local/php/etc/php.ini
sudo /usr/local/php/daemon/php-fpm reload 
## 或者重启 
sudo /usr/local/php/daemon/php-fpm restart

php -m | grep dm
[dm]
extension=/home/top/tools/dm/dmDB/drivers/php_pdo/libphp80_dm.so
extension=/home/top/tools/dm/dmDB/drivers/php_pdo/php80_pdo_dm.so

; 是否允许持久性连接
dm.allow_persistent = 1
; 允许建立持久性连接的最大数. -1 为没有限制.
dm.max_persistent = -1
; 允许建立连接的最大数(包括持久性连接). -1 为没有限制.
dm.max_links = -1
; 默认的主库地址
dm.default_host = 192.168.11.212:2621/jkgl
; 默认的连接用户名
dm.default_user = jkgl_yehui_sys
; 默认的连接口令.
dm.default_pw = JkDb_0309
; 连接超时,这个参数未实际的用到,等待服务器支持
dm.connect_timeout = 10
; 对于各种变长数据类型,每列最大读取的字节数。如果它设置为 0 或是小于 0,那么,读取变长字段时,
dm.defaultlrl = 4096
; 是否读取二进制类型数据,如果它设置为 0,那么二进制将被 NULL 值代替
dm.defaultbinmode = 1
; 是否允许检察持久性连接的有效性,如果设置为 ON,那么当重用一个持久性连接时,会检察该连接是否
dm.check_persistent = ON

#13 普通用户添加到sudoers组

# 用root用户登录 或 切换到root用户
sudo su
## 方式一:
[root@localhost ~]# usermod -G sudo top
## 如果报 usermod:“sudo”组不存在 则只能用方式二

## 方式二:
#默认只读文件,改为root用户可读可写
[root@localhost ~]# chmod 640 /etc/sudoers
[root@localhost ~]# vim /etc/sudoers
# ## Allow root to run any commands anywhere 下面加入top[需要添加的账户名]那行
## Sudoers allows particular users to run various commands as
## the root user, without needing the root password.
##
## Examples are provided at the bottom of the file for collections
## of related commands, which can then be delegated out to particular
## users or groups.
##
## This file must be edited with the 'visudo' command.


# Defaults specification

#
# Refuse to run if unable to disable echo on the tty.
#
Defaults   !visiblepw

Defaults    env_reset
Defaults    env_keep =  "COLORS DISPLAY HOSTNAME HISTSIZE KDEDIR LS_COLORS"
Defaults    env_keep += "MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE"
Defaults    env_keep += "LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES"
Defaults    env_keep += "LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE"
Defaults    env_keep += "LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY"

Defaults    secure_path = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

## Next comes the main part: which users can run what software on
## which machines (the sudoers file can be shared between multiple
## systems).
## Syntax:
##
##      user    MACHINE=COMMANDS
##
## The COMMANDS section may have other options added to it.
##
## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL
top     ALL=(ALL)       ALL
## Allows people in group wheel to run all commands
%wheel  ALL=(ALL)       ALL

#14 解压自动覆盖代码

[top@localhost codes]$ sudo unzip -o 0507.zip -d /var/www/html
# 解压
sudo tar zxvf xxx.tar.gz -C /目标文件夹  
# 打包
sudo tar zcvf /zzz.tar.gz ./zzz
# copy
\cp -rf /0506/* /var/www/html

#15 安装supervisor

15.1 安装 setuptools

#1 下载 https://pypi.org/project/setuptools/#files
#2 安装
tar -zxvf setuptools-65.3.0.tar.gz
cd setuptools-65.3.0/
python setup.py install

### python2.7 只支持44.1.1  https://pypi.org/project/setuptools/44.1.1/#files
# 安装
unzip -o -d setuptools setuptools-44.1.1.zip
cd setuptools/setuptools-44.1.1/
sudo python setup.py install

15.2 安装supervisor

#1 下载 https://pypi.org/project/supervisor/#files
#2 安装
tar -zxvf supervisor-4.2.4.tar.gz
cd supervisor-4.2.4/
python setup.py install

#3 安装后会在/usr/bin 生成这三个文件
[top@localhost setuptools-44.1.1]$ ls -al /usr/bin/ | grep "super"
-rwx------  1 root root         418  9月 23 19:29 echo_supervisord_conf
-rwx------  1 root root         402  9月 23 19:29 supervisorctl
-rwx------  1 root root         398  9月 23 19:29 supervisord
# 驗證supervisor是否安裝成功
[top@localhost setuptools-44.1.1]$ sudo supervisorctl --help

15.3 supervisor配置

#建立 /etc/supervisor 目錄
mkdir /etc/supervisor
#echo_supervisord_conf 生成supervisord.conf
# 需要先切换到root用户
su
echo_supervisord_conf > /etc/supervisor/supervisord.conf
#设置权限
sudo chmod 644 /etc/supervisor/ -R
#修改/etc/supervisor/supervisord.conf檔案內容
[include]
files = /etc/supervisor/conf.d/*.conf

[top@localhost setuptools-44.1.1]$ sudo mkdir /etc/supervisor/conf.d
[top@localhost setuptools-44.1.1]$ sudo chmod 644 /etc/supervisor/conf.d
[top@localhost setuptools-44.1.1]$ sudo vi /etc/supervisor/conf.d/laravel-worker.conf
[top@localhost setuptools-44.1.1]$ sudo chmod 644 /etc/supervisor/conf.d -R

## 解决unix-tmp-supervisor-sock-no-such-file
## 针对/etc/supervisor/supervisord.conf的扩展配置
sudo chmod 777 /var/run
sudo chmod 777 /var/log
sudo touch /var/run/supervisor.sock
sudo chmod 777 /var/run/supervisor.sock
supervisorctl update
; Sample supervisor config file.
;
; For more information on the config file, please see:
; http://supervisord.org/configuration.html
;
; Notes:
;  - Shell expansion ("~" or "$HOME") is not supported.  Environment
;    variables can be expanded using this syntax: "%(ENV_HOME)s".
;  - Quotes around values are not supported, except in the case of
;    the environment= options as shown below.
;  - Comments must have a leading space: "a=b ;comment" not "a=b;comment".
;  - Command will be truncated if it looks like a config file comment, e.g.
;    "command=bash -c 'foo ; bar'" will truncate to "command=bash -c 'foo ".
;
; Warning:
;  Paths throughout this example file use /tmp because it is available on most
;  systems.  You will likely need to change these to locations more appropriate
;  for your system.  Some systems periodically delete older files in /tmp.
;  Notably, if the socket file defined in the [unix_http_server] section below
;  is deleted, supervisorctl will be unable to connect to supervisord.

[unix_http_server]
;file=/tmp/supervisor.sock   ; the path to the socket file
file=/var/run/supervisor.sock   ; the path to the socket file
;chmod=0700                 ; socket file mode (default 0700)
;chown=nobody:nogroup       ; socket file uid:gid owner
;username=user              ; default is no username (open server)
;password=123               ; default is no password (open server)

; Security Warning:
;  The inet HTTP server is not enabled by default.  The inet HTTP server is
;  enabled by uncommenting the [inet_http_server] section below.  The inet
;  HTTP server is intended for use within a trusted environment only.  It
;  should only be bound to localhost or only accessible from within an
;  isolated, trusted network.  The inet HTTP server does not support any
;  form of encryption.  The inet HTTP server does not use authentication
;  by default (see the username= and password= options to add authentication).
;  Never expose the inet HTTP server to the public internet.

;[inet_http_server]         ; inet (TCP) server disabled by default
;port=127.0.0.1:9001        ; ip_address:port specifier, *:port for all iface
;username=user              ; default is no username (open server)
;password=123               ; default is no password (open server)

[supervisord]
;logfile=/tmp/supervisord.log ; main log file; default $CWD/supervisord.log
logfile=/var/log/supervisord.log ; main log file; default $CWD/supervisord.log
logfile_maxbytes=50MB        ; max main logfile bytes b4 rotation; default 50MB
logfile_backups=10           ; # of main logfile backups; 0 means none, default 10
loglevel=info                ; log level; default info; others: debug,warn,trace
;pidfile=/tmp/supervisord.pid ; supervisord pidfile; default supervisord.pid
pidfile=/var/run/supervisord.pid ; supervisord pidfile; default supervisord.pid
nodaemon=false               ; start in foreground if true; default false
silent=false                 ; no logs to stdout if true; default false
minfds=1024                  ; min. avail startup file descriptors; default 1024
minprocs=200                 ; min. avail process descriptors;default 200
;umask=022                   ; process file creation umask; default 022
;user=supervisord            ; setuid to this UNIX account at startup; recommended if root
;identifier=supervisor       ; supervisord identifier, default is 'supervisor'
;directory=/tmp              ; default is not to cd during start
;nocleanup=true              ; don't clean up tempfiles at start; default false
;childlogdir=/tmp            ; 'AUTO' child log dir, default $TEMP
;environment=KEY="value"     ; key value pairs to add to environment
;strip_ansi=false            ; strip ansi escape codes in logs; def. false

; The rpcinterface:supervisor section must remain in the config file for
; RPC (supervisorctl/web interface) to work.  Additional interfaces may be
; added by defining them in separate [rpcinterface:x] sections.

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

; The supervisorctl section configures how supervisorctl will connect to
; supervisord.  configure it match the settings in either the unix_http_server
; or inet_http_server section.

[supervisorctl]
;serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL  for a unix socket
serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL  for a unix socket
;serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket
;username=chris              ; should be same as in [*_http_server] if set
;password=123                ; should be same as in [*_http_server] if set
;prompt=mysupervisor         ; cmd line prompt (default "supervisor")
;history_file=~/.sc_history  ; use readline history if available

; The sample program section below shows all possible program subsection values.
; Create one or more 'real' program: sections to be able to control them under
; supervisor.

;[program:theprogramname]
;command=/bin/cat              ; the program (relative uses PATH, can take args)
;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
;numprocs=1                    ; number of processes copies to start (def 1)
;directory=/tmp                ; directory to cwd to before exec (def no cwd)
;umask=022                     ; umask for process (default None)
;priority=999                  ; the relative start priority (default 999)
;autostart=true                ; start at supervisord start (default: true)
;startsecs=1                   ; # of secs prog must stay up to be running (def. 1)
;startretries=3                ; max # of serial start failures when starting (default 3)
;autorestart=unexpected        ; when to restart if exited after running (def: unexpected)
;exitcodes=0                   ; 'expected' exit codes used with autorestart (default 0)
;stopsignal=QUIT               ; signal used to kill process (default TERM)
;stopwaitsecs=10               ; max num secs to wait b4 SIGKILL (default 10)
;stopasgroup=false             ; send stop signal to the UNIX process group (default false)
;killasgroup=false             ; SIGKILL the UNIX process group (def false)
;user=chrism                   ; setuid to this UNIX account to run the program
;redirect_stderr=true          ; redirect proc stderr to stdout (default false)
;stdout_logfile=/a/path        ; stdout log path, NONE for none; default AUTO
;stdout_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
;stdout_logfile_backups=10     ; # of stdout logfile backups (0 means none, default 10)
;stdout_capture_maxbytes=1MB   ; number of bytes in 'capturemode' (default 0)
;stdout_events_enabled=false   ; emit events on stdout writes (default false)
;stdout_syslog=false           ; send stdout to syslog with process name (default false)
;stderr_logfile=/a/path        ; stderr log path, NONE for none; default AUTO
;stderr_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
;stderr_logfile_backups=10     ; # of stderr logfile backups (0 means none, default 10)
;stderr_capture_maxbytes=1MB   ; number of bytes in 'capturemode' (default 0)
;stderr_events_enabled=false   ; emit events on stderr writes (default false)
;stderr_syslog=false           ; send stderr to syslog with process name (default false)
;environment=A="1",B="2"       ; process environment additions (def no adds)
;serverurl=AUTO                ; override serverurl computation (childutils)

; The sample eventlistener section below shows all possible eventlistener
; subsection values.  Create one or more 'real' eventlistener: sections to be
; able to handle event notifications sent by supervisord.

;[eventlistener:theeventlistenername]
;command=/bin/eventlistener    ; the program (relative uses PATH, can take args)
;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
;numprocs=1                    ; number of processes copies to start (def 1)
;events=EVENT                  ; event notif. types to subscribe to (req'd)
;buffer_size=10                ; event buffer queue size (default 10)
;directory=/tmp                ; directory to cwd to before exec (def no cwd)
;umask=022                     ; umask for process (default None)
;priority=-1                   ; the relative start priority (default -1)
;autostart=true                ; start at supervisord start (default: true)
;startsecs=1                   ; # of secs prog must stay up to be running (def. 1)
;startretries=3                ; max # of serial start failures when starting (default 3)
;autorestart=unexpected        ; autorestart if exited after running (def: unexpected)
;exitcodes=0                   ; 'expected' exit codes used with autorestart (default 0)
;stopsignal=QUIT               ; signal used to kill process (default TERM)
;stopwaitsecs=10               ; max num secs to wait b4 SIGKILL (default 10)
;stopasgroup=false             ; send stop signal to the UNIX process group (default false)
;killasgroup=false             ; SIGKILL the UNIX process group (def false)
;user=chrism                   ; setuid to this UNIX account to run the program
;redirect_stderr=false         ; redirect_stderr=true is not allowed for eventlisteners
;stdout_logfile=/a/path        ; stdout log path, NONE for none; default AUTO
;stdout_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
;stdout_logfile_backups=10     ; # of stdout logfile backups (0 means none, default 10)
;stdout_events_enabled=false   ; emit events on stdout writes (default false)
;stdout_syslog=false           ; send stdout to syslog with process name (default false)
;stderr_logfile=/a/path        ; stderr log path, NONE for none; default AUTO
;stderr_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
;stderr_logfile_backups=10     ; # of stderr logfile backups (0 means none, default 10)
;stderr_events_enabled=false   ; emit events on stderr writes (default false)
;stderr_syslog=false           ; send stderr to syslog with process name (default false)
;environment=A="1",B="2"       ; process environment additions
;serverurl=AUTO                ; override serverurl computation (childutils)

; The sample group section below shows all possible group values.  Create one
; or more 'real' group: sections to create "heterogeneous" process groups.

;[group:thegroupname]
;programs=progname1,progname2  ; each refers to 'x' in [program:x] definitions
;priority=999                  ; the relative start priority (default 999)

; The [include] section can just contain the "files" setting.  This
; setting can list multiple files (separated by whitespace or
; newlines).  It can also contain wildcards.  The filenames are
; interpreted as relative to this file.  Included files *cannot*
; include files themselves.

[include]
files = /etc/supervisor/conf.d/*.conf
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/html/artisan horizon
autostart=true
autorestart=true
user=vagrant
redirect_stderr=true
stdout_logfile=/var/www/html/storage/logs/worker.log

[program:laravel-echo]
process_name=%(program_name)s_%(process_num)02d
directory=/var/www/html
command=laravel-echo-server start
autostart=true
autorestart=true
user=vagrant
redirect_stderr=true
stdout_logfile=/var/www/html/storage/logs/echo-server.log

15.4 测试supervisor

# 常用命令
supervisord -c /etc/supervisor/supervisord.conf ## 启动
supervisorctl shutdown  ## 关闭
supervisord -c /etc/supervisord.conf  ## 通过配置文件启动supervisor
supervisorctl -c /etc/supervisord.conf status  ## 查看状态
supervisorctl -c /etc/supervisord.conf reload  ## 重新载入配置文件 
supervisorctl -c /etc/supervisord.conf start [all]|[x]  ## 启动所有/指定的程序进程 
supervisorctl -c /etc/supervisord.conf stop [all]|[x]  ## 关闭所有/指定的程序进程

15.5 设置开机启动

## 开机启动
[root@host supervisor-4.2.0]# sudo touch /usr/lib/systemd/system/supervisord.service
[root@host supervisor-4.2.0]# sudo vim /usr/lib/systemd/system/supervisord.service
[root@host supervisor-4.2.0]# systemctl enable supervisord
Created symlink from /etc/systemd/system/multi-user.target.wants/supervisord.service to /usr/lib/systemd/system/supervisord.service.
[root@host supervisor-4.2.0]# systemctl is-enabled supervisord
enabled
[root@host supervisor-4.2.0]# sudo systemctl daemon-reload
[root@host supervisor-4.2.0]# sudo systemctl restart supervisord
[root@host supervisor-4.2.0]# sudo systemctl status supervisord

## 配置成功后可以使用下面命令
# 重启指定应用
supervisorctl restart <application name>
# 停止指定应用
supervisorctl stop <application name>
# 启动指定应用
supervisorctl start <application name>
# 查看状态
supervisorctl status
# 重启所有应用
supervisorctl restart all
# 停止所有应用
supervisorctl stop all
# 启动所有应用
supervisorctl start all
# supervisord service for systemd (CentOS 7.0+)
# by ET-CS (https://github.com/ET-CS)
[Unit]
Description=Supervisor daemon

[Service]
Type=forking
ExecStart=/usr/bin/supervisord -c /etc/supervisor/supervisord.conf
ExecStop=/usr/bin/supervisorctl $OPTIONS shutdown
ExecReload=/usr/bin/supervisorctl $OPTIONS reload
KillMode=process
Restart=on-failure
RestartSec=42s

[Install]
WantedBy=multi-user.target

参考资料汇总