发布于 2015-11-09 14:46:38 | 298 次阅读 | 评论: 0 | 来源: PHPERZ

这里有新鲜出炉的PHP教程,程序狗速度看过来!

PHP开源脚本语言

PHP(外文名: Hypertext Preprocessor,中文名:“超文本预处理器”)是一种通用开源脚本语言。语法吸收了C语言、Java和Perl的特点,入门门槛较低,易于学习,使用广泛,主要适用于Web开发领域。PHP的文件后缀名为php。


/private/etc/apache2/httpd.conf

一、启动Apache

sudo apachectl start

sudo apachectl -v   可以查看到Apache的版本信息

此时在浏览器中输入http://localhost,会出现It works!的页面

sudo apachectl restart 重启Apache

二、运行PHP

1、找到Apache的配置文件,在目录/etc/apache2/下,打开Finder,选择"前往"-"前往文件夹",输入"/etc/apache2/",找到其中的"httpd.conf"文件,选择用文稿打开进行编辑,点按Command+F,搜索#LoadModule php5_module libexec/apache2/libphp5.so,如图

把蓝色那一行的#号去掉,然后保存,如果出现文本锁定,无法解锁的情况,解决办法有两种

a)选中该文件,右击后选择"显示简介",点击右下角的小锁的图标,输入电脑密码解锁,然后选择左边的+号键,选择自己当前电脑登陆的用户,将权限设置为读与写,如果还是不行,将其上一级文件夹权限同样再修改一次。

b)将该文件复制到桌面,进行修改,修改后再复制到原来的文件夹替换之前的文件即可。

2、重启Apache,在终端输入  sudo apachectl restart

3、在终端输入  sudo cp /Library/WebServer/Documents/index.html.en /Library/WebServer/Documents/info.php

即在Apache的根目录下复制index.html.en文件并重命名为info.php。

4、打开info.php,在It works后面加上<?php phpinfo(); ?>,然后再次重启Apache,在浏览器中输入http://localhost/info.php,会出现一个显示php信息的页面,如图所示。

Mac下配置Apache时遇到的Forbidden


You don't have permission to access /HelloMac.htm on this server.

OS X升级到Yosemite之后,自带的Apache也从2.2升级到了2.4,访问权限的配置上有所不同。

以配置alise别名目录为例,把/Users/redraiment/workspace/映射到http://localhost/workspace/,在2.2版本中配置信息如下:

<IfModule alias_module>
    Alias /workspace "/Users/redraiment/workspace/"
    <Directory "/Users/redraiment/workspace/">
        AllowOverride All
        Options Indexes MultiViews FollowSymLinks ExecCGI
        Order allow,deny
        Allow from all
        DirectoryIndex index.html index.php
    </Directory>
</IfModule>

升级到2.4版本之后:Order allow,denyAllow from all要改成Require all granted如下所示:

<IfModule alias_module>
    Alias /workspace "/Users/redraiment/workspace/"
    <Directory "/Users/redraiment/workspace/">
        AllowOverride All
        Options Indexes MultiViews FollowSymLinks ExecCGI
        Require all granted
        DirectoryIndex index.html index.php
    </Directory>
</IfModule>

 



最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务