以php5.4,apache2.4,mysql5.7为例
一,apache的配置:
1,找到配置文件apache目录下conf->httpd文件。
2,配置文件
根目录配置:
Define SRVROOT "D:/x64"
ServerRoot "${SRVROOT}"
或者ServerRoot "文件目录“
端口配置:
Listen 80
加载PHP文件配置:
#LoadModule xml2enc_module modules/mod_xml2enc.so
后面一行加上LoadModule php5_module "c:/www/php54/php5apache2_2.dll(文件目录下的php5apache2_2(2_4).dll路径)"
运行文件存放目录:
DocumentRoot "文件目录"
*权限目录:
<Directory "文件目录">此处的文件目录大于等于文件存放目录。
入口文件设置:
<IfModule dir_module>
DirectoryIndex index.html index.htm index.php
</IfModule>
PHP解释配置:
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz后面一行加上 AddType application/x-httpd-php .php来解析php文件
指定PHP配置文件:
PHPIniDir "php配置文件目录" 例如D:/php54/php.ini就是 PHPIniDir "D:/php54"
介绍:
错误日志:ErrorLog "logs/error.log"
访问日志: CustomLog "logs/access.log" common
错误提示区:
#ErrorDocument 500 "The server made a boo boo."
#ErrorDocument 404 /missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://www.example.com/subscription_info.html
3,虚拟主机多站点配置
首先,conf->httpd文件中加载:
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
然后,在conf/extra/httpd-vhosts.conf文件中:
# Add any other Virtual Hosts below
#<VirtualHost *:80>
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot "${SRVROOT}/docs/dummy-host.example.com"
# ServerName dummy-host.example.com
# ServerAlias www.dummy-host.example.com
# ErrorLog "logs/dummy-host.example.com-error.log"
# CustomLog "logs/dummy-host.example.com-access.log" common
#</VirtualHost>
#<VirtualHost *:80>
# ServerAdmin webmaster@dummy-host2.example.com
# DocumentRoot "${SRVROOT}/docs/dummy-host2.example.com"
# ServerName dummy-host2.example.com
# ErrorLog "logs/dummy-host2.example.com-error.log"
# CustomLog "logs/dummy-host2.example.com-access.log" common
#</VirtualHost> 此处为添加站点处
将其改为
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "你的文件地址"
ServerName 域名你的(127.0.0.2)
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
二,数据库配置:
1,配置文件复制更名为my.ini
打开my.ini并配置
[mysql]
default-character-set=utf8
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
basedir = D:/mysql-5.7.11-winx64
datadir = D:/mysql-5.7.11-winx64/Data
port = 3306
character_set_server=utf8
# server_id = .....
2,配置环境变量:
” 我的电脑“ 右击 “属性”->高级->环境变量->系统变量->Path 编辑(在path最后以;隔开加入你的路径D:\mysql-5.7.11-winx64)确定即可
3,以管理员身份运行cmd(C:/windows/system32/cmd.exe右击管理员运行)依次键入
cd D:
cd D:\mysql-5.7.11-winx64\bin
mysqld --initialize-insecure
mysqld -install
4,启动服务器 net start mysql
5,进入数据库 mysql -uroot -p(两次回车)
6设置密码set password for root @localhost=password("your password');
三,PHP配置
php.ini文件中去掉extension=php_mysql.dll前面的“;”即可