Debian 6下手動(dòng)安裝LAMP環(huán)境(通用版)

開始之前,更新一下系統(tǒng) apt-get update apt-get upgrade –show-upgraded

目錄 1.安裝/配置Apache 2.安裝/配置MySQL 3.安裝/配置PHP

一、安裝/配置Apache

1.安裝Apache apt-get install apache2

2.確保開啟偽靜態(tài)功能 a2enmod rewrite

3.設(shè)置虛擬主機(jī)

推薦如下方式

在目錄/etc/apache2/sites-available/下創(chuàng)建形如example.com的文件(按照綁定域名的數(shù)量可創(chuàng)建多個(gè)文件),內(nèi)容如下(請參照修改)

<VirtualHost *:80> ???? ServerAdmin webmaster@example.com ???? ServerName example.com ???? ServerAlias www.example.com ???? DocumentRoot /srv/www/example.com/public_html/ ???? ErrorLog /srv/www/example.com/logs/error.log ???? CustomLog /srv/www/example.com/logs/access.log combined </VirtualHost>

根據(jù)上面的配置,你的網(wǎng)站目錄應(yīng)該都在/srv/www下,ErrorLog和CustomLog并不是必選,但一旦設(shè)定,相關(guān)目錄必須存在(自行創(chuàng)建,命令如下,) mkdir -p /srv/www/example.com/public_html mkdir /srv/www/example.com/logs

設(shè)定生效 a2ensite example.com

4.重啟Apache /etc/init.d/apache2 reload

如需停用該網(wǎng)站,可使用如下命令 a2dissite example.com

注意:啟用/停用網(wǎng)站,都需要重啟Apache(命令如上面所示)

二、安裝/配置MySQL

1.安裝MySQL apt-get install mysql-server

安裝過程會(huì)提示設(shè)定密碼,相關(guān)設(shè)置存儲(chǔ)于/etc/mysql/my.cnf

2.安全設(shè)置 mysql_secure_installation

3.MySQL常用命令

登錄 mysql -u root -p

創(chuàng)建數(shù)據(jù)庫example,并授權(quán)給用戶newuser(用戶密碼newpassword) create database example; grant all on example.* to ‘newuser’ identified by ‘newpassword’;

退出MySQL quit

三、安裝/配置PHP

1.安裝PHP apt-get install php5 php-pear php5-suhosin

PHP配置文件位于/etc/php5/apache2/php.ini

2.修改PHP配置/etc/php5/apache2/php.ini max_execution_time = 30 memory_limit = 64M error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR display_errors = Off log_errors = On error_log = /var/log/php.log register_globals = Off

3.安裝PHP對(duì)MySQL的支持 apt-get install php5-mysql

4.最后,重啟Apache /etc/init.d/apache2 restart

贊(0)
版權(quán)聲明:本文采用知識(shí)共享 署名4.0國際許可協(xié)議 [BY-NC-SA] 進(jìn)行授權(quán), 轉(zhuǎn)載請注明出處。
文章名稱:《Debian 6下手動(dòng)安裝LAMP環(huán)境(通用版)》
文章鏈接:http://www.lrracing.com/395.html
【聲明】:國外主機(jī)測評(píng)僅分享信息,不參與任何交易,也非中介,所有內(nèi)容僅代表個(gè)人觀點(diǎn),均不作直接、間接、法定、約定的保證,讀者購買風(fēng)險(xiǎn)自擔(dān)。一旦您訪問國外主機(jī)測評(píng),即表示您已經(jīng)知曉并接受了此聲明通告。
【關(guān)于安全】:任何 IDC商家都有倒閉和跑路的可能,備份永遠(yuǎn)是最佳選擇,服務(wù)器也是機(jī)器,不勤備份是對(duì)自己極不負(fù)責(zé)的表現(xiàn),請保持良好的備份習(xí)慣。