How to Use PHP or shell to automatically add a domain name to nginx

Source: Internet
Author: User
Tags call shell
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.

  1. Vi nginx. conf
  2. Modify the server block inserver_nameAdd the domain name to be bound, for example:
    server_name test.com admin.com;
  3. Reload nginx
    nginx -s reopen

How can I automate the above process through PHP? How can I tell nginx to myself?server_nameAdd 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.

  1. Vi nginx. conf
  2. Modify the server block inserver_nameAdd the domain name to be bound, for example:
    server_name test.com admin.com;
  3. Reload nginx
    nginx -s reopen

How can I automate the above process through PHP? How can I tell nginx to myself?server_nameAdd 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.