mac osx10.9.* 自带了apache, php

Apache配置

1- 启动

sudo apachectl start

启动后,访问 http://localhost/ 应该能看到"It works!"的初始页面,

vi /etc/apache2/httpd.conf

197行可以看到如下代码片段:

<Directory "/Library/WebServer/Documents">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks MultiViews #
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None #
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
</Directory>

cd /Library/WebServer/Documents

It Works 内容在 index.html.en 这是apache的默认页

2- 停止/重启

sudo apachectl stop

sudo apachectl restart

3- 创建个人站点目录

cd ~

mkdir Sites

echo "helloWorld" >> index.html

sudo apachectl restart

然后再访问 http://localhost/~shelley/ 应该就能看到"helloWorld"的个人目录初始页面(注:~shelley需换成~你的用户名

如果失败

sudo vi /etc/apache2/users/Guest.conf

<Directory "/Users/shelley/Sites">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

为何一定是Sites目录名,

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

第10行

# Settings for user home directories
#
# Required module: mod_userdir #
# UserDir: The name of the directory that is appended onto a user's home
# directory if a ~user request is received. Note that you must also set
# the default access control for these directories, as in the example below.
#
UserDir Sites #
# Users might not be in /Users/*/Sites, so use user-specific config files.
#
Include /private/etc/apache2/users/*.conf
<IfModule bonjour_module>
RegisterUserSite customized-users
</IfModule>

4- 启动虚拟主机

默认情况下,apache的虚拟主机功能是关闭的

sudo vi /etc/apache2/httpd.conf

放开注释

#Virtual hosts

#Include /private/etc/apache2/extra/httpd-vhosts.conf

修改文件

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

类似以下内容

NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot "/Users/shelley/Sites"
ServerName www.shelleymyl.com
ErrorLog "/Users/shelley/Sites/log/error.log"
CustomLog "/Users/shelley/Sites/log/access.log" common
<Directory />
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order deny,allow
Allow from all
</Directory>
</VirtualHost>

  

5- URL转发

先打开httpd.conf,确保下面这二行没有被注释掉:

LoadModule proxy_module libexec/apache2/mod_proxy.so
LoadModule proxy_http_module libexec/apache2/mod_proxy_http.so

然后在httpd.conf最后加上

ProxyPass /HelloWorldApp http://localhost:8080/HelloWorldApp/
ProxyPassReverse /HelloWorldApp http://localhost:8080/HelloWorldApp/

这样访问 http://localhost/HelloWorldApp、http://ip/HelloWorldApp、http://www.shelleymyl.com/HellpWorldApp  都相当于访问 http://localhost:8080/HelloWorldApp

6- 端口转发

假如服务器上有一个应用 http://x.x.x.x:8080/ ,如果想通过类似 http://www.shelleymyl.com 的域名来直接访问,就需要做端口转发,仍然打开httpd.conf

LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so

在"5、URL转发"的基础上,再打开这二项

然后修改

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

NameVirtualHost *:80

<VirtualHost *:80>
ProxyPreserveHost On
ServerName www.yjmyzz.com ProxyPass / http://www.yjmyzz.com:8000/
ProxyPassReverse / http://www.yjmyzz.com:8000/ ServerAdmin webmaster@localhost
</VirtualHost>

这样就相当于把 80端口转发到8080端口上了

PHP配置

PHP的配置非常简单,就一个事

vi /etc/apache2/httpd.conf

LoadModule php5_module libexec/apache2/libphp5.so

放开注释

然后sudo apachectl restart 重启,在用户目录的Sites文件夹下,新建一个index.php,里面echo phpinfo() ,就可以看到效果了:

reference:

http://www.cnblogs.com/yjmyzz/p/3920361.html

  

  

MAC OSX10.9.2上搭建Apache,php的更多相关文章

  1. Mac OS X上搭建Apache、PHP、MySQL的Web服务器

    mac OS 系统太帅了,安装php的环境如此简单,大赞一个! 转载自http://jingyan.baidu.com/article/39810a23e1939fb636fda6a9.html 在M ...

  2. Linux平台上搭建apache+tomcat负载均衡集群

    传统的Java Web项目是通过tomcat来运行和发布的.但在实际的企业应用环境中,采用单一的tomcat来维持项目的运行是不现实的.tomcat 处理能力低,效率低,承受并发小(1000左右).当 ...

  3. 在centos 7云服务器上搭建Apache服务器并访问到你的网站

    网站是指在互联网上根据一定的规则,用HTML等语言制作的网页的集合.网站的目的是用来展示一些信息,如果是个人网站则是为了展示自己的一些想被人知道的东西,例如自己的一些作品,又或者是通过网站来达到盈利的 ...

  4. 记录一下在WinXP上搭建Apache的httpd+PHP+MySQL+Wordpress的过程

    实验室有台旧电脑,想用它一台服务器. 不知为何,U盘启动盘死活不能启动,所以放弃了安装Linux的念头,直接在原来的XP上弄一个服务器,毕竟用的人也不多,也就局域网的这几个人, 本来主要是搭建一个FT ...

  5. 在CentOS上搭建apache和PHP服务器环境(转)

    1.您也可以使用一键自动部署环境的工具,请参见网友开发的这个工具 http://www.centos.bz/2013/08/ezhttp-tutorial/ 2. 安装: wget -c http:/ ...

  6. (转载)Windows 上搭建Apache FtpServer

    因工作需要,最近经常接触到FTP,今天我来介绍一个开源的FTP服务器,那就是Apache FTPServer,Apache FTPServer是一个100%纯Java的FTP服务器. 它的设计是基于现 ...

  7. 在阿里云服务器上搭建 Apache Tomat 应用

    在阿里云上购买一台服务器,系统采用 window 2008 Server 企业版,64位 1.下载Java7 JRE,安装 http://www.java.com/zh_CN/download/man ...

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

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

  9. 在centos7云服务器上搭建Apache服务器并访问到你的网站

    使用X-shell ssh安全连接到云服务器 https://mail.qq.com/cgi-bin/mail_spam?action=check_link&url=https://www.n ...

随机推荐

  1. Windows平台下主要的内存管理途径

    new / delete   malloc / free    CoTaskMemAlloc / CoTaskMemFree    IMalloc::alloc / IMalloc/free    G ...

  2. delphi对ini文件的操作(转载 万一)

    ini 文件操作记要(1): 使用 TIniFileunit Unit1;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Gr ...

  3. Introduction to Web Services

    What are Web Services? Web Services are client and server applications that communicate over the Wor ...

  4. Android新浪微博客户端(六)——Home界面的ListView

    原文出自:方杰|http://fangjie.info/?p=184转载请注明出处 最终效果演示:http://fangjie.info/?page_id=54该项目代码已经放到github:http ...

  5. Shopilex - 开源免费网店系统

    Shopilex - 开源免费网店系统 Shopilex是一套基于GPL开源协议的,MVC架构的开源电子商务网店系统,是目前中文领域里真正开源免费的网店系统.

  6. Check the quota usage

    stack@ubuntu1:~/Downloads$ nova absolute-limits +--------------------+------+-------+ | Name | Used ...

  7. JS~字符串长度判断,超出进行自动截取(支持中文)

    今天一个小弟问我的问题,在文本框中输入字符,如果超出指定长度,就把它截取,要求中文等于两个字符的长度,我找一下资料,把这个功能实现了,下面是JS代码: <html> <script ...

  8. 定时关机命令——shutdown

    通常会用到的定时关机命令有两种: Shutdown -s -t 36001小时后自己主动关机(3600秒) at 12:00 Shutdown -s 12:00自己主动关闭计算机 系统定时关机: Wi ...

  9. [转] When exactly does the virtual table pointer (in C++) gets set for an object?

    PS: http://stackoverflow.com/questions/7934540/when-exactly-does-the-virtual-table-pointer-in-c-gets ...

  10. [转] GMT、UTC与24时区 等时间概念

    许多人都知道两地时间表简称为GMT或UTC,而世界时区表则通称为World Time,那么GMT与UTC的实质原意又是为何?世界时区又是怎么区分的?面盘上密密麻麻的英文单字代表着什么意义与作用呢?这些 ...