LAMP(Linux+Apache+MySql+PHP)架構師一套強大的網站解決方案。LAMP是多個開源項目的首字母縮寫,LAMP網站架構主要應用於動態網站的Wed架構,這種Web框架具備同用,跨平臺,高性能,穩定性等特性,是目前企業部署網站的首選平臺。同時,咱們也須要看到Nginx在國內的應用愈來愈成熟,相對於Apache而言,Nginx對於靜態文件的響應能力要遠遠高於Apache服務器,因此近幾年也興起了LNMP的架構。但對於負載PHP的網站而言,Apache仍然是目前的首選產品。
php
首先準備實驗環境:
html
註釋:我是用RPM軟件包來作的,你們也能夠用源碼包安裝。mysql
虛擬機一臺web
redhat5.9_64位系統一個 sql
本機IP:192.168.0.2數據庫
[root@localhost ~]# ifconfig eth0 192.168.0.2vim
設置IP的目的是爲了下面實驗訪問的時候方便。服務器
如今咱們來安裝相關的軟件:架構
[root@localhost ~]# yum -y install php app
[root@localhost ~]# yum -y install httpd
[root@localhost ~]# yum -y install mysql
[root@localhost ~]# yum -y install mysql-server
[root@localhost ~]# yum -y install php-mysql
修改HTTP配置文件在行添加「 index.php」:
[root@localhost ~]# vim /etc/httpd/conf/httpd.conf
# The index.html.var file (a type-map) is used to deliver content-
# negotiated documents. The MultiViews Option can be used for the
# same purpose, but it is much slower.
#
DirectoryIndex index.php index.html index.html.var
在修改配置文件php添加這行:
[root@localhost ~]# vim /etc/httpd/conf.d/php.conf
AddType application/x-httpd-php .php
寫一個php測試文件:
[root@localhost ~]# vim /var/www/html/index.php
<?php
phpinfo();
?>
而後開開網頁輸入本機IP地址看看是否支持PHP,出現下面這個就證實支持PHP。
[root@localhost ~]# firefox 192.168.0.2
而後刪除測試文件。
[root@localhost ~]# rm -rf /var/www/html/index.php
下載一個軟件包 Discuz_X3.0_SC_UTF8 而後解壓。記住這個軟件包版本不能過高,不讓然會有問題的 。這個事下載地址:
「簡體 UTF8:http://download.comsenz.com/DiscuzX/3.0/Discuz_X3.0_SC_UTF8.zip」
[root@localhost Desktop]# unzip Discuz_X3.0_SC_UTF8.zip
[root@localhost Desktop]# ll
總計 10372
-rwxrw-rw- 1 root root 10575658 2013-12-19 Discuz_X3.0_SC_UTF8.zip
drwxr-xr-x 2 root root 4096 2013-08-02 readme
drwxr-xr-x 12 root root 4096 2013-08-02 upload
drwxr-xr-x 4 root root 4096 2013-08-02 utility
[root@localhost Desktop]# cd upload/
[root@localhost upload]# cp -rf * /var/www/html/
[root@localhost upload]# cd /var/www/html/
[root@localhost html]# chmod 777 -R uc_client/ uc_server/ config/ data/
[root@localhost html]# /etc/init.d/mysqld restart
中止 mysqld: [肯定]
初始化 MySQL 數據庫: Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/bin/mysqlbug script!
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
[肯定]
啓動 mysqld: [肯定]
[root@localhost html]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.95 Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database bbs;
Query OK, 1 row affected (0.00 sec)
mysql> grant all on bbs.* to bbsuser@'localhost' identified by '111' ;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
若是出現這個錯誤的時候「mysql_connect() 不支持 請檢查 mysql 模塊是否正確加載」
咱們要加三行才能夠:
[root@localhost html]# vim /etc/php.ini
extension=msql.so
extension=mysqli.so
extension=pdo_mysql.so
如今重啓全部服務而且加入開機啓動:
[root@localhost ~]# /etc/init.d/httpd restart
[root@localhost ~]# /etc/init.d/mysqld restart
[root@localhost ~]# chkconfig httpd on
[root@localhost ~]# chkconfig mysqld on
如今就能夠再圖形裏面來作了:
註釋:下面圖例咱們要設一些參數:
數據庫名 : bbs
數據庫用戶名: bbsuser
數據庫密碼 : 111
設置admin論壇管理員密碼:
管理員帳號 : admin
管理員密碼 : 111
重複密碼 : 111
出現這個是由於沒有聯網,你們看到這個不要覺得是錯了,出現這個是正常的。
如今咱們在測試一下咱們作的論壇,咱們在網頁裏輸入本機的IP地址。
實驗到此結束,若是想在多臺系統上來實驗的話,咱們能夠加上DNS來作,這樣的話,咱們就可更好的驗證了。這樣也是鍛鍊咱們作綜合實驗了。