apache+php安装教程
生活随笔
收集整理的這篇文章主要介紹了
apache+php安装教程
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
一.安裝
二. 配置
1.php配置
php.ini-development 文件重命名為 php.ini
指定PHP擴展包的具體目錄,以便調用相應的DLL文件
找到如下部分代碼:
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
; extension_dir = "ext"
修改為
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
extension_dir = "D:/servers/php/ext"
去掉以下配置注釋,支持mysql
找到如下部分代碼:
extension=php_curl.dll
extension=php_gd2.dll
extension=php_mysql.dll
extension=php_pdo_mysql.dll
extension=php_pdo_odbc.dll
支持session
session.save_path = "e:/temp"
上傳文件目錄配置
upload_tmp_dir ="e:/temp"
時區配置
date.timezone =Asia/Shanghai
在#LoadModule vhost_alias_module modules/mod_vhost_alias.so下添加以下代碼
代碼:
LoadModule php5_module "e:/servers/php/php5apache2_2.dll"
PHPIniDir "e:/servers/php"
AddType application/x-httpd-php .php .html .htm
web主目錄修改
找到如下部分代碼:
DocumentRoot "D:/servers/Apache2.2/htdocs"
改為
DocumentRoot "D:/servers/phpweb"
找到如下部分代碼: <Directory "D:/servers/Apache2.2/htdocs">
改為
<Directory "D:/phpweb">
找到如下部分代碼:
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
改為
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
重啟apache
三 測試
建立phpweb目錄 D:\servers\phpweb
創建測試文件 index.php
復制代碼 代碼如下:
<?php
phpinfo();
?>
瀏覽:http://localhost
顯示如下信息,說明配置成功:
創建mysql連接測試文件
代碼如下:
<?php
$connect=mysql_connect("10.71.196.147","user","");
if(!$connect) echo "Mysql Connect Error!";
else echo "mysql 連接成功";
mysql_close();
?>
瀏覽:http://localhost/mysqltest.php 測試mysql連接
1 apache
比較簡單,一路next完成.
瀏覽器驗證,出現一下頁面,成功
2 php安裝
下載zip包,直接解壓到一個目錄,目錄重命名為php
mysql安裝教程:
http://blog.csdn.net/long2010yu2010/article/details/7913375二. 配置
1.php配置
php.ini-development 文件重命名為 php.ini
指定PHP擴展包的具體目錄,以便調用相應的DLL文件
找到如下部分代碼:
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
; extension_dir = "ext"
修改為
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
extension_dir = "D:/servers/php/ext"
去掉以下配置注釋,支持mysql
找到如下部分代碼:
extension=php_curl.dll
extension=php_gd2.dll
extension=php_mysql.dll
extension=php_pdo_mysql.dll
extension=php_pdo_odbc.dll
支持session
session.save_path = "e:/temp"
上傳文件目錄配置
upload_tmp_dir ="e:/temp"
時區配置
date.timezone =Asia/Shanghai
配置說明教程:http://www.cnblogs.com/tigertall/archive/2010/01/28/1658869.html
在#LoadModule vhost_alias_module modules/mod_vhost_alias.so下添加以下代碼
代碼:
LoadModule php5_module "e:/servers/php/php5apache2_2.dll"
PHPIniDir "e:/servers/php"
AddType application/x-httpd-php .php .html .htm
web主目錄修改
找到如下部分代碼:
DocumentRoot "D:/servers/Apache2.2/htdocs"
改為
DocumentRoot "D:/servers/phpweb"
找到如下部分代碼: <Directory "D:/servers/Apache2.2/htdocs">
改為
<Directory "D:/phpweb">
找到如下部分代碼:
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
改為
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
重啟apache
三 測試
建立phpweb目錄 D:\servers\phpweb
創建測試文件 index.php
復制代碼 代碼如下:
<?php
phpinfo();
?>
瀏覽:http://localhost
顯示如下信息,說明配置成功:
創建mysql連接測試文件
代碼如下:
<?php
$connect=mysql_connect("10.71.196.147","user","");
if(!$connect) echo "Mysql Connect Error!";
else echo "mysql 連接成功";
mysql_close();
?>
瀏覽:http://localhost/mysqltest.php 測試mysql連接
總結
以上是生活随笔為你收集整理的apache+php安装教程的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Reptile:requests + B
- 下一篇: 区块链对未来金融的重要影响