MAC upgrade to 10.10 (OS X Yosemite) apache+php configuration issues

Source: Internet
Author: User
Tags php and mysql 403 forbidden error

The locally tested site does not function properly after upgrading to the latest system, because the version of his Apache is upgraded with the MAC system upgrade

Server version:apache/2.4.9 (Unix)

Server built:sep 9 2014 14:48:20

The version before upgrade is 10.9

Server version:apache/2.2.26 (Unix) Server Built:dec 10 2013 22:09:38

Basically, the previously configured block was overwritten.
So the site doesn't work properly
The solution is
1 re-enable PHP to prevent PHP script files from appearing directly on the Web page
1 sudo mvim /etc/apache2/httpd.conf

/loadmodule Php5_module libexec/apache2/libphp5.so
Find the line in the file and remove the previous #
Save As you can

2. Open the Support User level directory http://localhost/~username/

The user-level directory cannot be accessed
Not foundthe requested the URL/~zhuzi/was not found on the this server.

No, you need to recreate it.
sudo mkdir ~/sites
At this point you need to configure zhuzi.conf

Add the following code (10.10) to configure the method

12345 <Directory "/Users/zhuzi/Sites/">    Options Indexes MultiViews    AllowOverride None    Require all granted</Directory>

Then change the directory permissions

sudo chmod 775/etc/apache3/users/zhuzi.conf

You also need to configure httpd.conf

sudo mvim/etc/apache2/httpd.conf

Find a few blocks with Vim's find command to remove the previous #

LoadModule authz_core_module libexec/apache2/mod_authz_core.soloadmodule authz_host_module libexec/apache2/mod_ Authz_host.soloadmodule Userdir_module libexec/apache2/mod_userdir.soinclude/private/etc/apache2/extra/ Httpd-userdir.conf

Configure httpd-userdir.conf

1 sudo nano /etc/apache2/extra/httpd-userdir.conf

Remove the # from the front of the block

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

Restart Apache

1 sudo apachectl restart

This is where you can access

http://localhost/~zhuzi/

At last

<directory/>

allowoverride None

# Require all denied

Require all granted

</Directory>

How to set up Virtual Hosts in Apache on Mac OSX 10.10 Yosemite

http://coolestguidesontheplanet.com/set-virtual-hosts-apache-mac-osx-10-10-yosemite/

Setting up Virtual Hosts in Apache on Mac OSX 10.10 Yosemite are straight forward after you have your local WEB development   Environment up and running–get your web development up and running first including Apache, PHP and MySQL following this AMP Stack Guide here 10.10 if required.

The process of setting up Virtual Hosts was done easier in the Terminal either using nano or Viwith sudo or as a root user, Or you can do a GUI visual editor like Text Wrangler which allows access to the/private/etc directory by clicking ' Sho W everything "In the Open dialog box.

Allow the vhosts configuration from the Apache configuration file httpd.conf

Open the httpd.conf

sudo nano/etc/apache2/httpd.conf

Search for 'vhosts' and uncomment the include line

# Virtual Hostsinclude/private/etc/apache2/extra/httpd-vhosts.conf

Also allow another module to run by uncommenting:

LoadModule Vhost_alias_module libexec/apache2/mod_vhost_alias.so
Edit the vhosts.conf file

Open this file to add in the Vhost.

sudo nano/etc/apache2/extra/httpd-vhosts.conf

An example in the file is given of the format required to add additional domains, just follow this to create your new virt UAL Host:

<virtualhost *:80>serveradmin [Email protected]documentroot "/usr/docs/dummy-host2.example.com" ServerName Dummy-host2.example.comerrorlog "/private/var/log/apache2/dummy-host2.example.com-error_log" CustomLog "/private/ Var/log/apache2/dummy-host2.example.com-access_log "common</virtualhost>

We can take this example and extend in it, if you wanted a domain named apple.com for example, you can copy the existing T Ext block and edit to suit:

<virtualhost *:80>    ServerName apple.com    serveralias www.apple.com    documentroot "/users/username/ Sites/apple "    errorlog"/private/var/log/apache2/apple.com-error_log "    customlog"/private/var/log/apache2 /apple.com-access_log "Common    ServerAdmin [email protected]</virtualhost>

The example above a vhost for apple.com are created and the document root is in the Sites folder, in the text block a Bove I has also added in some log files, what are need to change are the document root location username and Domain name to suit your needs. Finish and save the file.

Now also your need to map the IP address to be the localhost.

Map Your IP address to localhost
sudo nano/etc/hosts

Add the Domain and ' www ' Alias to resolve to the localhost address

127.0.0.1 apple.com www.apple.com

Restart Apache
sudo apachectl restart

Check out your local vhost domain in the browser

Losing Localhost

One caveat to note about the virtual hosts is this once set up lose your older document root previously At/library/webser ver/documents or accessed in the browser athttp://localhost What happens is so you get a 403 Forbidden Error. But the ~/username document root is still compatible.

To-get around this, need-to-add in a vhost for localhost and declare this vhost before all of the others, in the same File

sudo nano/etc/apache2/extra/httpd-vhosts.conf

Add in:

<virtualhost *:80>servername localhostdocumentroot/library/webserver/documents/</virtualhost>
Restart Apache
sudo apachectl restart
Changing the WebServer Default User

One of the frustrations of using the Users/username/sites folder for Vhosts are the permissions issues with things like upd Ates and authentication.

This is because the default webserver user which runs httpd are known as _WWW, which'll not being the user in your local ACC Ount. If your machine was only with use by and the webserver would run only under your account then you can change the user.

Find Your User and Group

In the Terminal with the ID command to see your username and group

Id

You'll get a bunch of user groups, you need your primary user uid and group GID names

uid=502 (Admin) gid=20 (staff)

Change this back in/etc/apache2/httpd.conf

Restart Apache
sudo apachectl restart

Restart Apache and now is running httpd as your local account.

MAC upgrade to 10.10 (OS X Yosemite) apache+php configuration issues

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.