国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home php教程 php手冊(cè) 配置文件在正式服務(wù)器上的部署

配置文件在正式服務(wù)器上的部署

Jun 06, 2016 pm 07:37 PM
server formal deploy Configuration file

配置文件在正式服務(wù)器上的部署。 從文件服務(wù)器下載配置文件,備份并替換本地的配置文件,將配置文件壓縮成zip格式 無 ?phpheader("Content-Type:text/html;charset=utf-8");include 'tz.php';/** * 執(zhí)行配置文件的壓縮 * Created by PhpStorm. * User: saint

配置文件在正式服務(wù)器上的部署。
從文件服務(wù)器下載配置文件,備份并替換本地的配置文件,將配置文件壓縮成zip格式
<?php
header("Content-Type:text/html;charset=utf-8");
include 'tz.php';
/**
 * 執(zhí)行配置文件的壓縮
 * Created by PhpStorm.
 * User: saint
 * Date: 2015/3/18
 * Time: 14:25
 */
if(!defined("SYSTEM_PATH")) 	define("SYSTEM_PATH",	'/data/wwwroot/static/webroot');

class Compress
{
    /**
     * @var array 這里是需要處理的配置文件
     */
    public $cfg_files = array(
        'DEMO1Config.json', #
    );

    /**
     * @var string 文件服務(wù)器地址
     */
    public $file_server = '';

    public $cfg_path = '';

    public $temp_path = '';

    public $zip_file = '';

    /**
     * 環(huán)境初始化
     */
    public function _InitEnv()
    {
        $this->cfg_path = SYSTEM_PATH . '/metafile';
        if(false == (is_dir( $this->cfg_path) && is_writable($this->cfg_path))) {
            throw new Exception('配置目錄不存在或者不可寫');
        }

        $this->temp_path = SYSTEM_PATH . '/tmp';
        if(false == (is_dir($this->temp_path) && is_writable($this->temp_path))) {
            throw new Exception('臨時(shí)配置目錄不存在或者不可寫');
        }

        if(function_exists('file_get_contents') == false) {
            throw new Exception('file_get_contents函數(shù)已禁用');
        }

        if(function_exists('file_put_contents') == false) {
            throw new Exception('file_put_contents函數(shù)已禁用');
        }

        if(class_exists('ZipArchive') == false) {
            throw new Exception('找不到ZipArchive');
        }

    }

    public function downloadFiles()
    {
        $start = microtime(true);
        try {
            $this->_InitEnv();
        } catch (Exception $e) {
            echo $e->getMessage();
            exit;
        }

        $file_array = array();

        // 依次從服務(wù)器上下載配置文件
        foreach($this->cfg_files as $filename) {
            $tmp_file = $this->temp_path . '/' . $filename;
            $remote_file = $this->file_server . '/' . $filename;

            // 檢查本地是否存在臨時(shí)文件,如果有,則檢查這個(gè)文件本地文件是否一致
            $is_download = true;
            if(is_file($tmp_file)) {
                if(hash_file('sha256', $tmp_file) == hash_file('sha256', $remote_file)) {
                    $is_download = false;
                }
            }

            if($is_download) {
                $contents = file_get_contents($remote_file);
                file_put_contents($tmp_file, $contents);
            }

            $file_array[] = $tmp_file;
        }

        // 對(duì)配置文件進(jìn)行壓縮
        try {
            $this->compressFiles();
        } catch (Exception $e) {
            echo $e->getMessage();
            exit;
        }

        $limit = microtime(true) - $start;

        echo '<p>生成壓縮文件成功,本次耗時(shí):' . $limit . 's</p>';
        echo '<p>開始替換原來的配置文件</p>';

        $this->replaceFiles();

        // 插入數(shù)據(jù)庫


        echo '<p>替換完畢</p>';

    }

    // 替換原來的文件
    public function replaceFiles()
    {
        // 打開配置目錄,創(chuàng)建備份目錄
        chdir($this->cfg_path);
        $backup_dir = 'cfg_bak_' . date('Ymd');
        if(is_dir($backup_dir)) {
            rmdir($backup_dir);
        }
        mkdir($backup_dir, 0777);
        array_push($this->cfg_files, $this->zip_file);
        foreach($this->cfg_files as $file_name) {
            $dst_file = $backup_dir . '/' . $file_name;
            if(is_file($file_name)) {
                copy($file_name, $dst_file);
            }
            $new_file = $this->temp_path . '/' . $file_name;
            copy($new_file, $file_name);
        }
    }

    /**
     * 執(zhí)行壓縮文件
     * @param $file_array
     * @throws Exception
     */
    public function compressFiles()
    {
        chdir($this->temp_path);
        $this->zip_file = 'cfg_' . date(('Ymd')) . '.zip';
        $zipClass = new ZipArchive();
        $fp = $zipClass->open($this->zip_file, ZipArchive::CREATE);
        if($fp === true) {
            foreach($this->cfg_files as $file_name) {
                $zipClass->addFile($file_name);
            }
        } else {
            throw new Exception('壓縮失敗:' . $fp);
        }
        $zipClass->close();
    }
}

$obj = new Compress();
$obj->downloadFiles();
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to configure Dnsmasq as a DHCP relay server How to configure Dnsmasq as a DHCP relay server Mar 21, 2024 am 08:50 AM

The role of a DHCP relay is to forward received DHCP packets to another DHCP server on the network, even if the two servers are on different subnets. By using a DHCP relay, you can deploy a centralized DHCP server in the network center and use it to dynamically assign IP addresses to all network subnets/VLANs. Dnsmasq is a commonly used DNS and DHCP protocol server that can be configured as a DHCP relay server to help manage dynamic host configurations in the network. In this article, we will show you how to configure dnsmasq as a DHCP relay server. Content Topics: Network Topology Configuring Static IP Addresses on a DHCP Relay D on a Centralized DHCP Server

Best Practice Guide for Building IP Proxy Servers with PHP Best Practice Guide for Building IP Proxy Servers with PHP Mar 11, 2024 am 08:36 AM

In network data transmission, IP proxy servers play an important role, helping users hide their real IP addresses, protect privacy, and improve access speeds. In this article, we will introduce the best practice guide on how to build an IP proxy server with PHP and provide specific code examples. What is an IP proxy server? An IP proxy server is an intermediate server located between the user and the target server. It acts as a transfer station between the user and the target server, forwarding the user's requests and responses. By using an IP proxy server

Where is the win10 user profile? How to set the user profile in Win10 Where is the win10 user profile? How to set the user profile in Win10 Jun 25, 2024 pm 05:55 PM

Recently, many Win10 system users want to change the user profile, but they don’t know how to do it. This article will show you how to set the user profile in Win10 system! How to set up user profile in Win10 1. First, press the "Win+I" keys to open the settings interface, and click to enter the "System" settings. 2. Then, in the opened interface, click "About" on the left, then find and click "Advanced System Settings". 3. Then, in the pop-up window, switch to the "" option bar and click "User Configuration" below.

Yolov10: Detailed explanation, deployment and application all in one place! Yolov10: Detailed explanation, deployment and application all in one place! Jun 07, 2024 pm 12:05 PM

1. Introduction Over the past few years, YOLOs have become the dominant paradigm in the field of real-time object detection due to its effective balance between computational cost and detection performance. Researchers have explored YOLO's architectural design, optimization goals, data expansion strategies, etc., and have made significant progress. At the same time, relying on non-maximum suppression (NMS) for post-processing hinders end-to-end deployment of YOLO and adversely affects inference latency. In YOLOs, the design of various components lacks comprehensive and thorough inspection, resulting in significant computational redundancy and limiting the capabilities of the model. It offers suboptimal efficiency, and relatively large potential for performance improvement. In this work, the goal is to further improve the performance efficiency boundary of YOLO from both post-processing and model architecture. to this end

What should I do if I can't enter the game when the epic server is offline? Solution to why Epic cannot enter the game offline What should I do if I can't enter the game when the epic server is offline? Solution to why Epic cannot enter the game offline Mar 13, 2024 pm 04:40 PM

What should I do if I can’t enter the game when the epic server is offline? This problem must have been encountered by many friends. When this prompt appears, the genuine game cannot be started. This problem is usually caused by interference from the network and security software. So how should it be solved? The editor of this issue will explain I would like to share the solution with you, I hope today’s software tutorial can help you solve the problem. What to do if the epic server cannot enter the game when it is offline: 1. It may be interfered by security software. Close the game platform and security software and then restart. 2. The second is that the network fluctuates too much. Try restarting the router to see if it works. If the conditions are OK, you can try to use the 5g mobile network to operate. 3. Then there may be more

How to deploy and maintain a website using PHP How to deploy and maintain a website using PHP May 03, 2024 am 08:54 AM

To successfully deploy and maintain a PHP website, you need to perform the following steps: Select a web server (such as Apache or Nginx) Install PHP Create a database and connect PHP Upload code to the server Set up domain name and DNS Monitoring website maintenance steps include updating PHP and web servers, and backing up the website , monitor error logs and update content.

Install Helm on Ubuntu Install Helm on Ubuntu Mar 20, 2024 pm 06:41 PM

Helm is an important component of Kubernetes that simplifies the deployment of Kubernetes applications by bundling configuration files into a package called HelmChart. This approach makes updating a single configuration file more convenient than modifying multiple files. With Helm, users can easily deploy Kubernetes applications, simplifying the entire deployment process and improving efficiency. In this guide, I'll cover different ways to implement Helm on Ubuntu. Please note: The commands in the following guide apply to Ubuntu 22.04 as well as all Ubuntu versions and Debian-based distributions. These commands are tested and should work correctly on your system. in U

Equipped with AMD EPYC 4004 series processors, ASUS launches a variety of server and workstation products Equipped with AMD EPYC 4004 series processors, ASUS launches a variety of server and workstation products Jul 23, 2024 pm 09:34 PM

According to news from this website on July 23, ASUS has launched a variety of server and workstation-level products powered by AMD EPYC 4004 series processors. Note from this site: AMD launched the AM5 platform and Zen4 architecture EPYC 4004 series processors in May, offering up to 16-core 3DV-Cache specifications. ASUSProER100AB6 server ASUSProER100AB6 is a 1U rack server product equipped with EPYC Xiaolong 4004 series processor, suitable for the needs of IDC and small and medium-sized enterprises. ASUSExpertCenterProET500AB6 workstation ASUSExpertCenterProET500AB6 is a

See all articles