MAC升级到最新系统后 本地测试的站点不能正常运行,其原因是mac系统升级后 他的apache的版本也随之升级了版本

Server version: Apache/2.4.9 (Unix)

Server built:   Sep  9 2014 14:48:20

升级前的版本为 10.9

Server version: Apache/2.2.26 (Unix)
Server built:   Dec 10 2013 22:09:38 基本上之前配置的block都被覆盖了
所以导致站点不能正常工作
解决办法是
1 重新启用php 以避免php的脚本文件直接显示到网页上
1
sudo mvim /etc/apache2/httpd.conf
打开文件后 回车 输入 
/LoadModule php5_module libexec/apache2/libphp5.so
再文件中找到该行 去掉前面的#
保存即可 2、开启支持用户级目录 http://localhost/~username/ 用户级目录不能访问了
Not Found
The requested URL /~zhuzi/ was not found on this server.
配置用户级目录的.conf(一般会在用户级的根目录下有一个~/Sites)的目录 该目录就是用户级的站点 
没有的话需要重新创建
sudo mkdir ~/Sites
这时需要配置zhuzi.conf
sudo mvim /etc/apache2/users/zhuzi.conf 

添加如下代码(10.10)配置方式

1
2
3
4
5
<Directory "/Users/zhuzi/Sites/">
    Options Indexes MultiViews
    AllowOverride None
    Require all granted
</Directory>

然后更改目录权限

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

还需要配置 httpd.conf

sudo mvim /etc/apache2/httpd.conf

通过vim的查找命令找到一下几个块去掉前面的#

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

配置httpd-userdir.conf

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

将这个块前的#去掉

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

重启apache

1
sudo apachectl restart

这是就能访问

http://localhost/~zhuzi/

最后

<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 is 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 is done easier in the Terminal either using nano or viwith sudo or as a root user,  or you can you a GUI visual editor like Text Wrangler which allows access to the /private/etc directory by clicking ‘Show 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 hosts

Include /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 virtual host:

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

We can take this example and extend on it, if you wanted a domain named apple.com for example, you can copy the existing text 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 web@coolestguidesontheplanet.com
</VirtualHost>

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

Now also you 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 virtual hosts is that once set up you lose your older document root previously at /LIbrary/WebServer/Documents or accessed in the browser athttp://localhost what happens is that you get a 403 Forbidden Error. But the ~/username document root is still compatible.

To get around this, you need to add in a vhost for localhost and declare this vhost before any of the others, in the same file:

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

Add in:

<VirtualHost *:80>
ServerName localhost
DocumentRoot /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 is the permissions issues with things like updates and authentication.

This is because the default webserver user which runs httpd is known as _www, which will not be the user in your local account. If your machine is only in use by you and the webserver will run only under your account then you can change the user.

Find Your User and Group

In the Terminal use the id command to see your username and group

id

You will 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 you are running httpd as your local account.

 

MAC 升级到10.10(OS X Yosemite)下apache+php的配置问题的更多相关文章

  1. PHP初步:在Mac OS X Yosemite下搭建Apache+PHP+Mysql

    Mac OS X是基于unix的操作系统,很多软件都集成在系统中.所以,对于配置PHP的开发环境相对于windows和Linux更简单. 1. 启动Apache服务器 打开终端(terminal),查 ...

  2. Mac 软件专题之:OS X Yosemite 精彩应用软件推荐

    目前,很多软件都已经发布了针对Yosemite系统的版本,今天和大家分享专题:「OS X Yosemite 精彩应用」,主要分享适配Yosemite系统全新的扁平化界面和新功能的软件,但要知道未在此专 ...

  3. OS X Yosemite下安装Hadoop2.5.1伪分布式环境

    最近开始学习Hadoop,一直使用的是公司配好的环境.用了一段时间后发现对Hadoop还是一知半解,故决定动手在本机上安装一个供学习研究使用.正好自己用的是mac,所以没啥说的,直接安装. 总体流程 ...

  4. Mac OS X终端下apache操作

    重启apache:sudo /usr/sbin/apachectl restart 关闭apache:sudo /usr/sbin/apachectl stop 开启apache:sudo /usr/ ...

  5. 如何在 OS X Yosemite 中安装 Java

    如果你的 Mac 纯净的安装了 OS X Yosemite 的话,其中是不会包含 Java 的,如果你的 Mac 需要安装 Java 环境的话,可以通过下面介绍的两种方法来实现.通过手动安装最新版 J ...

  6. Mac OS 10.10 Yosemite正式版怎么升级 升级教程

    苹果在2014年10月17号凌晨一点召开了新品发布会,推出了新的 iPad.iMac 产品,以及大家一直所期盼的 Mac OS 10.10 正式版系统.个人是从 Mac OS 10.10 的第一个测试 ...

  7. 简单制作 OS X Yosemite 10.10 正式版U盘USB启动安装盘方法教程 (全新安装 Mac 系统)

    原文地址: http://www.iplaysoft.com/osx-yosemite.html 简单制作 Mac OS X Yosemite 正式版 USB 启动盘的方法教程: 其实制作 OS X ...

  8. 在Mac OS X Yosemite 10.10.3 中搭建第一个 ASP.NET 5 Web 项目

    终于有时间在 Mac 上安装一下 ASP.NET 5,网上有许多教程,但是多数的时间比较早了,版本不是最新,搭着 Build 2015 的春风,我也实践一下 Mac OS X 上的 ASP.NET 5 ...

  9. Mac OS X 10.10.2 Yosemite jdk 环境变量配置

    我的Mac系统版本是OS X 10.10.2 Yosemite,为了用Eclipse做android开发,安装了jdk 1.7, 但是如果想使用IntelliJ IDE做android开发的话,就需要 ...

随机推荐

  1. Gstreamer基本概念介绍(开发前必读)

    1. 元件(Elements) 元件(element)是GStreamer中最重要的概念.你可以通过创建一系列的元件(Elements),并把它们连接起来,从而让数据流在这个被连接的各个元件(Elem ...

  2. hdu 4409 LCA

    思路:就是个比较裸的LCA了,不过要注意的是,如果a和b的公共祖先是a,那么答案就是farther[a]. #include<cstring> #include<cmath> ...

  3. Android渠道汇总

    序号 渠道名  渠道说明 特殊渠道   1 googleplay  google市场 2 umeng  自动更新 3 office_web  官方网络 4 office_qrcode 官方二维码 硬件 ...

  4. Oracle数据库作业-6 29、查询选修编号为“3-105“课程且成绩至少高于选修编号为“3-245”的同学的Cno、Sno和Degree,并按Degree从高到低次序排序。 select tname,prof from teacher where depart = '计算机系' and prof not in ( select prof from teacher where depart 。

    29.查询选修编号为"3-105"课程且成绩至少高于选修编号为"3-245"的同学的Cno.Sno和Degree,并按Degree从高到低次序排序. selec ...

  5. asp.net EF model中的默认值设置

    在做数据库规划时,通常会规划一些系统字段,也就是由数据库本身自行指定默认值到这个字段上,创建新的“创建时间(CreateDate)”字段就会常常这样设计. 如果希望能有默认值,且让.net 程序在新增 ...

  6. 跟我一起学习ASP.NET 4.5 MVC4.0(一)(转)

    由于上面一个项目使用的是ASP.NET4.0 MVC3.0,在招人的时候发现很多人有听说过MVC,但是却是没用过,对MVC也只是一知半解,最近想给团队成员做一个系统的解说,让大家都可以学习一下ASP. ...

  7. web.config connectionStrings 数据库连接字符串的解释

    先来看一下默认的连接SQL Server数据库配置<connectionStrings>   <add name="LocalSqlServer" connect ...

  8. 使用Struts2 验证框架,验证信息重复多次出现

    版权声明:本文为博主原创文章,未经博主允许不得转载. 问题描述:第一次提交表单.某个数据不符合规则,就会出现一条错误信息.再次提交,上次显示的错误信息不消失,又多出一条一模一样的错误信息.提交几次,就 ...

  9. [转]基于SQL脚本将数据库表及字段提取为C#中的类

    开发时,勉不了需要使用SQL直接与数据库交互,这时对于数据库中的表名及字段名会使用的比较多.如果每使用一次都复制一个,实在蛋疼.所以就考虑将其做成const常量.但是数据库中的表和字段相当多,一个一个 ...

  10. 10款基于jquery实现的超酷动画源码

    1.jQuery二级下拉菜单 下拉箭头翻转动画 之前我们分享过不少基于jQuery的二级下拉菜单,甚至是多级的下拉菜单,比如这款jQuery/CSS3飘带状多级下拉菜单就非常华丽.但今天要介绍的这款j ...