apache和php、mysql的整合

來源:互聯網
上載者:User

標籤:php、mysql和apache的整合

1、編輯apache的主設定檔httpd.conf 調整 ServerName 127.0.0.1:80  (注意備份) 

    vi /application/apache/conf/httpd.conf +98

    98     ServerName 127.0.0.1:80

    在311行下增加兩行:

    AddType application/x-httpd-php .php .phtml

    AddType application/x-httpd-php.source .phps

    #把以php結尾都檔案交給php解析處理,如果這裡出錯,網站開啟就開始下載;

    67 User www

    68 Group www

    #一般不使用系統的deamon預設使用者,這裡稍後可以自行建立,這是安全起見。

    

    167 <IfModule dir_module>

    168     DirectoryIndex index.html

    169 </IfModule>

    #修改首頁檔案 為168  DirectoryIndex  index.php index.html

2、建立使用者 useradd -M -s /sbin/nologin  www

3、 檢查apache 的文法,然後重啟。

4、建立虛擬機器主機。

5、建立一個php程式(位置根據虛擬機器主機的設定檔做定論,這裡是為了測試,一般測試後要刪除,很不安全)。

    vi index.php

    <?php

    phpinfo ();

    ?>

6、配置windows下的host檔案。

7、在瀏覽器路輸入欄位名看到php介面就大功告成。

8、在網站目錄下建立index.php

    

    <?php

            //$link_id=mysql_connect(‘主機名稱‘,‘使用者‘,‘密碼‘);

            $link_id=mysql_connect(‘localhost‘,‘root‘,‘123456‘) or mysql_error();

            if($link_id){

            echo "mysql successful by oldboy!";

            }

            else {

            echo mysql_error();

            }

    ?>

9、瀏覽器輸入欄位名

    顯示mysql successful by oldboy!

10、就成功了。

           


本文出自 “一個檔案一個命令” 部落格,謝絕轉載!

apache和php、mysql的整合

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.