zoukankan      html  css  js  c++  java
  • [www.infoshare.cc]mac 10.10.5下配置apache

    来源:http://www.infoshare.cc/

    1、配置/etc/apache2/httpd.conf,打开httpd.conf,找到下面3行,将其前面注释#去除

    LoadModule php5_module libexec/apache2/libphp5.so

    Include /private/etc/apache2/other/*.conf

    Include /private/etc/apache2/extra/httpd-vhosts.conf

     

    2、创建个人站点

    • 创建目录:/Users/macbook/Sites         (macbook为你自己的用户名)
    • 打开/etc/apache2/users/macbook.conf(如果没有自行创建),输入配置:

    <Directory "/Users/macbook/Sites/">

        Options Indexes MultiViews

        AllowOverride None

        Order allow,deny

        Allow from all

    </Directory>

     

    3、创建虚拟主机

    打开 /etc/apache2/extra/httpd-vhosts.conf

    输入

    <VirtualHost *:80>

         DocumentRoot "/Users/macbook/Sites/"

         ServerName www.macbook.com

         <Directory />

                     Options Indexes FollowSymLinks MultiViews

                     AllowOverride None

                     Order deny,allow

                     Allow from all

           </Directory>

    </VirtualHost>

     

    4、修改host

    打开/etc/hosts

    输入

    127.0.0.1       www.macbook.com

     

    5、重启服务

     

    apachectl restart

     

    6、浏览器访问(XX为/Users/macbook/Sites目录下面次级目录,也可以将index.php目录放在Sites下面,直接访问http://www.macbook.com/index.php)

    http://www.macbook.com/XX/index.php

     

     

    备注:PHP连接数据库失败问题

    首先进入数据库,获取UNIX socket: 对应的至

    mysql> status
    --------------
    mysql  Ver 14.14 Distrib 5.7.14, for osx10.11 (x86_64) using  EditLine wrapper
    
    Connection id:		2563
    Current database:	
    Current user:		root@localhost
    SSL:			Not in use
    Current pager:		stdout
    Using outfile:		''
    Using delimiter:	;
    Server version:		5.7.14 MySQL Community Server (GPL)
    Protocol version:	10
    Connection:		Localhost via UNIX socket
    Server characterset:	latin1
    Db     characterset:	latin1
    Client characterset:	utf8
    Conn.  characterset:	utf8
    UNIX socket:		/tmp/mysql.sock
    Uptime:			2 days 23 hours 3 min 29 sec
    
    Threads: 3  Questions: 225  Slow queries: 0  Opens: 189  Flush tables: 1  Open tables: 182  Queries per second avg: 0.000
    

    接下来退出数据库模式,命令行输入:  

    # cp php.ini.default php.ini

    // 进入php.ini

    # vim php.ini 

    // 找到下面这几行

    extension=php_mysql.dll  

    extension=php_mysqli.dll 前面的;去掉 

    //以下两项后面加上 /tmp/mysql.sock(从以上UNIX socket: /tmp/mysql.sock 获取)

    mysql.default_socket=/tmp/mysql.sock

    mysqli.default_socket=/tmp/mysql.sock

    //设置safe_mode从on修改为off

    sql.safe_mode=off

     

    最后重启服务即可

    apachectl restart

     

  • 相关阅读:
    springboot访问redis序列化问题
    观察者模式在源码中的使用
    抽象工厂模式在源码中的使用
    工厂方法模式在源码中的应用
    策略模式的应用
    springcloud实现限流
    Elasticsearch
    java8新特性(二)StreamApi
    thinkpaidE450 win10 进入bios
    restframe_work2
  • 原文地址:https://www.cnblogs.com/wonderful0714/p/5790827.html
Copyright © 2011-2022 走看看