ini 配置Apache虚拟主机和PHP使用; http://stackoverflow.com/questions/9110179/adding-virtualhost-fails-access-f

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ini 配置Apache虚拟主机和PHP使用; http://stackoverflow.com/questions/9110179/adding-virtualhost-fails-access-f相关的知识,希望对你有一定的参考价值。

## ==> In C:\WINDOWS\system32\drivers\etc\hosts or /etc/hosts

#127.0.0.1    localhost
#127.0.0.1    cs2

## ==> In httpd.conf or apache2.conf

#Virtual hosts
#Include conf/extra/httpd-vhosts.conf

LoadModule php5_module "c:/Program Files/PHP/php5apache2_4.dll"
AddHandler application/x-httpd-php .php
<IfModule dir_module>
  DirectoryIndex index.php index.html index.htm index.xhtml
</IfModule>

## ==> In httpd-vhosts.conf

NameVirtualHost *:80
# Listen 80 # Apache 2.4 seems not to start when this line is enabled...

<VirtualHost *:80>
  ServerName localhost
  #ServerAlias www.localhost.com
  ServerAdmin mnothro@yahoo.com

  DocumentRoot "C:/Apache24/htdocs"
  <Directory "C:/Apache24/htdocs">
    Options +Indexes +FollowSymLinks -MultiViews
    AllowOverride All

    Require all granted
    # Replaces in 2.4:
    #Order allow,deny
    #Allow from all
  </Directory>

  ErrorLog "logs/localhost-error.log"
  LogLevel warn

  CustomLog "logs/localhost-access.log" combined
</VirtualHost>

<VirtualHost *:80>
  ServerName cs2
  #ServerAlias www.cs2.com
  ServerAdmin mnothro@yahoo.com

  DocumentRoot "D:/Workspace/cadeauxsucres2"
  <Directory "D:/Workspace/cadeauxsucres2">
    Options +Indexes +FollowSymLinks -MultiViews
    AllowOverride All

    Require all granted
    # Replaces in 2.4:
    #Order allow,deny
    #Allow from all
  </Directory>

  ErrorLog "logs/cs2-error.log"
  LogLevel warn

  CustomLog "logs/cs2-access.log" combined
</VirtualHost>

配置php开发环境

安装apache
1 loadModule 加载php的模块
2 addType 告诉apache凡是php结尾的文件都交给php模块执行
3 PHPIniDir 告诉apache php.ini的文件在哪里
4 在php.ini里配置时间 中国时区PRC
5 在apapche配置打开 多站点虚拟机
6 在虚拟机目录配置

nameVirtualHost *:80

<virtualhost *:80>
ServerName localhost
DocumentRoot "c:/wamp/www"
<directory "c:/wamp/www">
options indexes //显示文件列表
Order Deny,Allow
allow from all
DirectoryIndex index.php //默认首页
</directory>
</virtualhost>

7 在window DNS里添加虚拟机的域名

安装mysql

1 在php.ini文件中,设定php模块所在的路径(查找关键字extension_dir)
2 “打开”mysql这个模块就可以了(查找关键字php_mysql.dll)



















以上是关于ini 配置Apache虚拟主机和PHP使用; http://stackoverflow.com/questions/9110179/adding-virtualhost-fails-access-f的主要内容,如果未能解决你的问题,请参考以下文章

配置php开发环境

如何将 PHP 应用程序限制在它们自己的目录和它们自己的 php.ini 中?

Apache 2.2 phpinfo() 配置文件 (php.ini) 路径与 httpd.conf 不匹配

Linux+Apache+PHP+MySQL服务器环境配置(CentOS篇)

ini Apache的主机配置

Windows下的php.ini 无效使用