windows+apache+php+mysql快速搭建服务器环境

来源:互联网 发布:vscode php注释插件 编辑:程序博客网 时间:2024/04/30 08:49

windows+apache+php+mysql快速搭建服务器环境

  
软件下载地址:
http://windows.php.net/
http://php.net/     linux和windows版本下载地址
http://apache.org/
http://mysql.com/

注意:路径要注意更改到安装的相应位置,所创建的文件夹最好不要有空格

配置Apache服务器
     
                 --编辑httpd.conf

DocumentRoot "C:/Apache/htdocs"
修改为:
#DocumentRoot "C:/Apache2.2/htdocs"
DocumentRoot "D:/www"

Directory "C:/Apache2.2/htdocs"
修改为:Directory "D:/www"

DirectoryIndex index.html
修改为:DirectoryIndex index.html index.htm index.php default.htmldefault.htm default.php

    OptionsFollowSymLinks
    AllowOverride All     //开启.htaccess
    Order allow,deny
    Allow from all

AllowOverride All

#LoadModule rewrite_module modules/mod_rewrite.so
修改为:
LoadModule rewrite_module modules/mod_rewrite.so  //开启.htaccess

# Virtual hosts   //开启vhost插件
#Include conf/extra/httpd-vhosts.conf
修改为:
# Virtual hosts
Include conf/extra/httpd-vhosts.conf


(下面代码复制到httpd.conf文件的末尾)

ScriptAlias /php/ "C:/WP/PHP/"
AddTypeapplication/x-httpd-php .php
AddType application/x-httpd-php.html
AddType application/x-httpd-php.txt   (指PHP可以执行的类型)
Action application/x-httpd-php "C:/WP/PHP/php-cgi.exe"

LoadFile C:\WP\PHP\php5ts.dll
LoadFile C:\WP\PHP\libmysql.dll

LoadModule php5_module "C:/WP/PHP/php5apache2_2.dll"






配置httpd-vhosts.conf
          
                   //添加多个域名方法

NameVirtualHost 223.4.94.66:80

  ServerAdmin xiuyajfc@yeah.net
  ServerName www.xiuyajfc.com
  DocumentRoot "D:/xiuya"
  ErrorLog "logs/xiuya_err.log"
  CustomLog "logs/xiuya_access.log" common

  ServerAdmin xiuyajfc@yeah.net
  ServerName showmee.xiuyajfc.com
  DocumentRoot "D:/showmee"
  ErrorLog "logs/showmee_err.log"
  CustomLog "logs/showmee_access.log" common 






配置PHP

       --编辑php.ini(将php.ini-dist复制到apache文件夹中并改后缀)
        --在PHP目录下创建zend、tmp、uploadstmp目录

extension_dir="./"
修改为:extension_dir="C:\WP\PHP\ext\"

doc_root=
修改为:doc_root="D:\www"

;session.save_path="/tmp"
修改为:session.save_path="C:/WP/PHP/tmp"  在C:/PHP下创建tmp文件夹

display_errors=Off
修改为:display_errors=On

;date.timezone=
修改为:date.timezone=PRC

;upload_tmp_dir =
修改为:
upload_tmp_dir = "C:/WP/PHP/tmp"


            //设置数据库

mysql.default_host=localhost

mysql.default_port=3306

mysql.default_user=root

mysql.default_password=password

;extension=php_mysql.dll   //开启扩展
修改为:extension=php_mysql.dll

所有  ;extension=   都修改为:extension=

在命令提示符输入:mysql -hlocalhost -uroot -p


把PHP目录下的全部 .dll 文件复制到C:\WP\Apache\bin目录中
把PHP安装目录中的全部 .dll 文件复制到windows系统的system32文件夹中
我的电脑属性--高级系统设置--高级--环境变量--系统变量{在变量:path,值:(加上)C:\WP\PHP\ext}







配置Zend

           (将下面这段复制到php.ini文件末尾)

[Zend]
zend_optimizer.optimizerimization_level=1023
zend_optimizer.optimizer encoder_loader=0
zend_extension_manageroptimizer_ts="C:\WP\PHP\Zend\lib\Optimizer-3.3.0"
zend_extension_ts="C:\WP\PHP\Zend\lib\ZendExtensionManager.dll"







配置MySQL

            --编辑my.ini
datadir="C:/WP/MySQL/data/"   //数据库存放位置







配置phpmyadmin

命名小写文件夹名为:phpmyadmin 放到D:/PHPSite文件夹里
在D:\PHPSite\phpmyadmin\libraries下找到config.default.php文件

$cfg['PmaAbsoluteUri'] = 'http://localhost/phpmyadmin/';

$cfg['Servers'][$i]['host'] = 'localhost';

$cfg['Servers'][$i]['auth_type'] = 'cookie';

$cfg['Servers'][$i]['user'] = 'root';

$cfg['Servers'][$i]['password'] = 'mysql的密码';

$cfg['DefaultLang'] = 'zh';

$cfg['DefaultCharset'] = 'gb2312';

$cfg['FilterLanguages'] = 'gb2312';

$cfg['PmaNoRelation_DisableWarning'] = true;

$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
   //'phpmyadmin'-seescripts/create_tables.sql

$cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark';
   //'pma_bookmark'

$cfg['Servers'][$i]['relation'] = 'pma_relation';
   //'pma_relation'

$cfg['Servers'][$i]['table_info'] = 'pma_table_info';
   //'pma_table_info'

$cfg['Servers'][$i]['table_coords'] ='pma_table_coords';
   //'pma_table_coords'

$cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages';
    //'pma_pdf_pages'

$cfg['Servers'][$i]['column_info'] = 'pma_column_info';
   //'pma_column_info'

$cfg['Servers'][$i]['history'] = 'pma_history';
    //'pma_history'

$cfg['Servers'][$i]['designer_coords'] ='pma_designer_coords';
   //'pma_designer_coords'

$cfg['Servers'][$i]['tracking'] = 'pma_tracking';
   //'pma_tracking'

$cfg['Servers'][$i]['userconfig'] = 'pma_userconfig';
    //'pma_userconfig'

$cfg['Servers'][$i]['auth_swekey_config'] ='/etc/swekey-pma.conf';
    //设置密钥,如果没有为空

$cfg['blowfish_secret'] ='123456';(还有在phpmyadmin根文件夹里的config.sample.inc.php文件夹 18行$cfg['blowfish_secret'] = '123456';)

最后登陆http://localhost/phpmyadmin 
-----导入-浏览(D:\www\phpmyadmin\scripts\create_tables.sql
0 0
原创粉丝点击