apache php mysql

1 php部分

//修改PHP的默认时区

php.ini

[Date]
date.timezone = "Asia/Shanghai"

//若php不支持mysql的函数,在确认PHP已配置好环境变量的情况下,先重启一下电脑,再试试。

2 mysql部分

如果用service mysqld start无法启动mysql,试试用/etc/init.d/mysqld start来启动mysql

如果apache已经支持php,但无法连接mysql,执行以下操作

1 yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc

2 /etc/init.d/httpd restart

 

CREATE DATABASE IF NOT EXISTS yourdbname DEFAULT CHARSET utf8 COLLATE utf8_general_ci;

//mysql修改root密码

    UPDATE user SET password=PASSWORD('123456') WHERE user='root';
    FLUSH PRIVILEGES;

//为远程连接赋权限

//grant 权限(select,insert,update,delete) on (数据库).(表) to 用户@'主机' identified by '密码'

  grant all privileges  on *.* to root@'%' identified by "root";

  FLUSH PRIVILEGES;

  GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
  FLUSH   PRIVILEGES;

//创建用户test,只能从本机联入,只能访问book库,密码是abc

  grant select,insert,update,delete on book.* to test@localhost Identified by "abc";

//mysql数据库连接的demo

<?php

    

  $con=mysql_connect("localhost","root","123456");

    

  mysql_select_db("mysql",$con);

    

  $res=mysql_query("select host from user");

    

  while($row=mysql_fetch_array($res)){

    echo $row['host']."<br>";

    

  }

    

  mysql_close($con);



?>

 

 

3

//apache 多站点配置

  修改httpd.conf

    打开LoadModule vhost_alias_module modules/mod_vhost_alias.so

    打开Include conf/extra/httpd-vhosts.conf

    修改Listen 80为Listen 8081 Listen 8082 ...

    修改DocumentRoot "你想指定的本地目录"

    修改<Directory "你想指定的本地目录">

  修改extra\httpd-vhosts.conf 添加如下的段

    <VirtualHost *:8081>
        DocumentRoot "C:/www/blog"
        ServerName localhost
    </VirtualHost>

//apache配置以支持yii路径路由

    打开LoadModule rewrite_module modules/mod_rewrite.so

//apache加入对PHP的支持

    修改httpd.conf,加入以下代码

   PHPIniDir "C:\Program Files\PHP\"
 LoadModule php5_module "C:\Program Files\PHP\php5apache2_2.dll"

 

你可能感兴趣的:(apache)