mac PHP multi-site configuration

不言
Release: 2023-03-23 21:26:01
Original
2239 people have browsed it

This article mainly introduces mac PHP multi-site configuration, which has certain reference value. Now I share it with everyone. Friends in need can refer to it

Write in front:

1. Files that need to be modified are placed in hidden folders by default and need to be opened by searching. Shortcut key: command + space, enter "/etc" without quotation marks, and you can open the etc folder. . The three files we need to modify can be found in it.


2. Place the project folder under /Library/WebServer/Documents in advance (the default path of the php local server ), for example my project: /Library/WebServer/Documents/MyObj


Built-in PHP configuration multi-site:

1. Modify the /private/etc/hosts file. It is recommended to open it with an editor. Add your website name (customized) to the last line of

. The reference is as follows:

127.0.0.1 www.MyObj.com


2. Modify the /private/etc/apache2/httpd.conf file. It is recommended to open it with an editor

Look for "httpd- vhosts.conf", find the following code:

#Include conf/extra/httpd-vhosts.conf


##Remove the leading # 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 it with an editor

Scroll to the bottom and see the following two similar pieces of 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>
Copy after login


After modification, it is as follows. In fact, it is just copying a paragraph and then modifying "

DocumentRoot" (folder address) and "ServerName" (to access the domain name, it needs to match the settings in the first step). The first paragraph is the newly added custom domain name, the second and third paragraphs are In order to ensure that localhost, 127.0.0.1 can still be used to log in (actually it is also a custom method, but the domain name is specially written as the customary localhost and 127.0.0.1)

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "/Library/WebServer/Documents/MyObj"
    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"
    ServerName 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"
    ServerName 127.0.0.1
    ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log"
    CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common
</VirtualHost>
Copy after login


4. Just restart apache. Terminal command: sudo apachectl restart


5. If you want to add a new domain name, repeat steps 1 and 3,


mamp configures multi-site (mamp is a PHP environment configuration integrated app under mac, specifically Baidu)

1. Share hosts with built-in file, so the added domain name is also written into this file, just refer to the above method;

2. The other two files are in the /Applications/MAMP/conf folder, modify them according to the above method. Yes, reset after modification is completed.

3. Note:

The strange thing is that when starting the built-in PHP, you can also access the domain name created by mamp, but the file is not a file under mamp, but a built-in file. document. Similarly, when starting mamp, you can also use the newly created domain name of the built-in PHP, but the files accessed are not built-in PHP. This is very strange. Do we need to study further? ? ? ? ? It may be related to the shared hosts file.

Related recommendations:

MAC new site configuration PHP environment


The above is the detailed content of mac PHP multi-site configuration. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!