Requirement: bind the manually entered domain name to the local machine through PHP. Requirement: The nginx domain name must be bound to ving.pdf in general security situations. conf: Modify the server block and add the domain name to be bound to server_name, for example, server_nametest.comadmin.com; reload ngi... requirement: bind the manually entered domain name to the local machine through PHP
Requirements: Security
This is usually required for nginx to bind a domain name.
- Vi nginx. conf
- Modify the server block in
server_name
Add the domain name to be bound, for example:
server_name test.com admin.com;
- Reload nginx
nginx -s reopen
How can I automate the above process through PHP? How can I tell nginx to myself?server_name
Add the domain name to be bound and re-load the configuration file?
Reply content:
Requirement: bind the manually entered domain name to the local machine through PHP
Requirements: Security
This is usually required for nginx to bind a domain name.
- Vi nginx. conf
- Modify the server block in
server_name
Add the domain name to be bound, for example:
server_name test.com admin.com;
- Reload nginx
nginx -s reopen
How can I automate the above process through PHP? How can I tell nginx to myself?server_name
Add the domain name to be bound and re-load the configuration file?
You can use php to modify the configuration file, or use php to call commands to modify the configuration file, or write a C program with the root owner and u + s permissions to call php, to avoid running php scripts directly as root.
It is more convenient to use php to call shell scripts. php is just a caller and all things are done by another shell script, which is safe.
In addition, you can use crontab to regularly run the shell script to check whether a domain name adding task is generated by php. In this way, php does not have a clear call relationship with the script that executes the Add task.