How to build a php production environment that can prevent operational errors?

the company uses Aliyun"s ECS server, which used to be a server (centos7) + a disk, and the environment and code were all put together. Once, when configuring the environment, the system file was deleted by mistake, so that the system could not boot. Later, the data from the disk was taken out, and the environment was reinstalled in the server that put the mysql data and project code in the heart. It took a day before the website could be accessed.
restart Aliyun today. As a result, all the files and environment of the server are inexplicably restored to the code that went wrong a few months ago. The data accessed by users are all the code from a few months ago, and Ali Yunfang doesn"t know why. Fortunately, this time the database files were backed up to other disks to recover the data.

I just want to ask, how should the project be deployed? for example, if you configure a file now, and then accidentally delete the system file, people cannot access the server, but the data on the data disk is fine

.


may not describe very clearly, draw a diagram: I do not know if this is better, can avoid data loss caused by server problems, and can recover faster.

clipboard.png

the company is a small company, but also the first job, the company is only a programmer, I do not have much experience, I hope you can give some suggestions, thank you.

Mar.09,2021

because it is a small company + single programmer, I only give you what you can do alone:

  1. the online deployment process is fully automated;
  2. all runtime environments except code are implemented using Docker;
  3. since it is Aliyun, open a regular snapshot of Aliyun.

sounds scary, but the actual cost of learning is very low, and the benefits of learning are very large. It doesn't matter if you are php-web or java-web or node-web or py-web,.

the following are the knowledge points that will be involved:

  1. (basic, major premise) Linux basic knowledge, Shell scripting
  2. Git version control, GitHub/GitLab version repository, CI/CD continuous deployment (Jenkins)
  3. Docker (Docker cmd, Dockerfile, Docker-compose), you don't need to learn cluster-related
  4. like K8s.
  5. use and management of virtual machines, VMWARE, install a vmware workstation, locally or install a vmware exsi (on a company server for free, highly recommended), learn how to manage virtual machines

these are all things that one person can do, with a lot of learning materials and great personal benefits.


if conditions permit, it is recommended that the servers be placed separately, the application servers put the production environment code, and the persistent storage servers such as databases, file services, etc., and then the code can be stored on a separate git server; that is, all kinds of services are separated to avoid devastating damage caused by problems with the stand-alone version.

then the development line, test line, production, to their own strict standards, but also can avoid a lot of problems, although only their own person, but I think it is still necessary.
prepare your data for disaster so that you can recover if something goes wrong. The database can be deployed as a slave database for disaster recovery, etc., and files can be backed up regularly.

the most important thing is to improve the ability of operation and maintenance and reduce the probability of problems, otherwise you will just back up, restore, backup and restore all day long.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1be8d87-3194e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1be8d87-3194e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?