LAMP論壇搭建

         LAMP(Linux+Apache+MySql+PHP)架構師一套強大的網站解決方案。LAMP是多個開源項目的首字母縮寫,LAMP網站架構主要應用於動態網站的Wed架構,這種Web框架具有同用,跨平臺,高性能,穩定性等特性,是目前企業部署網站的首選平臺。同時,我們也需要看到Nginx在國內的應用越來越成熟,相對於Apache而言,Nginx對於靜態文件的響應能力要遠遠高於Apache服務器,所以近幾年也興起了LNMP的架構。但對於負載PHP的網站而言,Apache仍然是目前的首選產品。


首先準備實驗環境:

註釋:我是用RPM軟件包來做的,大家也可以用源碼包安裝。


  1. 虛擬機一臺

  2. redhat5.9_64位系統一個 

  3. 本機IP:192.168.0.2

[root@localhost ~]# ifconfig  eth0   192.168.0.2


設置IP的目的是爲了下面實驗訪問的時候方便。



現在我們來安裝相關的軟件:


[root@localhost ~]#  yum  -y  install  php  

[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

wKioL1Ovvkri65quAARE_MxNn0o454.jpg

然後刪除測試文件。

[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



現在就可以再圖形裏面來做了:

wKiom1Ovw8WDjQtDAAQz44HCKUk231.jpg

wKioL1Ovw5eyI8pQAAQFxUpy1pc311.jpg

wKiom1Ovw8bAHtA8AAN-wBhy8qI257.jpg

註釋:下面圖例我們要設一些參數:

數據庫名    : bbs  

數據庫用戶名: bbsuser

數據庫密碼  : 111

設置admin論壇管理員密碼:

管理員賬號  : admin

管理員密碼  : 111

重複密碼    : 111

wKioL1Ovw5fgeysnAAPOsTkE57w642.jpg

wKiom1Ovw8bRTuDEAAPcajBMjj4183.jpg

出現這個是因爲沒有聯網,大家看到這個不要以爲是錯了,出現這個是正常的。

wKioL1Ovw5jC9Zz4AAOXdGdw0DI714.jpg

現在我們在測試一下我們做的論壇,我們在網頁裏輸入本機的IP地址。

wKiom1Ovw8byMlbfAAR6etgX9H0939.jpg

wKioL1Ovw5ij1qKxAASefDAybl8963.jpg

wKiom1Ovw8fi1SzyAATAmbjuJZk077.jpg



    實驗到此結束,如果想在多臺系統上來實驗的話,我們可以加上DNS來做,這樣的話,我們就可更好的驗證了。這樣也是鍛鍊我們做綜合實驗了。



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章