Ubuntu下安裝PHP

來源:互聯網
上載者:User
Ubuntu下安裝PHP

安裝apache2:sudo apt-get install apache2。查看是否成功:http://localhost/
安裝PHP5:sudo apt-get install php5
sudo apt-get install libapache2-mod-php5(根據俺的實際測試,這一步似乎不用做了,在上一步已經安裝好了,不過還是建議你copy/paste一下這條命令)
sudo /etc/init.d/apache2 restart 測試PHP5是否安裝成功
sudo gedit /var/www/testphp.php
在裡面寫入,然後在Firefox中開啟: http://localhost/testphp.php

安裝mysql:sudo apt-get install mysql-server

MySql初始只允許本機(127.0.0.1)串連,如果想多台機子使用或者向Internet開放的話,編輯/etc/mysql/my.cnf
sudo gedit /etc/mysql/my.cnf
找到bind-address = 127.0.0.1,用#注釋掉,象這樣:#bind-address = 127.0.0.1

MySql預設沒有設定root密碼,原生root使用者也沒有密碼,有風險是吧,這樣
mysqladmin -u root password your-new-password
mysqladmin -h root@local-machine-name -u root -p password your-new-password(這裡我怎麼也串連不上mysql伺服器,最後在mysql-admin裡面改的)
sudo /etc/init.d/mysql restart

安裝MYSQL Administrator:sudo apt-get install mysql-admin

安裝MYSQL for Apache HTTP Server
sudo apt-get install libapache2-mod-auth-mysql
sudo apt-get install php5-mysql

(sudo apt-get install phpmyadmin)

要讓PHP與MySql一起工作,編輯
sudo gedit /etc/php5/apache2/php.ini
取消對;extension=mysql.so的注釋,象這樣
…
extension=mysql.so
…

儲存檔案,然後
sudo /etc/init.d/apache2 restart

測試:
http://localhost/phpmyadmin

  • 聯繫我們

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