目前世界最流行的企業建站方式是LAMP(Linux+Apache+MySQL+PHP),即使用Linux作爲操作系統,Apache作爲Web服務器,MySQL作爲數據庫,PHP作爲服務器端腳本解釋器。這四個軟件都是遵循GPL的開放源碼軟件,它們安全、穩定、快速、功能強大,使用它們可以建立一個快速、穩定、免費的網站系統。
1.APACHE的簡介
Apache是世界使用排名第一的Web服務器,市場佔有率達60%左右。
它的特點是簡單、速度快、性能穩定。
它的成功之處主要在於它的源代碼開放、有一支開放的開發隊伍、支持跨平臺的應用(可以運行在幾乎所有的Unix、Windows、Linux系統平臺上)、模塊化結構以及它的可移植性等方面。
如果你準備選擇Web服務器,毫無疑問Apache是你的最佳選擇。接下來就開始我們的宏大的計劃。
2.Mysql 數據庫的簡介
MySQL在過去由於性能高、成本低、可靠性好,已經成爲最流行的開源數據庫,因此被廣泛地應用在Internet上的中小型網站中。隨着MySQL的不斷成熟,它也逐漸用於更多大規模網站和應用,比如維基百科、Google和Facebook等網站。非常流行的開源軟件組合LAMP中的“M”指的就是MySQL。
3. PHP的簡介
PHP 是一門簡單而有效的編程語言,它像是粘合劑,可以將 LAMP 系統所有其他的組件粘合在一起。您可以使用 PHP 編寫能訪問 MySQL 數據庫中的數據和 Linux 提供的一些特性的動態內容。
LAMP 安裝 配置
配置環境
操作系統:RedHat Enterprise 5 2.6.18-164.el5
然後下載文件 mysql, apache, php ,請到下面的官方網址下載相應軟件
http://www.apache.org/
http://www.php.net/
http://www.mysql.com/
在這裏我們使用 server 目錄下的相關rpm包
httpd-2.2.3-31.el5.i386.rpm apache 主配置文檔
httpd-devel-2.2.3-31.el5.i386.rpm
httpd-manual-2.2.3-31.el5.i386.rpm apache的相關手冊
mysql-5.0.77-3.el5.i386.rpm mysql的rpm 包
mysql-server-5.0.77-3.el5.i386.rpm mysql服務器的主配置文檔
php-5.1.6-23.2.el5_3.i386.rpm php 動態腳本
php-mysql-5.1.6-23.2.el5_3.i386.rpm php和mysql數據庫之間的連接器件
其他
phpMyAdmin-2.11.10.1-all-languages.zip phpmyadmin的管理工具的源碼
phpwind_GBK_8.3.zip phpwind的論壇的源碼
一:安裝apache
1:[root@ www.linuxidc.com ~]# yum install http* 安裝http的包
[root@ www.linuxidc.com ~]# cd /var/www/html/
[root@ www.linuxidc.com html]# ll
total 0
2:[root@ www.linuxidc.com html]# vim index.html 建立一個測試頁
hello the world!!!!!!!!
3: [root@ www.linuxidc.com html]# service httpd start 啓動httpd的服務
Starting httpd: [ OK ]
4:測試
5: [root@ www.linuxidc.com html]# chkconfig httpd on 設置httpd服務爲自動啓動
二:安裝mysql
1:[root@ www.linuxidc.com html]# yum install mysql* 安裝mysql的包
Running Transaction
Installing : perl-DBI 1/10
Installing : mysql 2/10
Installing : perl-DBD-MySQL 3/10
Installing : mysql-server 4/10
Installing : libtool-ltdl 5/10
Installing : unixODBC 6/10
Installing : mysql-connector-odbc 7/10
Installing : mysql-bench 8/10
Installing : mysql-test 9/10
Installing : mysql-devel 10/10
2[root@ www.linuxidc.com html]# service mysqld start 啓動mysqld服務
3: [root@ www.linuxidc.com html]# chkconfig mysqld on 設置mysqld爲自動啓動
[root@ www.linuxidc.com html]# netstat -tupln|grep mysql 查看端口的狀態
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 449/mysqld
[root@ www.linuxidc.com html]#
三:安裝php
1:建立一個index.php的測試頁面
[root@ www.linuxidc.com html]# cd /var/www/html/
[root@ www.linuxidc.com html]# ll
total 4
-rw-r--r-- 1 root root 24 Mar 9 01:09 index.html
[root@ www.linuxidc.com html]# mv index.html index.php
[root@ www.linuxidc.com html]# ll
total 4
-rw-r--r-- 1 root root 24 Mar 9 01:09 index.php
[root@ www.linuxidc.com html]# vim index.php
hello the world!!!!!!!!
phpinfo();
?>
注意:在這裏我們知道了php是apache的一個模塊,這樣的話可以減少對系統資源的佔用
Cat /etc/httpd/conf.d/php.conf
Cd /etc/httpd/modues/libphp5.mode
2:重新啓動apache的服務
[root@ www.linuxidc.com html]# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
3:在客戶機上進行測試
4:修改 /var/www/html/index.php 的首頁
[root@ www.linuxidc.com ~]# vim /var/www/html/index.php
hello the world!!!!!!!!
$link=mysql_connect('127.0.0.1','root','');
if($link)
echo "ok";
else
echo "not ok";
?>
再次進行測試,驗證php和mysql之間的連接是否正常
這裏我們看到我們已經連接成功,但是這樣管理mysql的話會比較麻煩,安全性也不是很高。
四:我們下載phpmyadmin的圖形化管理工具
1:使用工具下載好的軟件包放在/root的目錄下
[root@ www.linuxidc.com ~]# ll
total 16160
drwxr-xr-x 2 root root 4096 Feb 7 19:03 Desktop
-rw------- 1 root root 1310 Feb 8 01:55 anaconda-ks.cfg
-rw-r--r-- 1 root root 35236 Feb 8 01:55 install.log
-rw-r--r-- 1 root root 3995 Feb 8 01:54 install.log.syslog
-rw-r--r-- 1 root root 4483812 Mar 9 01:03 phpMyAdmin-2.11.10.1-all-languages.zip
-rw-r--r-- 1 root root 11962650 Mar 9 01:03 phpwind_GBK_8.3.zip
2.解壓縮
[root@ www.linuxidc.com ~]# unzip phpMyAdmin-2.11.10.1-all-languages.zip
[root@ www.linuxidc.com ~]# ll
total 16164
drwxr-xr-x 2 root root 4096 Feb 7 19:03 Desktop
-rw------- 1 root root 1310 Feb 8 01:55 anaconda-ks.cfg
-rw-r--r-- 1 root root 35236 Feb 8 01:55 install.log
-rw-r--r-- 1 root root 3995 Feb 8 01:54 install.log.syslog
drwxr-xr-x 9 root root 4096 Aug 20 2010 phpMyAdmin-2.11.10.1-all-languages
-rw-r--r-- 1 root root 4483812 Mar 9 01:03 phpMyAdmin-2.11.10.1-all-languages.zip
-rw-r--r-- 1 root root 11962650 Mar 9 01:03 phpwind_GBK_8.3.zip
-rw-r--r-- 1 root root 688 Mar 9 01:03 server.repo
-rw-r--r-- 1 root root 1141 Mar 8 22:47 userquota.sh
3:移動 phpMyAdmin-2.11.10.1-all-languages 目錄到網站的根目錄下面
[root@ www.linuxidc.com ~]# mv phpMyAdmin-2.11.10.1-all-languages /var/www/html/phpmyadmin
4:在客戶端進行先關的驗證
可以看到我們已經進入了mysql的管理頁面啦,在這裏我們可以增加刪除數據庫,並作相應的操作啦。
爲了安全起見我們可以使用一下的命令給數據庫更改密碼
5: Mysqladmin –u root –p password ‘123456’