Home > Article > Backend Development > How to change php default directory under mac
The method to change the default directory of PHP under mac is: first open the configuration file and create the Sites folder under the user name; then modify the DocumentRoot attribute and add relevant code to the configuration file; finally restart the apache server. .
The operating environment of this article: Mac OS X 10.10.1 system, PHP 5.6&&Apache 2.4.2, macbook pro computer.
We all know that after setting up a php server on a mac, the default path is generally /Library/WebServer/Documents. But for some needs, we may need to modify the default path, so how should we do it? Let’s take a look.
Assumption: The user name of mac is MuyunLee. The following uses tangjr as an example.
The specific steps are as follows:
Open the file /private/etc/apache2/httpd.conf
Find
LoadModule userdir_module libexec/apache2/mod_userdir.so
and remove
Create the folder Sites under the user name
Modify the DocumentRoot in the /private/etc/apache2/httpd.conf file to:
DocumentRoot "/Users/MuyunLee/PHPWorkSpace"
Create the file /private/etc/apache2 /users/MuyunLee.conf
and enter the following code in the file
Options Indexes MultiViews AllowOverride All Require all granted # OSX 10.10 / Apache 2.4
Find the /private/etc/apache2/httpd.conf file and change
Options FollowSymLinks Multiviews
to
Options FollowSymLinks Multiviews Indexes
Restart apache server
sudo apachectl restart
Free video tutorial sharing: Programming video
The above is the detailed content of How to change php default directory under mac. For more information, please follow other related articles on the PHP Chinese website!