Mac OS X Yosemite 10.10 Configuration apache+php

Source: Internet
Author: User
Tags save file phpmyadmin

To view the Apache version of the current system, under terminal input: httpd-v

1. Launch Apache Service

sudo apachectl start

Open Safari, visit: http://localhost, show "It works! "indicates Apache boot normal

The default directory for Apache is currently accessed,/library/webserver/documents/

2. Configure user access to directory

Since the user directory has been previously configured, here is a list of user directories: mkdir ~/sites creates a Sites directory at the root of the current user

You can create a test HTML in the Sites directory, or Cp/library/webserver/documents/index.html.en ~/sites/

Modify the access permissions for the current user directory, which is consistent with the previous version, and here's how to change it:

Cd/etc/apache2/users

sudo vim username. conf

Note: The username here is the current user name, please modify it according to the actual situation

Enter the following:

<directory "/users/username/sites/" >

Options Indexes MultiViews

AllowOverride None

Require all granted

</Directory>

Save file, restart Apache, sudo apachectl restart

Modify access permissions for the current file: sudo chmod 775 username.conf

At this point, open Safari, Access http://localhost/~username/, the page prompts the ~username server does not exist, we also need to go to the next setting

3. Modify the Apache httpd.conf file

cd/etc/apache2/

sudo vim httpd.conf

Locate the following message, and then remove the preceding #:

LoadModule Php5_module libexec/apache2/libphp5.so

LoadModule Authz_core_module libexec/apache2/mod_authz_core.so

LoadModule Authz_host_module libexec/apache2/mod_authz_host.so

LoadModule Userdir_module libexec/apache2/mod_userdir.so

Include/private/etc/apache2/extra/httpd-userdir.conf

Modify/etc/apache2/extra/httpd-userdir.conf

sudo vim/etc/apache2/extra/httpd-userdir.conf

Find the information to fix it and remove it from the previous #:

Include/private/etc/apache2/users/*.conf

At this time access to http://localhost/~username/, still inaccessible, prompt: You do not have permission to access/~username/on the this server.

  

Here is the difference between the new version and the old version, the need to reopen the httpd.conf file,

sudo vim/etc/apache2/httpd.conf

Found it

<directory/>

allowoverride None

Require all denied

</Directory>

Modified to:

<directory/>

allowoverride None

Require all granted

</Directory>

If required. htaccess supports pseudo-static rewirte, you need to open the line of code in httpd.conf:

LoadModule Rewrite_module libexec/apache2/mod_rewrite.so

Note: Under MAC OS system. htaccess files are not created directly, and are hidden!

For example, add pseudo-static to WordPress, such as the following command:

CD ~/sites/wordpress

Touch. htaccess

VI. htaccess

Add the following content:

Rewriteengine on

Rewritebase/~haibor/wordpress/

Rewriterule ^index\.php$-[L]

Rewritecond%{request_filename}!-f

Rewritecond%{request_filename}!-d

Rewriterule. /~haibor/wordpress/index.php [L]

Remember to give permission and restart:

chmod 777. htaccess

sudo apachectl restart

Restart Apache,sudo apachectl Restart

At this time visit: http://localhost/~username/, display: "It works! "Congratulations, Apache configuration is successful!"

4. Configuring Virtual Host Support

Edit Httpd.conf to find

#Include conf/extra/httpd-vhosts.conf Uncomment this line

Edit/etc/apache2/extra/httpd-vhosts.conf

<virtualhost *:80>

#ServerAdmin [email protected]

DocumentRoot "/users/hinet/sites/shanxiang/trunk"

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

<directory "/users/hinet/sites/shanxiang/trunk" > #rewrite需指明路径

Options Indexes followsymlinks MultiViews

AllowOverride all #AllowOverride None to allowoverride all to support. htaccess

Require all granted

</Directory>

</VirtualHost>

<virtualhost *:80>

#ServerAdmin [email protected]

DocumentRoot "/users/hinet/sites/phpmyadmin"

ServerName phpmyadmin.com

#ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log"

#CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common

<directory/>

Options Indexes followsymlinks MultiViews

AllowOverride None

Order Deny,allow

Allow from all

Require all granted

</Directory>

</VirtualHost>

Edit the/etc/hosts file, add

127.0.0.1 phpmyadmin.com

  

5. Configure PHP

  Cd/etc

sudo cp/etc/php.ini.default/etc/php.ini

  sudo apachectl restart

Create a info.php file to test if PHP is installed successfully

CD ~/sites

Vim info.php

Enter the following information:

<body>

<?php phpinfo ();?>

</body>

Open the browser, Access http://localhost/~username/info.php, display a message indicating that the PHP installation configuration is successful ~

Mac OS X Yosemite 10.10 Configuration apache+php

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.