MAC OSX10.9.2上搭建Apache,php
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的更多相关文章
- Mac OS X上搭建Apache、PHP、MySQL的Web服务器
mac OS 系统太帅了,安装php的环境如此简单,大赞一个! 转载自http://jingyan.baidu.com/article/39810a23e1939fb636fda6a9.html 在M ...
- Linux平台上搭建apache+tomcat负载均衡集群
传统的Java Web项目是通过tomcat来运行和发布的.但在实际的企业应用环境中,采用单一的tomcat来维持项目的运行是不现实的.tomcat 处理能力低,效率低,承受并发小(1000左右).当 ...
- 在centos 7云服务器上搭建Apache服务器并访问到你的网站
网站是指在互联网上根据一定的规则,用HTML等语言制作的网页的集合.网站的目的是用来展示一些信息,如果是个人网站则是为了展示自己的一些想被人知道的东西,例如自己的一些作品,又或者是通过网站来达到盈利的 ...
- 记录一下在WinXP上搭建Apache的httpd+PHP+MySQL+Wordpress的过程
实验室有台旧电脑,想用它一台服务器. 不知为何,U盘启动盘死活不能启动,所以放弃了安装Linux的念头,直接在原来的XP上弄一个服务器,毕竟用的人也不多,也就局域网的这几个人, 本来主要是搭建一个FT ...
- 在CentOS上搭建apache和PHP服务器环境(转)
1.您也可以使用一键自动部署环境的工具,请参见网友开发的这个工具 http://www.centos.bz/2013/08/ezhttp-tutorial/ 2. 安装: wget -c http:/ ...
- (转载)Windows 上搭建Apache FtpServer
因工作需要,最近经常接触到FTP,今天我来介绍一个开源的FTP服务器,那就是Apache FTPServer,Apache FTPServer是一个100%纯Java的FTP服务器. 它的设计是基于现 ...
- 在阿里云服务器上搭建 Apache Tomat 应用
在阿里云上购买一台服务器,系统采用 window 2008 Server 企业版,64位 1.下载Java7 JRE,安装 http://www.java.com/zh_CN/download/man ...
- PHP初步:在Mac OS X Yosemite下搭建Apache+PHP+Mysql
Mac OS X是基于unix的操作系统,很多软件都集成在系统中.所以,对于配置PHP的开发环境相对于windows和Linux更简单. 1. 启动Apache服务器 打开终端(terminal),查 ...
- 在centos7云服务器上搭建Apache服务器并访问到你的网站
使用X-shell ssh安全连接到云服务器 https://mail.qq.com/cgi-bin/mail_spam?action=check_link&url=https://www.n ...
随机推荐
- 测试Flask+PYTHON的WEB框架
参数URL: http://blog.csdn.net/qwiwuqo/article/details/8970621 安装flask之前,你必须要先安装python和easy_install. 安装 ...
- C获取本地时间的localtime函数
最近有朋友问如下问题: #include <stdio.h>#include <stdlib.h>#include <iconv.h>#include <ti ...
- 【宽搜】Vijos P1051 送给圣诞夜的极光
题目链接: https://vijos.org/p/1051 题目大意: 给一张‘-’和‘#’的图,规定曼哈顿距离小于等于2的‘#’属于同一图案,求图案数.[曼哈顿距离:对于A(x1,y1)和B(x2 ...
- [Data Structure] 二叉搜索树(Binary Search Tree) - 笔记
1. 二叉搜索树,可以用作字典,或者优先队列. 2. 根节点 root 是树结构里面唯一一个其父节点为空的节点. 3. 二叉树搜索树的属性: 假设 x 是二叉搜索树的一个节点.如果 y 是 x 左子树 ...
- Promise in AngularJS
What's promise Angular’s event system provides a lot of power to our Angular apps. One of the most p ...
- Linux编程之自定义消息队列
我这里要讲的并不是IPC中的消息队列,我要讲的是在进程内部实现自定义的消息队列,让各个线程的消息来推动整个进程的运动.进程间的消息队列用于进程与进程之间的通信,而我将要实现的进程内的消息队列是用于有序 ...
- ListView列表拖拽排序
ListView列表拖拽排序能够參考Android源代码下的Music播放列表,他是能够拖拽的,源代码在[packages/apps/Music下的TouchInterceptor.java下]. 首 ...
- Android ScrollView
ScrollView 滚动视图 滚动视图用于为其它组件添加滚动条,在默认的情况下,当窗体中内容比较多,而一屏显示不下时,超出的部分不能被用户所看到.因为Android的布局管理器本身没有提供滚动屏幕的 ...
- Android之Notification的多种用法
我们在用手机的时候,如果来了短信,而我们没有点击查看的话,是不是在手机的最上边的状态栏里有一个短信的小图标提示啊?你是不是也想实现这种功能呢?今天的Notification就是解决这个问题的. 我们也 ...
- .Net程序猿玩转Android开发---(3)登陆页面布局
这一节我们来看看登陆页面如何布局.对于刚接触到Android开发的童鞋来说.Android的布局感觉比較棘手.须要结合各种属性进行设置,接下来我们由点入面来 了解安卓中页面如何布局,登陆页面非常eas ...