Home > Backend Development > PHP Problem > How to change php default directory under mac

How to change php default directory under mac

王林
Release: 2023-03-10 17:58:02
Original
2504 people have browsed it

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. .

How to change php default directory under mac

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
Copy after login

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"
Copy after login

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
Copy after login

Find the /private/etc/apache2/httpd.conf file and change

Options FollowSymLinks Multiviews
Copy after login

to

Options FollowSymLinks Multiviews Indexes
Copy after login

Restart apache server

sudo apachectl restart
Copy after login

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!

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