iMac搭建网络服务器

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u012876214/article/details/85116643

说明:iMac自带PHP和Apache服务器,仅需配置即可。

1.进入/etc/apache2,编辑httpd.conf

  • 启动php环境。将下面这句前的#去掉。
# LoadModule php5_module libexec/apache2/libphp5.so
  • 修改权限。
<Directory />                              <Directory />
    AllowOverrid none        =>                Allow from all
    Require all denied                     </Directory>
</Directory>
  • 修改服务器根目录。
DocumentRoot "xxxxxx"                DocumentRoot "/Users/layne/WebServer"
<Directory "XXXXXX">        =>      <Directory "/Users/layne/WebServer">
    ......       						......
</Directory>					      </Directory>
  • 增加默认文件(index.php)。
<IfModule dir_module>						<IfModule dir_module>
    DirectoryIndex index.html      =>   		DirectoryIndex index.html index.php
</IfModule>								</IfModule>

2.重启Apache

~layne$sudo apachectl restart    //重启
//~ layne$sudo apachectl start   //启动

3.这时只要把你的php文件(如test.php)放到/Users/layne/WebServer目录下,然后在浏览器输入http://localhost/test.php即可访问。

猜你喜欢

转载自blog.csdn.net/u012876214/article/details/85116643
今日推荐