Deploy PHP app
Deploy Your PHP application
To deploy PHP application on LAMP, you need to add VirtualHost for it
VirtualHost is vhost configuration segment. Each application must correspond to a unique VirtualHost in vhost.conf / default.cong
- Apache vhost configuration file: /etc/httpd/conf.d/vhost.conf
- Nginx vhost configuration file: /etc/nginx/conf.d/default.conf
Overall, just need two steps:
- Upload source codes of applicaiton
- Add new VirtualHost vhost configuration segment
- Apache VirtualHost :
<VirtualHost *:80>...</VirtualHost>
- Nginx VirtualHost :
server{}
Deploy fisrt application
There is a example application in LAMP, we sugget you to replace the example application for deploy first application:
-
Use WinSCP to connect Cloud Server
-
Delete all files in the folder /data/wwwroot/www.example.com, but don't delete www.example.com
-
Upload your application's codes to the folder: /data/wwwroot/www.example.com
-
Modify the virtual host configuration file to realize operations such as binding domain and modifying website directory
-
Save virtual host configuration file and then restart service
# restart Apache
systemctl restart httpd
# restart Nginx
systemctl restart httpd -
Using the Chrome or Firefox to visit: http://domain or http://IP/mysite2 to visit your application
Deploy second application
Start to deploy the second application, you should add new VirtualHost segment to the file vhost.conf
-
Use WinSCP to connect Cloud Server,create a new "mysite2" website directory under /data/wwwroot
-
Upload your application's codes to the folder::/data/wwwroot/mysite2
-
Edit the Virtual machine host configuration file file to get the code snippet according to the scenario:
Web Server 场景 获取代码段 Apache 有域名,通过 http://域名 访问网站 获取 没有域名,通过 http://IP/mysite2 访问网站 获取 Nginx 有域名,通过 http://域名 访问网站 获取 没有域名,通过 http://IP/mysite2 访问网站 获取 -
Save virtual host configuration file and then restart service
# restart Apache
systemctl restart httpd
# restart Nginx
systemctl restart httpd -
Using the Chrome or Firefox to visit: http://domain or http://IP/mysite2 to visit your application
Deploy more application
Deploy more application is the same with Deploy second application
Finally, we know the new and summarize the steps of the LAMP deployment site:
- Upload the website code
- Bind the domain name (not necessary)
- Add the site configuration or modify the sample site configuration
- Increase the database corresponding to the site (not necessary)
- Enter the installation wizard
Maintain PHP Environment
Refer to:《PHP Guide》 and 《PHP Advanced》