LAMP即Linux+Apache+MySQL+PHPphp
centos5.3 64位鏡像html
下載連接: http://pan.baidu.com/s/11QxVw 密碼: 5zq6mysql
第一步:安裝Apache2sql
1.切換到root用戶, 輸入yum install httpd, 選擇yes, 自動安裝,shell
2.版本:httpd-2.2.3-82.el5.centos.x86_64.rpm數據庫
3.啓動:/etc/init.d/httpd startapache
4.重啓:/etc/init.d/httpd restartcentos
5.中止:/etc/init.d/httpd stop瀏覽器
6.查看運行狀態:/etc/init.d/httpd status安全
關於apache的一些配置文件
1./etc/httpd/conf/httpd.conf:最主要的配置文件;
2./etc/httpd/conf.d/*.conf:這個是 CentOS 的特點, 若是你不想修改原始配置文件 httpd.conf 的話, 其餘配置的在此獨立配置, 啓動 apache 時, 這個文件就會被讀入到主要配置文件;
3./usr/lib/httpd/modules:apache 支持不少的模塊, 您想要使用的模塊默認都放置在此目錄;
4./var/www/html:這裏是 CentOS 默認的"首頁"目錄;
5./var/www/error:默認的系統錯誤信息, 主機設置錯誤或瀏覽器端要求的數據錯誤, 在瀏覽器上出現的錯誤提示就以這裏的信息爲主;
6./var/www/icons:提供 apache 的一些小圖標;
7./var/www/cgi-bin:默認一些可執行的 CGI 程序放置的目錄;
8./var/log/httpd:日誌文件目錄, 這裏的文件很容易變的很大, 須要提供足夠的空間;
9./usr/sbin/apachectl:這是 Apache 的主要執行文件, 這個執行文件實際上是 shell script, 它能夠主動檢測系統上的一些設置值, 好讓您啓動 Apache 時更簡單;
10./usr/sbin/httpd:這是主要的 apache 的二進制文件;
11./usr/bin/htpasswd:當您想登錄某些網頁時, 須要輸入帳號與密碼. 那麼Apache自己就提供一個最基本的密碼保護方式, 該密碼的產生就是經過這個命令實現的.
第二步:安裝MySQL
1.安裝命令:yum install mysql mysql-server
2.版本: mysql.i386 0:5.0.95-5.el5_9
mysql.x86_64 0:5.0.95-5.el5_9
mysql-server.x86_64 0:5.0.95-5.el5_9
3.啓動服務:/etc/init.d/mysqld start
4.查看狀態:/etc/init.d/mysqld status
5.設置root用戶密碼:mysqladmin -u root -p password 123456
Enter password:通常初始密碼爲空, 直接回車便可, 若是不是新用戶則輸入原密碼
6.若是初始密碼不爲空, 或者忘記密碼, 可經過如下方式重置root密碼:
先中止mysql服務:/etc/init.d/mysqld stop
開啓mysql安全模式:mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
開啓新終端, 先切到root用戶, 進入mysql,
[root@localhost /]# mysql -u root mysql mysql> update user set password=password('leaf') where user='root'; Query OK, 3 rows affected (0.01 sec) Rows matched: 3 Changed: 3 Warnings: 0 mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec) mysql> quit; Bye
中止安全模式:/etc/init.d/mysqld stop
從新啓動:/etc/init.d/mysqld start
7.登錄mysql:mysql -u root -p
Enter password:密碼
8./etc/my.cnf:這是Mysql的配置文件, 包括mysql 數據庫的優化;
/usr/lib/mysql:這個目錄是 MySQL 數據庫放置的位置, 務必在備份時將此目錄完整的備份下來
第三步:安裝php5
1.命令:yum install php, 自行安裝, 選yes, 安裝過程很簡單.
2.重啓apache:/etc/init.d/httpd restart
3.測試. 在/var/www/html/ 下新建一個文件test.php
<html> <body> <?php phpinfo(); ?> </body> </html>
在瀏覽器中打開http://localhost/test.php , 會看到不少php的信息, 到此已經成功一大半了
第四步:使php支持mysql
1.安裝所須要的支持包,
命令:yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc
yum install php-mysql
2.重啓apache:/etc/init.d/httpd restart
3.在瀏覽器中打開http://localhost/test.php , 會看到mysql的信息
第五步:配置apache和mysql開機啓動
1.如系統中沒有chkconfig, 需先安裝chkconfig. 命令爲:yum install chkconfig
2.在切換到root用戶時, 要使用 su -, 沒有-是不行的.
[root@localhost ~]# chkconfig --levels 3 httpd on
[root@localhost ~]# chkconfig --list httpd
httpd 0:off 1:off 2:off 3:on 4:off 5:off 6:off
[root@localhost ~]# chkconfig --levels 3 mysqld on
[root@localhost ~]# chkconfig --list mysqld
mysqld 0:off 1:off 2:off 3:on 4:off 5:off 6:off
關於chkconfig的詳細用法後續會介紹
到此LAMP搭建完成