PHP移動互連網開發(1)??環境搭建及配置

來源:互聯網
上載者:User
一、PHP5.4環境搭配基本流程

Apache:Web服務提供者。官網:www.apache.org

PHP: 官網:www.php.net

Mysql: 官網:www.mysql.com

二、軟體下載

Apache下載地址:http://download.csdn.net/detail/lxq_xsyu/7057423

PHP下載地址:http://download.csdn.net/detail/lxq_xsyu/7057401

Mysql下載地址:http://download.csdn.net/detail/lxq_xsyu/6468461

三、環境搭建

(1)Apache安裝

安裝成功

(2)解壓PHP5.4

(3)配置Apache的httpd.conf檔案

Apache安裝目錄

  1. ServerRoot "D:/Apache Software Foundation"

監聽連接埠

  1. #Listen 12.34.56.78:80

  1. Listen 80

載入PHP組件

  1. LoadModule php5_module "D:/php54/php5apache2_2.dll"

伺服器名稱

  1. #ServerName www.meritit.com:80

檔案根目錄

  1. DocumentRoot "D:/Apache Software Foundation/htdocs"

許可權檔案夾


索引(預設訪問首頁)

  1. DirectoryIndex index.html

錯誤記錄檔

  1. ErrorLog "logs/error.log"


訪問日誌

  1. CustomLog "logs/access.log" common


配置解析php

  1. AddType application/x-compress .Z
  2. AddType application/x-gzip .gz .tgz
  3. AddType application/x-httpd-php .php


錯誤類型

  1. #ErrorDocument 500 "The server made a boo boo."
  2. #ErrorDocument 404 /missing.html
  3. #ErrorDocument 404 "/cgi-bin/missing_handler.pl"
  4. #ErrorDocument 402 http://www.meritit.com/subscription_


四、測試是否搭建成功

建立a.php

  1. phpinfo();
  2. ?>


可以看到找不到php的設定檔,我們在apache設定檔中指定一下php的設定檔目錄

  1. PHPIniDir "D:/php54"



五、配置多網站訪問

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

去掉上面注釋(開啟虛擬機器主機設定檔)

在httpd-vhosts.conf中配置了兩個網站如下

  1. DocumentRoot "D:/Apache Software Foundation/a_com"
  2. ServerName 127.0.0.2
  3. ServerAlias www.dummy-host.meritit.com
  4. ErrorLog "logs/dummy-host.meritit.com-error.log"
  5. CustomLog "logs/dummy-host.meritit.com-access.log" common
  6. DocumentRoot "D:/Apache Software Foundation/b_com"
  7. ServerName 127.0.0.3
  8. ErrorLog "logs/dummy-host2.meritit.com-error.log"
  9. CustomLog "logs/dummy-host2.meritit.com-access.log" common


注意:一旦配置了虛擬機器主機,前面配置的DocumentRoot就無效了。

D:\Apache Software Foundation\a_com\a.php

  1. echo "aaaaaa";
  2. ?>

D:\Apache Software Foundation\b_com\b.php

  1. echo "bbbbbb";
  2. ?>

注意:要修改許可權檔案夾目錄

訪問結果:
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.