For Nginx, include the virtual host configuration in the master configuration nginx.conf:
Include sites-enabled/*.conf;
When creating a new virtual host, create a new file in the Sites-enables, such as:
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, access to the www.a.com will reverse proxy to the back-end Apache monitoring 8080 processing.
with Nginx forwarding, you can run multiple versions of Apache (PHP) on a single server, as long as Apache listens on different ports.
For example, Apache (PHP5.4) listens on the port is 8081, that needs the PHP5.4 support user website to generate the Nginx virtual host configuration to forward to 8081 port.
The Apache Master profile httpd.conf is loaded into the virtual host configuration:
Include conf/extra/httpd-vhosts.conf
There are cofn files in the httpd-vhosts.conf that are loaded into the vhosts:
Include conf/extra/vhosts/*.conf
Inside the conf/extra/vhosts/a.com.conf virtual host:
<virtualhost *:8080>
ServerAdmin [email protected]
DocumentRoot "/png/www/a.com/public_html"
ServerName www.a.com
Serveralias a.com
Errorlog "/png/www/a.com/logs/httpd_error_log"
Customlog "/png/www/a.com/logs/httpd_access_log" combined
<directory "/png/www/a.com/public_html" >
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
/png/www/a.com is the directory of the virtual host, the public_html is the root directory, for the virtual host users to assign a directory of FTP users, such as the use of proftpd ftpasswd to generate an account:
http://my.oschina.net/eechen/blog/303398
The development of a virtual host management system, is simply called adduser/ftpasswd generation of FTP accounts, as well as the generation of Nginx and Apache virtual host configuration, generated after the use of nginx-t and httpd- s tests if the configuration is correct after the overloaded service takes effect. PHP provides a number of file system operation functions and string processing functions (replacement/Regular match), PHP has good support for the database,It is also convenient to store the user information of the virtual host.
The idea of developing virtual host management system in PHP