Method, device and equipment for publishing web application PHP code based on shell script
By building an initial web application directory and using shell scripts to automate the deployment of PHP code, the high cost and long time required for iterative deployment of web application systems are solved, achieving fast and accurate automated deployment and reducing operation and maintenance costs and error rates.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHERY AUTOMOBILE CO LTD
- Filing Date
- 2023-10-26
- Publication Date
- 2026-08-04
AI Technical Summary
Iterative deployment of PHP code for web application systems requires high costs and maintenance expenses. Traditional manual deployment processes are cumbersome, have long iteration and launch times, and have a high rate of operational errors.
By building an initial web application directory to store shell scripts, using shell scripts to pull PHP code files from the SVN code repository, logging into the web application machine using the user key, and pushing the code files, automated deployment is achieved.
Reduce maintenance costs and human error rate, achieve fast and accurate automatic deployment of PHP code, reduce iteration and deployment time, and make it easier for users to use.
Smart Images

Figure CN117478661B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of Web technology, and in particular to a method, apparatus, and device for publishing PHP code for Web applications based on Shell scripts. Background Technology
[0002] In order to respond quickly to market demands, web application systems require continuous software iteration. Software versions are updated weekly, and with bug fixes and releases, there are a large number of software iteration and release requirements for the PHP code of web application systems.
[0003] However, manually deploying PHP code is cumbersome, prone to errors by maintenance personnel, involves multiple deployment servers, and results in long software iteration and deployment times, which affects users' use of the web application system.
[0004] Currently, the market offers solutions for software iteration, release, and deployment, including paid continuous integration and deployment platforms (such as Blue Whale and EasyOps) and open-source tools like Jenkins. However, paid versions require high fees, while open-source tools like Jenkins require complex deployment and configuration, resulting in high maintenance costs. These issues urgently need to be addressed. Summary of the Invention
[0005] This application provides a method, apparatus, and device for publishing PHP code for web applications based on Shell scripts, in order to solve the problems of high costs, high maintenance costs, and cumbersome traditional manual PHP code publishing processes, which result in long software iteration and deployment times and high error rates when iterating and launching PHP code for current web application systems.
[0006] The first aspect of this application provides a method for publishing PHP code for a web application based on a shell script, comprising the following steps: constructing an initial web application directory and storing the shell script in the initial web application directory to obtain a new web application directory; using the shell script to pull PHP code files from an SVN code repository to the new web application directory to obtain a final web application directory; logging into the web application machine using a user key based on the shell script, and pushing the PHP code files in the final web application directory to the web application machine.
[0007] Optionally, before building the initial web application directory, the process includes: installing the SVN and RSYNC environments, and configuring the user key for SSH login to the web application machine.
[0008] Optionally, after pushing the PHP code file in the final Web application directory to the Web application machine, the process includes: obtaining the number of times the PHP code file has been published; if the number of publications is greater than or equal to a preset number of publications, then reverting the historical version of the PHP code file to the Web application machine.
[0009] Optionally, after pushing the PHP code file to the Web application machine, the method further includes: determining whether the PHP code file and the preset configuration file are both synchronized to the Web application machine's code directory; if the PHP code file and the preset configuration file are both synchronized to the Web application machine's code directory, then printing "synchronization successful" and updating the release version number of the PHP code file on the Web application machine; otherwise, printing "synchronization error".
[0010] Optionally, before constructing the initial web application directory, the method further includes: receiving the PHP code file and obtaining the access address of the PHP code file in the SVN code repository.
[0011] A second aspect of this application provides a method for publishing PHP code for a web application based on a shell script, comprising: a build module for building an initial web application directory and storing the shell script in the initial web application directory to obtain a new web application directory; a pull module for using the shell script to pull PHP code files from an SVN code repository to the new web application directory to obtain a final web application directory; and a publishing module for logging into the web application machine using a user key based on the shell script and pushing the PHP code files in the final web application directory to the web application machine.
[0012] Optionally, before building the initial web application directory, the build module is also used to: install the SVN environment and the RSYNC environment, and configure the user key for SSH login to the web application machine.
[0013] Optionally, after the PHP code file in the final Web application directory is pushed to the Web application machine, the publishing module is further configured to: obtain the number of times the PHP code file has been published; if the number of publications is greater than or equal to a preset number of publications, then roll back the historical version of the PHP code file to the Web application machine.
[0014] Optionally, after the PHP code file in the final Web application directory is published to the Web application machine, the publishing module is further configured to: determine whether the PHP code file and the preset configuration file are both synchronized to the Web application machine's code directory; if the PHP code file and the preset configuration file are both synchronized to the Web application machine's code directory, then print "synchronization successful" and update the publishing version number of the PHP code file on the Web application machine; otherwise, print "synchronization error".
[0015] Optionally, before building the initial web application directory, the building module is further configured to: receive the PHP code file and obtain the access address of the PHP code file in the SVN code repository.
[0016] A third aspect of this application provides an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the method for publishing Web application PHP code based on Shell script as described in the above embodiments.
[0017] A fourth aspect of this application provides a computer-readable storage medium having a computer program stored thereon, which is executed by a processor to implement the method for publishing Web application PHP code based on Shell script as described in the above embodiments.
[0018] This application constructs an initial web application directory and stores a shell script in it, resulting in a new web application directory. The shell script then pulls PHP code files from an SVN repository to this new directory, resulting in the final web application directory. Finally, the shell script uses a user key to log in to the web application machine and pushes the PHP code files from the final directory to the web application machine. This solves the problems of high costs and maintenance expenses associated with PHP code deployment during current web application system software iterations, as well as the cumbersome, time-consuming, and error-prone traditional manual PHP code deployment process. It reduces maintenance costs and human error rates, enabling rapid and accurate automated PHP code deployment, thus facilitating user experience with web application systems.
[0019] Additional aspects and advantages of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application. Attached Figure Description
[0020] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein:
[0021] Figure 1 This is a flowchart illustrating a method for publishing PHP code for a web application based on a shell script, according to an embodiment of this application.
[0022] Figure 2 This is a schematic diagram of the structure of a web application directory according to an embodiment of this application;
[0023] Figure 3 A flowchart illustrating the distribution of PHP code files according to one embodiment of this application;
[0024] Figure 4 Example diagram of an apparatus for publishing PHP code for a web application based on a shell script, according to an embodiment of this application;
[0025] Figure 5 This is a schematic diagram of the structure of an electronic device according to an embodiment of this application. Detailed Implementation
[0026] The embodiments of this application are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain this application, and should not be construed as limiting this application.
[0027] The following description, with reference to the accompanying drawings, describes a method, apparatus, and device for publishing PHP code for web applications based on shell scripts, according to embodiments of this application. Addressing the issues mentioned in the background section regarding the high costs and maintenance associated with publishing PHP code for current web application systems during software iteration, the cumbersome and time-consuming traditional manual PHP code publishing process, and the high error rate, this application provides a method for publishing PHP code for web applications based on shell scripts. In this method, an initial web application directory is constructed, and a shell script is stored in this directory to obtain a new web application directory. The shell script then pulls PHP code files from an SVN repository to the new web application directory, resulting in the final web application directory. Finally, the user login key is invoked using the shell script to log in to the web application machine, and the PHP code files in the final web application directory are pushed and published to the web application machine. This solves the problems of high costs and maintenance costs associated with deploying PHP code during software iteration in current web application systems, as well as the cumbersome, time-consuming, and error-prone traditional manual PHP code deployment process. It reduces maintenance costs and human error rates, enabling fast and accurate automatic deployment of PHP code, making it easier for users to use web application systems.
[0028] Specifically, Figure 1 This is a flowchart illustrating a method for publishing PHP code for a web application based on a Shell script, as provided in an embodiment of this application.
[0029] like Figure 1 As shown, this method for publishing PHP code for a web application based on a shell script includes the following steps:
[0030] In step S101, an initial web application directory is constructed, and the shell script is stored in the initial web application directory to obtain a new web application directory.
[0031] The initial web application directory is built by the code deployment machine. The initial web application directory contains multiple subdirectories, and each web application directory has the same structure.
[0032] For example, such as Figure 2As shown, for example, the www.xx.com application directory contains subdirectories named config, info, and release. The info subdirectory contains files named excludefile, svn, version, and hosts. The config directory contains the default configuration files to be synchronized to the web application machine; the release directory contains the PHP code fetched by SVN; the hosts file contains the IP address or domain name of the web application machine, such as 192.168.1.100; the svn file contains the SVN access address for retrieving the web application code, such as http: / / 192.168.1.10 / svn / www.xx.com / ; the version file contains the directory where the PHP code files on the web application machine are located, such as www.xx.com: / data / :20230704; and the excludefile file contains the filenames or directories of files that do not need to be synchronized to the web application.
[0033] In some embodiments, before building the initial web application directory, the process includes: installing the SVN and RSYNC environments, and configuring the user key for SSH login to the web application machine.
[0034] Specifically, before building the initial web application directory, the code deployment machine needs to install environments such as SVN and RSYNC, and configure a user key that can be used to log in to the web application machine via SSH.
[0035] It should be noted that code deployment machines and web application machines are different types of servers.
[0036] Optionally, in some embodiments, before building the initial web application directory, the method further includes: receiving PHP code files and obtaining the access address of the PHP code files in the SVN code repository.
[0037] Understandably, PHP code files are submitted by developers and stored in an SVN repository, with the developers providing access to the SVN repository for the PHP code files.
[0038] In step S102, a Shell script is used to pull PHP code files from the SVN code repository to a new Web application directory, thus obtaining the final Web application directory.
[0039] Shell scripts can also be attached. Figure 3 The code is used to publish the script.
[0040] Specifically, the shell script defines a function `_SVN_CHECKOUT` to fetch PHP code files from SVN. Within this function, the variable `$SVN_URL` is defined as the SVN address in `${ROOTDIR} / ${PROJECT} / info / svn`, and `svn checkout` is defined to fetch PHP code files from the SVN repository to the `${ROOTDIR} / ${PROJECT} / release` directory. The shell script `pushwebcod.sh` is placed in the same directory as the published web application directory. For example, executing the script command `sh pushwebcod.sh www.xx.com svn 2023070401` fetches PHP code files to the `www.xx.com / release` directory, resulting in the final web application directory.
[0041] Before fetching PHP code files from the SVN repository, a shell script uses the `whoami` command in an `if` statement to determine if the user executing the shell script is `sysadmin`. If it is `sysadmin`, the PHP code files are fetched from the SVN repository; otherwise, the process exits. The shell script defines the home directory variable `$ROOTDIR` as the directory returned by the `pwd` command, the username variable `$USER_NAME` as `sysadmin`, the file variable `$USER_KEY` as the user key, the first parameter of the shell script as the variable `$PROJECT`, the second parameter as the variable `$ACTION`, and the third parameter as the variable `$VERSION`.
[0042] In step S103, the user key is used to log in to the web application machine based on the shell script, and the PHP code files in the final web application directory are pushed to the web application machine.
[0043] Specifically, a shell script is used to call the user key for SSH login to the web application machine, and the code publishing machine uses the shell script to execute the command sh pushwebcod.sh www.xx.com publish 2023070401 to publish PHP code files to the web application machine.
[0044] Furthermore, in some embodiments, after pushing the PHP code files in the final Web application directory to the Web application machine, the process includes: obtaining the number of times the PHP code files have been published; if the number of publications is greater than or equal to a preset number of publications, then reverting the historical version of the PHP code files to the Web application machine.
[0045] The preset number of releases can be a threshold set by the user, a threshold obtained through a limited number of experiments, or a threshold obtained through a limited number of computer simulations. According to the embodiments of this application, the preset number of releases is set to 2.
[0046] It should be understood that using a shell script to obtain the number of times a PHP code file has been published to the web application machine, if the PHP code file has been published more than or equal to 2 times, the PHP code file version can be rolled back to the web application machine.
[0047] Specifically, executing the shell script command `sh pushwebcod.sh www.xx.com list` will display the historical versions of currently published PHP code files, for example, the return value will be 2023070301 2023070401. Then, executing the command `shpushwebcod.sh www.xx.com publish 2023070301` will roll back the publication of the PHP code file version 2023070301 to the web application machine.
[0048] Furthermore, in some embodiments, after the PHP code file is pushed and published to the Web application machine, the method further includes: determining whether the PHP code file and the preset configuration file are both synchronized to the Web application machine's code directory; if the PHP code file and the preset configuration file are both synchronized to the Web application machine's code directory, then the synchronization is successful and the release version number of the PHP code file on the Web application machine is updated; otherwise, a synchronization error is printed.
[0049] The shell script defines the function `_PUBLISH_VERSION_PROJECT` to publish PHP code files to the web application machine. Within this function, the web application machine's code directory variable `$REMOTE_DIR` is defined to view the contents of the file `${ROOTDIR} / ${PROJECT} / info / version` and search for the line `"^${PROJECT}"`, then extract the second column separated by a colon from that line. The function also defines the web machine's IP variable `$_HOSTNAME` to iteratively read the IP addresses from the `${ROOTDIR} / ${PROJECT} / info / hosts` file. Finally, a `while` loop is defined to synchronize the PHP code files to the web application machine's code directory using `RSYNC`.
[0050] `rsync-avzc --delete --exclude-from = ${ROOTDIR} / ${PROJECT} / info / excludefile -e "ssh-i ${USER_KEY}" ${ROOTDIR} / ${PROJECT} / release / ${VERSION} / ${USER_NAME}@${_HOSTNAME}:${REMOTE_DIR})` synchronizes default configuration files to the web application machine directory using `rsync-avzc "ssh-i ${USER_KEY}" ${ROOTDIR} / ${PROJECT} / config / `.
[0051] ${USER_NAME}@${_HOSTNAME}:${REMOTE_DIR}, and record the command return values for synchronizing PHP code files and synchronizing preset configuration files;
[0052] Furthermore, an if statement is defined in the shell script to determine whether RSYNC successfully synchronizes the PHP code file and the preset configuration file. If the synchronization is successful, a success message is printed, and the release version number of the PHP code file on the web application machine is updated using the command (sed -i "s#:${CUR_VERSION}#:${VERSION}#"${ROOTDIR} / ${PROJECT} / info / version); otherwise, a synchronization error is printed.
[0053] The shell script uses the `if` statement to define how to view the names of machines currently capable of publishing web applications: `if [${#VERSION}-eq 0-a${#ACTION}-eq 0-a"x${PROJECT}"=="xlist"]; then`
[0054] / bin / ls${ROOTDIR}| / bin / sed's / / \n / '| / bin / grep-v"$0"
[0055] exit
[0056] fi
[0057] In a shell script, use the if statement to define how to view the current PHP code file version number of the web application machine: `if [${#VERSION}-eq 0-a${#ACTION}-eq 0-a${#PROJECT}-ne 0]; then`
[0058] / bin / cat${ROOTDIR} / ${PROJECT} / info / version| / bin / egrep"^${PROJECT}:"| / bin / cut-d':'-f3
[0059] exit
[0060] fi
[0061] In a shell script, use the if statement to define how to view the historical version numbers of PHP code files published by a web application machine: `if [${#VERSION} -eq 0 -a"x${ACTION}" == "xlist" -a${#PROJECT} -ne 0]; then`
[0062] / bin / ls${ROOTDIR} / ${PROJECT} / release / | / bin / sed's / / \n / '| / bin / egrep-o'[0-9]{8}-[0-9]{2}'
[0063] exit
[0064] fi
[0065] In a shell script, use the if statement to define how to pull PHP code files from an SVN repository to the deployment machine: `if [${#VERSION} -ne 0 -a"x${ACTION}" == "xsvn" -a${#PROJECT} -ne 0]; then`
[0066] _SVN_CHECKOUT
[0067] exit
[0068] fi
[0069] Using if statements in shell scripts to define the distribution of PHP code files to web application machines
[0070] if[${#VERSION}-ne 0-a"x${ACTION}"=="xpublish"-a${#PROJECT}-ne 0]; then CUR_VERSION=$( / bin / cat${ROOTDIR} / ${PROJECT} / info / version| / bin / egrep"^${PROJECT}:"| / bin / cut-d':'-f3)
[0071] _PUBLISH_VERSION_PROJECT
[0072] exit
[0073] fi
[0074] In summary, this application embodiment uses a Shell script to pull PHP code to the Web application directory via SVN, and logs into the Web application machine by calling the SSH user key through the RSYNC of the code publishing machine, and pushes PHP code files to the Web application machine. It can view the name of the currently publishable Web application machine, the version number of the currently published PHP code file on the Web application machine, the historical version number of the published PHP code file on the Web application machine, view a specific version number of the published PHP code file to the Web application machine, and roll back a specific version number of the PHP code file to the Web application machine.
[0075] The method for publishing PHP code for web applications based on Shell scripts, as proposed in this application, involves constructing an initial web application directory, storing the Shell script in the initial web application directory to obtain a new web application directory, using the Shell script to pull PHP code files from the SVN code repository to the new web application directory to obtain the final web application directory, logging into the web application machine using the user key based on the Shell script, and pushing the PHP code files in the final web application directory to the web application machine. This solves the problems of high costs and maintenance costs associated with publishing PHP code for current web application systems during software iteration, as well as the cumbersome, time-consuming, and error-prone traditional manual PHP code publishing process. It reduces maintenance costs and the error rate of manual operations, enabling rapid and accurate automatic PHP code publishing, thus facilitating user access to the web application system.
[0076] Next, referring to the accompanying drawings, an apparatus for publishing PHP code for web applications based on shell scripts according to embodiments of this application is described.
[0077] Figure 4 This is a block diagram of an apparatus for publishing PHP code for a web application based on a Shell script, according to an embodiment of this application.
[0078] like Figure 4 As shown, the device 10 for publishing PHP code for web applications based on shell scripts includes: a build module 100, a pull module 200, and a publishing module 300.
[0079] The module 100 is used to build an initial web application directory and store the shell script in the initial web application directory to obtain a new web application directory; the pull module 200 is used to use the shell script to pull PHP code files from the SVN code repository to the new web application directory to obtain the final web application directory; and the publishing module 300 is used to log in to the web application machine based on the user key using the shell script and push the PHP code files in the final web application directory to the web application machine.
[0080] Optionally, in some embodiments, before building the initial web application directory, the build module 100 is also used to: install the SVN environment and the RSYNC environment, and configure the user key for SSH login to the web application machine.
[0081] Optionally, in some embodiments, after the PHP code files in the final Web application directory are published to the web application machine, the publishing module 300 is further configured to: obtain the number of times the PHP code files have been published; if the number of publications is greater than or equal to a preset number of publications, then roll back the historical version of the PHP code files to the Web application machine.
[0082] Optionally, in some embodiments, after the PHP code files in the final Web application directory are published to the web application machine, the publishing module 300 is further configured to: determine whether the PHP code files and the preset configuration files are both synchronized to the Web application machine's code directory; if the PHP code files and the preset configuration files are both synchronized to the Web application machine's code directory, then print "synchronization successful" and update the publishing version number of the PHP code files on the Web application machine; otherwise, print "synchronization error".
[0083] Optionally, in some embodiments, before building the initial web application directory, the build module 100 is further configured to: receive PHP code files and obtain the access address of the PHP code files in the SVN code repository.
[0084] It should be noted that the foregoing explanation of the method embodiment for publishing PHP code of a web application based on a shell script also applies to the apparatus for publishing PHP code of a web application based on a shell script in this embodiment, and will not be repeated here.
[0085] The apparatus for publishing PHP code for web applications based on Shell scripts, as proposed in this application, constructs an initial web application directory and stores the Shell script in it, resulting in a new web application directory. The Shell script then pulls PHP code files from an SVN repository to this new directory, resulting in the final web application directory. Finally, the Shell script calls the user's key to log in to the web application machine and pushes the PHP code files from the final directory to the web application machine. This solves the problems of high costs and maintenance expenses associated with deploying PHP code during software iterations in current web application systems. Furthermore, the traditional manual PHP code deployment process is cumbersome, time-consuming, and prone to errors. This apparatus reduces maintenance costs and human error rates, enabling rapid and accurate automatic deployment of PHP code, thus facilitating user access to web application systems.
[0086] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device may include:
[0087] The system includes a memory 501, a processor 502, and a computer program stored on the memory 501 and executable on the processor 502. When the processor 502 executes the program, it implements the method for publishing PHP code for a web application based on a shell script, as provided in the above embodiments.
[0088] Furthermore, electronic devices also include:
[0089] Communication interface 503 is used for communication between memory 501 and processor 502.
[0090] The memory 501 is used to store computer programs that can run on the processor 502.
[0091] The memory 501 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage device.
[0092] If the memory 501, processor 502, and communication interface 503 are implemented independently, then the communication interface 503, memory 501, and processor 502 can be interconnected via a bus to complete communication between them. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of representation, Figure 5 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0093] Optionally, in a specific implementation, if the memory 501, processor 502, and communication interface 503 are integrated on a single chip, then the memory 501, processor 502, and communication interface 503 can communicate with each other through an internal interface.
[0094] Processor 502 may be a central processing unit (CPU), an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of this application.
[0095] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the above-described method for publishing PHP code for a web application based on a shell script.
[0096] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0097] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "N" means at least two, such as two, three, etc., unless otherwise explicitly specified.
[0098] Any process or method described in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more N executable instructions for implementing custom logic functions or processes, and the scope of the preferred embodiments of this application includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as should be understood by those skilled in the art to which embodiments of this application pertain.
[0099] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include: an electrical connection having one or more wires (electronic device), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Alternatively, the computer-readable medium may be paper or other suitable media on which the program can be printed, since the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in a computer memory.
[0100] It should be understood that the various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, the N steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0101] Those skilled in the art will understand that all or part of the steps of the methods described in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it includes one or a combination of the steps of the method embodiments.
[0102] Furthermore, the functional units in the various embodiments of this application can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.
[0103] The storage medium mentioned above can be a read-only memory, a disk, or an optical disk, etc. Although embodiments of this application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting this application. Those skilled in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of this application.
Claims
1. A method for publishing PHP code for a web application based on a shell script, characterized in that, Includes the following steps: An initial web application directory is constructed, and the shell script is stored in the initial web application directory to obtain a new web application directory; The shell script is used to pull PHP code files from the SVN code repository to the new web application directory, resulting in the final web application directory; as well as The user key is invoked based on the Shell script to log in to the Web application machine, and the PHP code file in the final Web application directory is pushed and published to the Web application machine; After the PHP code file in the final web application directory is published to the web application machine, the process includes: obtaining the number of times the PHP code file has been published; if the number of publications is greater than or equal to a preset number of publications, then reverting the historical version of the PHP code file to the web application machine. After the PHP code file in the final Web application directory is published to the Web application machine, the method further includes: determining whether the PHP code file and the preset configuration file are both synchronized to the Web application machine's code directory; if the PHP code file and the preset configuration file are both synchronized to the Web application machine's code directory, then the synchronization is successful and the release version number of the PHP code file on the Web application machine is updated; otherwise, a synchronization error is printed.
2. The method according to claim 1, characterized in that, Before building the initial web application directory, the following is included: Install the SVN and RSYNC environments, and configure the user key for SSH login to the web application machine.
3. The method according to claim 1, characterized in that, Before building the initial web application catalog, the following is also included: Receive the PHP code file and obtain the access address of the PHP code file in the SVN code repository.
4. A device for publishing PHP code for web applications based on shell scripts, characterized in that, include: The build module is used to build an initial web application directory and store shell scripts in the initial web application directory to obtain a new web application directory; The pull module is used to pull PHP code files from the SVN code repository to the new web application directory using the shell script, thus obtaining the final web application directory. The publishing module is used to log in to the Web application machine based on the user key using the Shell script, and to push the PHP code file in the final Web application directory to the Web application machine. After the PHP code file in the final Web application directory is published to the Web application machine, the publishing module is further configured to: obtain the number of times the PHP code file has been published; If the number of releases is greater than or equal to the preset number of releases, then the historical version of the PHP code file is rolled back to the Web application machine; After the PHP code file in the final Web application directory is published to the Web application machine, the publishing module is further configured to: determine whether the PHP code file and the preset configuration file are both synchronized to the Web application machine's code directory; if the PHP code file and the preset configuration file are both synchronized to the Web application machine's code directory, then print "synchronization successful" and update the publishing version number of the PHP code file on the Web application machine; otherwise, print "synchronization error".
5. The apparatus according to claim 4, characterized in that, Before building the initial web application directory, the build module is also used to: Install the SVN and RSYNC environments, and configure the user key for SSH login to the web application machine.
6. An electronic device, characterized in that, Including memory and processor; The processor reads executable program code stored in the memory to run a program corresponding to the executable program code, so as to implement the method of publishing web application PHP code based on shell script as described in any one of claims 1-3.
7. A computer-readable storage medium storing a computer program, characterized in that, When executed by the processor, the program implements the method for publishing PHP code for a web application based on a shell script as described in any one of claims 1-3.