失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > MAC OSX10.9.2上搭建Apache php osx10.9.2apache

MAC OSX10.9.2上搭建Apache php osx10.9.2apache

时间:2021-05-17 08:31:42

相关推荐

MAC OSX10.9.2上搭建Apache php osx10.9.2apache

php教程|php手册

MAC,OSX10.9.2,上,搭建,Apache,php,osx10.9.2apache,MAC,OSX10.9.2,

php教程-php手册

MAC OSX10.9.2上搭建Apache,php,osx10.9.2apache

极光闪购v8源码,ubuntu微信wine,tomcat写日志写得慢,爬虫思路图,php设计教程外包,seo哪里好找行者SEOlzw

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

订单系统源码,清除vscode,ubuntu 分区软件,jaas tomcat,qt sqlite 开源,免备案国内服务器,时间日期格式插件,前端流行框架,nutch 爬虫教程,php手机端,洛阳网站seo优化,微网站开源系统,网页挂q,个人主页模板网站,php登陆页面模板,php财务管理系统源码,淘客程序是什么lzw

Apache配置

什么是网站源码和模板,ubuntu安装磁盘检查,爬虫被网站识别,php链接json,seo排名厂家lzw

1- 启动

sudo apachectl start

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

vi /etc/apache2/httpd.conf

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

# # 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 give it to you. # # The Options directive is both complicated and important. Please see # /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

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

Options Indexes MultiViews AllowOverride None Order allow,deny Allow from all

为何一定是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 users 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 RegisterUserSite customized-users

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 DocumentRoot "/Users/shelley/Sites" ServerNameErrorLog "/Users/shelley/Sites/log/error.log" CustomLog "/Users/shelley/Sites/log/access.log" common Options Indexes FollowSymLinks MultiViewsAllowOverride NoneOrder deny,allowAllow from all

5- URL转发

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

LoadModule proxy_module libexec/apache2/mod_proxy.soLoadModule 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、/HellpWorldApp 都相当于访问 http://localhost:8080/HelloWorldApp

6- 端口转发

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

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

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

然后修改

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

NameVirtualHost *:80 ProxyPreserveHost On ServerName ProxyPass / :8000/ ProxyPassReverse / :8000/ServerAdmin webmaster@localhost

这样就相当于把 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:

/yjmyzz/p/3920361.html

如果觉得《MAC OSX10.9.2上搭建Apache php osx10.9.2apache》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。