MAC OSX10.9.2上搭建Apache,php,osx10.9.2apache
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 "<span>/Users/shelley/Sites</span>"> 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/<br />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

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

DVWA
Damn Vulnerable Web App (DVWA) 是一個PHP/MySQL的Web應用程序,非常容易受到攻擊。它的主要目標是成為安全專業人員在合法環境中測試自己的技能和工具的輔助工具,幫助Web開發人員更好地理解保護網路應用程式的過程,並幫助教師/學生在課堂環境中教授/學習Web應用程式安全性。 DVWA的目標是透過簡單直接的介面練習一些最常見的Web漏洞,難度各不相同。請注意,該軟體中

MantisBT
Mantis是一個易於部署的基於Web的缺陷追蹤工具,用於幫助產品缺陷追蹤。它需要PHP、MySQL和一個Web伺服器。請查看我們的演示和託管服務。

SublimeText3漢化版
中文版,非常好用

SecLists
SecLists是最終安全測試人員的伙伴。它是一個包含各種類型清單的集合,這些清單在安全評估過程中經常使用,而且都在一個地方。 SecLists透過方便地提供安全測試人員可能需要的所有列表,幫助提高安全測試的效率和生產力。清單類型包括使用者名稱、密碼、URL、模糊測試有效載荷、敏感資料模式、Web shell等等。測試人員只需將此儲存庫拉到新的測試機上,他就可以存取所需的每種類型的清單。

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)