debian7.8安裝LAMP+Redis

一、安裝apache2+mysql5.5+php5

sudo apt-get install mysql-server-5.5
sudo apt-get install apache2
sudo apt-get install php5 php5-mysql
sudo apt-get install libapache2-mod-php5

vi /var/www/index.htmlphp

<!DOCTYPE html>
<html>
<body>

<?php
echo "My first PHP script!";
?>  

</body>
</html>

瀏覽器打開 http://localhost/index.php 看到內容:My first PHP script!,說明apahe2和php已安裝成功。html

測試php腳本中是否能鏈接mysqlmysql

shen@debian:/var/www/shm_fast$ cat connect-mysql.php 
<?php
$servername = "localhost";
$username = "root";
$password = "123456";

// 建立鏈接
$conn = mysqli_connect($servername, $username, $password);

// 檢測鏈接
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}
echo "Connected successfully";
?>
shen@debian:/var/www/shm_fast$ php -f connect-mysql.php 
Connected successfully

瀏覽器中輸入: http://localhost/shm_fast/connect-mysql.php
看到網頁輸出: Connected successfully 表示mysql安裝正確。web

二、安裝mysql管理工具phpmyadmin, mysql-workbench

sudo apt-get install phpmyadmin

安裝中選擇apache2做爲web server。redis

在Debain桌面,打開菜單: 應用程序 > 編程 > phpMyAdmin, 或者瀏覽器中輸入http://localhost/phpmyadmin/
能打開phpmyadmin登陸頁面,以root賬號登陸,若是成功說明phpmyadmin已安裝成功。sql

輸入圖片說明

輸入圖片說明

phpMyAdmin版本信息: 3.4.11.1deb2+deb7u1apache

apt-get install mysql-workbench

安裝完成後,在Debain桌面,打開菜單: 應用程序 > 編程 > MySQL Workbench, 便可打開桌面應用MySQL Workbench編程

輸入圖片說明

安裝後的版本號是5.2.40數組

三、安裝redis-server

sudo apt-get install redis-server

版本2.4.14瀏覽器

shen@debian:~$ redis-server --version
Redis server version 2.4.14 (00000000:0)
shen@debian:~$ sudo /etc/init.d/redis-server status
redis-server is running

安裝PHP包管理器——pear

sudo apt-get install php-pear
sudo apt-get install php5-dev

打開網站 http://pecl.php.net/ 搜索 redis,進入 http://pecl.php.net/package/redis

sudo pear install http://pecl.php.net/get/redis-2.2.7.tgz
...
Build process completed successfully
Installing '/usr/lib/php5/20100525/redis.so'
install ok: channel://pecl.php.net/redis-2.2.7
configuration option "php_ini" is not set to php.ini location
You should add "extension=redis.so" to php.ini
sudo vi /etc/php5/mods-available/redis.ini
shen@debian:~$ cat /etc/php5/mods-available/redis.ini
; configuration for php redis module
; priority=20
extension=redis.so
shen@debian:/etc/php5/conf.d$ sudo ln -snf ../mods-available/redis.ini 20-redis.ini
shen@debian:/etc/php5/conf.d$ ls -l
總用量 0
lrwxrwxrwx 1 root root 25  8月 31 13:36 10-pdo.ini -> ../mods-available/pdo.ini
lrwxrwxrwx 1 root root 24  9月  5 10:02 20-gd.ini -> ../mods-available/gd.ini
lrwxrwxrwx 1 root root 28  9月  5 10:02 20-mcrypt.ini -> ../mods-available/mcrypt.ini
lrwxrwxrwx 1 root root 28  8月 31 13:36 20-mysqli.ini -> ../mods-available/mysqli.ini
lrwxrwxrwx 1 root root 27  8月 31 13:36 20-mysql.ini -> ../mods-available/mysql.ini
lrwxrwxrwx 1 root root 31  8月 31 13:36 20-pdo_mysql.ini -> ../mods-available/pdo_mysql.ini
lrwxrwxrwx 1 root root 27  9月  9 09:41 20-redis.ini -> ../mods-available/redis.ini

重啓apache

shen@debian:~$ sudo /etc/init.d/apache2 restart
[ ok ] Restarting web server: apache2 ... waiting .

四、pear安裝mysql封裝:MDB2

sudo pear install MDB2
sudo pear install MDB2#mysql
sudo pear install PHP_Debug

五、安裝php5-curl

測試curl代碼:

shen@debian:~$ cat curl_version.php 
<?php
// 獲取cURL版本數組
$version = curl_version();

// 在cURL編譯版本中使用位域來檢查某些特性
$bitfields = Array(
            'CURL_VERSION_IPV6', 
            'CURL_VERSION_KERBEROS4', 
            'CURL_VERSION_SSL', 
            'CURL_VERSION_LIBZ'
            );


foreach($bitfields as $feature)
{
    echo $feature . ($version['features'] & constant($feature) ? ' matches' : ' does not match');
    echo PHP_EOL;
}
?>

安裝以前運行錯誤:

shen@debian:~$ php -f curl_version.php 
PHP Fatal error:  Call to undefined function curl_version() in /home/shen/curl_version.php on line 3

安裝並測試:

shen@debian:~$ sudo apt-get install php5-curl
shen@debian:~$ php -f curl_version.php 
CURL_VERSION_IPV6 matches
CURL_VERSION_KERBEROS4 does not match
CURL_VERSION_SSL matches
CURL_VERSION_LIBZ matches
相關文章
相關標籤/搜索