Alibaba Cloud virtual host deployment php project sharing

I read a lot on the Internet about how to deploy php projects to cloud servers. Most of the answers and articles are to configure the php runtime environment first, and then what to do. Because I am using Alibaba Cloud's exclusive virtual host, it is directly uploaded to the server code, and it is OK to import the data table.

   Since it is the first time to deploy php to a cloud server, I have been looking for a day's tutorial and watching it in a fog. Finally, I tried to deploy directly from the many answers, which is what I said above.

The first step is to log in to Alibaba Cloud and click Host Management Platform > Database Information > Management > Import. There may be errors in utf8mb4 when importing here. The answer I searched basically said that the format in the sql file has this. But my sql file is full of utf8. Only one comment has the field utf8mb4, try to change it to utf8, re-import it in the Alibaba Cloud database, success! 

The second step uploads the php project code to the server. (My virtual host is a linux system. Regarding the deployment of php in the windows system, you can set up the transfer system in Alibaba Cloud.) FileZilla is used, and the root directory is htdocs. Just upload your files to this directory. Regarding whether you need to take out index.php separately and put it in the root directory, it depends on your needs. If you need to open index.php after direct domain name access, take it out. I don't have it, I access it directly in the format of domain name + file name + index.php. When uploading the php project code, refer to Alibaba Cloud's solution. https://help.aliyun.com/knowledge_detail/36242.html?spm=a2c4g.11186623.4.2.VXEvNH . Because it is really slow to upload directly without compression, it is very easy to use according to his official method.

The third step is to modify the configuration file and others. If your php project database configuration file needs to be modified, pay attention to the database 'DB_HOST' address field. His address is the host management platform>database information> database address.  At that time, I wrote it as the IP address of the virtual host. If the error SQLSTATE[HY000] [2002] Connection refused is reported, and you have no problem running locally, it is possible that the configuration file was written. wrong.   embarrassment

After a day of fiddling, my head is dizzy, and I write this in a long way. Hope it can help programmers with the same problemgood at

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324845515&siteId=291194637