zoukankan      html  css  js  c++  java
  • 为Mac自带的Apache配置PHP和虚拟机

    参考地址:

    http://www.codesec.net/view/244646.html

    apache相关命令:
    启动:sudo apachectl start
    停止:sudo apachectl stop
    重启:sudo apachectl restart
    查看版本号:sudo apachectl -v

    2、添加php模块

    在终端中输入命令:sudo vi /etc/apache2/httpd.conf ,打开httpd.conf

    去掉PHP模块前面的注释 '#',重启apache,php添加成功

    3、配置‘mysites’虚拟机

    1.在终端输入命令:mkdir /Users/你的用户名/Sites ,添加此文件夹做为'mysites'虚拟机的物理存储位置。

    2.打开httpd.conf,去掉" # Include /private/etc/apache2/extra/httpd-vhosts.conf"前面的'#'。 

    3.选择 DocumentRoot "/Library/WebServer/Documents" <Directory "/Library/WebServer/Documents" > ...</Directory> 之间的内容,复制这些内容到它的下方;修改黄色区域修改为 "/Users/你的用户名/Sites",保存退出。

    在终端输入命令:sudo vi /etc/apache2/extra/httpd-vhosts.conf ,打开httpd-vhosts.conf。

    注释两个默认的虚拟机,在每一行前面加'#'

    接下来,添加如下代码,保存退出,重启apache

    # 'localhost'虚拟机
    <VirtualHost *:80>
    DocumentRoot "/Library/WebServer/Documents"
    ServerName localhost
    ErrorLog "/private/var/log/apache2/localhost-error_log"
    CustomLog "/private/var/log/apache2/localhost-access_log" common 
    </VirtualHost>
    # 'mysites'虚拟机
    <VirtualHost *:80>
    DocumentRoot "/Users/你的用户名/Sites"
    ServerName mysites
    ErrorLog "/private/var/log/apache2/mysites-error_log"
    CustomLog "/private/var/log/apache2/mysites-access_log" common 
    </VirtualHost>

    在终端输入命令: sudo vi /etc/hosts ,添加 "127.0.0.1 mysites",保存退出

    在终端输入命令:sudo vi /Users/你的用户名/Sites/info.php ,添加 "<?php echo phpinfo(); ?>" ,保存退出

    在浏览器中输入 http://mysites/info.php

  • 相关阅读:
    mongoDB 索引
    mongoDB _id:ObjectId("xxxx")详解
    mongoDB: cursor not found on server
    mongoDB group命令详解
    Python 中,matplotlib绘图无法显示中文的问题
    python常用
    deepin下安装python的Tkinter库
    wireshark抓包常见提示含义解析
    TimeUnit
    Java回调机制解析
  • 原文地址:https://www.cnblogs.com/mingaixin/p/5225200.html
Copyright © 2011-2022 走看看