This article mainly introduces the Mac PHP multi-site configuration, has a certain reference value, now share to everyone, the need for friends can refer to
Write in front:
1. The files need to be modified by default are placed in the hidden folder, you need to search to open, shortcut keys: command+ space, enter "/etc", do not include quotation marks, you can open the ETC folder. The 3 files we need to modify are found in it.
2. Pre-place the project folder under/library/webserver/documents (default path for PHP local server), such as My project:/library/webserver/documents/myobj
Built-in PHP configuration multi-site:
1. Modify the/private/etc/hosts file, it is recommended to open with editor
To add the last line to your website name (custom), refer to the following:
127.0.0.1 www.MyObj.com
2. Modify the/private/etc/apache2/httpd.conf file, it is recommended to open with editor
Find "httpd-vhosts.conf" and find the following code:
#Include conf/extra/httpd-vhosts.conf
Remove the first # and save (you need to enter a password when saving)
3. Modify the/private/etc/apache2/extra/httpd-vhosts.conf file, it is recommended to open with editor
Scroll to the bottom and see the following 2 similar code:
<virtualhost *:80> ServerAdmin webmaster@dummy-host.example.com documentroot "/usr/docs/ Dummy-host.example.com " ServerName dummy-host.example.com serveralias www.dummy-host.example.com Errorlog "/private/var/log/apache2/dummy-host.example.com-error_log" customlog "/private/var/log/apache2/ Dummy-host.example.com-access_log "Common</virtualhost><virtualhost *:80> ServerAdmin webmaster@dummy-host2.example.com documentroot "/usr/docs/dummy-host2.example.com" ServerName dummy-host2.example.com errorlog "/private/var/log/apache2/dummy-host2.example.com-error_log" Customlog "/private/var/log/apache2/dummy-host2.example.com-access_log" common</virtualhost>
After the modification, just copy a paragraph, and then modify the "documentroot " (folder address) and "servername "(Access to the domain name, need to match the first step of the setting) the first paragraph is the new custom domain name, second, the third paragraph is to ensure that the localhost,127.0.0.1 way can still be landed (in fact, is also a custom way, Just write the domain name into custom localhost and 127.0.0.1)
<virtualhost *:80> ServerAdmin webmaster@dummy-host.example.com documentroot "/library/webserver/documents/my OBJ "ServerName www. myobj.com serveralias www.dummy-host.example.com errorlog "/private/var/log/apache2/dummy-host.example.com-error_ Log "Customlog"/private/var/log/apache2/dummy-host.example.com-access_log "common</virtualhost>< VirtualHost *:80> ServerAdmin webmaster@dummy-host.example.com documentroot "/library/webserver/documents" Ser Vername localhost serveralias www.dummy-host.example.com errorlog "/private/var/log/apache2/dummy-host.example.com- Error_log "Customlog"/private/var/log/apache2/dummy-host.example.com-access_log "common</VirtualHost>< VirtualHost *:80> ServerAdmin webmaster@dummy-host2.example.com documentroot "/library/webserver/documents" Se Rvername 127.0.0.1 errorlog "/private/var/log/apache2/dummy-host2.example.com-error_log" Customlog "/private/var/lo G/apache2/dummy-host2.exampLe.com-access_log "common</virtualhost>
4. Restart Apache, terminal command: sudo apachectl restart
5. If you want to add a new domain name, repeat steps 1th and 3rd,
Mamp Configuration Multi-site (Mamp is a PHP environment under the MAC Configuration Integration app, specifically can Baidu)
1. With the built-in shared Hosts file, so the added domain name is also written in this file, refer to the above practice;
2. Another 2 files in the/applications/mamp/conf folder, according to the above method to modify, after the modification, reset.
3. Remark:
Oddly, when you launch the built-in PHP, you can also access the Mamp new domain name, but the file is not a file under Mamp, or a file under a built-in file. Similarly, starting Mamp can also use the built-in PHP new domain name, but the files accessed are not built-in PHP. This is very strange, still need to continue to dig into????? may be associated with a shared hosts file.