Idea of developing a virtual host management system using PHP
Source: Internet
Author: User
The idea of developing a virtual host management system in PHP is Nginx. The main configuration nginx. conf contains the virtual host configuration:
Include sites-enabled/*. conf;
When creating a VM, create a file in sites-enables, for example:
Sites-enabled/a.com. conf
Server {
Listen 80;
Server_name www.a.com;
Location /{
Proxy_set_header X-Real-IP $ remote_addr;
Proxy_set_header X-Forwarded-For $ remote_addr;
Proxy_set_header Host $ host;
Proxy_pass http: // 127.0.0.1: 8080;
}
}
That is, when www.a.com is accessed, it will reverse proxy to the backend Apache for 8080 processing.
Nginx forwarding allows you to run multiple versions of Apache (PHP) on one server, as long as Apache listens to different ports. For example, if the port listened by Apache (PHP5.4) is 8081, the user websites supported by PHP5.4 are forwarded to Port 8081 when the Nginx virtual host configuration is generated.
Load the VM configuration in the Apache Main configuration file httpd. conf:
Include conf/extra/httpd-vhosts.conf
The httpd-vhosts.conf contains the cofn file for loading vhosts:
Include conf/extra/vhosts/*. conf
Conf/extra/vhosts/a.com. conf VM:
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
/Png/www/a.com is the Directory of the VM, and public_html is the root directory. assign an FTP user to the VM user, for example, use the ftpasswd of ProFTPD to generate an account:
Developing a virtual host management system is nothing more than calling adduser/ftpasswd to generate an FTP account and Nginx and Apache virtual host configuration, use nginx-t and httpd-S to test whether the configuration is correct and then the heavy load service takes effect. PHP provides many file system operating functions and string processing functions (replacement/regular expression matching). PHP provides good support for databases, and it is naturally convenient to store user information on virtual hosts.
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.