LAMP 首先我们要了解LAMP到底是什么

  •   Linux     Linux 是免费开源软件,这意味着源代码可用的操作系统。
  •   Apache   Apache 是使用中最受欢迎的一个开放源码的WEB服务器软件。
  •  MySQL    MySQL 是多线程、多用户的SQL数据库管理系统        
  •   PHP,Perl 或 Python   PHP 是一种编程语言最初设计生产动态网站。PHP 是主要用于服务器端的应用程序软件。Perl 和 Python 类似。

此处就用Linux + Apache + Mysql + PHP 给大家演示一下怎样快速建站,希望您看过之后能有所帮助。此处我们就用rpm包来安装,当然也可以使用源码安装,(后期回味大家演示)第一次搭建论坛建议使用rpm包来安装。

 需要用到的几个rpm包 httpd ,mysql, mysql-server, php, php-mysql php-mbstring ,php-gd。建议使用yum源进行安装,来解决其依赖关系。

  1. [root@localhost ~]# yum install httpd mysql mysql-server -y 
  2. [root@localhost ~]# yum install php php-mysql php-mbstring php-gd -y 
  3.  
  4. [root@localhost ~]# service httpd  start 
  5. [root@localhost ~]# service mysqld start 
  6. [root@localhost html]# chkconfig httpd on   #开机自动启动服务
  7. [root@localhost html]# chkconfig mysqld on  
  8. [root@localhost ~]# netstat -tupln   #查看开放端口
  9. Active Internet connections (only servers) 
  10. Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name    
  11. tcp        0      0 127.0.0.1:2208              0.0.0.0:*                   LISTEN      2934/hpiod           
  12. tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      17908/mysqld  

启动了httpd和mysql服务后就可以进行测试

  1. [root@localhost ~]# cd /var/www/html 
  2. [root@localhost html]# vim index.php 
  3.  <?php 
  4.     phpinfo(); 
  5.  ?> 
  6.    

  1. [root@localhost ~]# cd /var/www/html 
  2. [root@localhost html]# vim index.php 
  3.  
  4.   $link=mysql_connect('localhost','root',''); 
  5.   if ($link) 
  6.         echo "Success..."; 
  7.   else 
  8.         echo "Failure"; 
  9.  
  10. ?> 

和mysql数据库连接正常

此时我们可以进入mysql并为mysql创建密码

  1. [root@localhost ~]# mysql 
  2. Welcome to the MySQL monitor.  Commands end with ; or \g. 
  3. Your MySQL connection id is 3 
  4. Server version: 5.0.45 Source distribution 
  5.  
  6. Type 'help;' or '\h' for help. Type '\c' to clear the buffer. 
  7.  
  8. mysql> show databases;  #查询数据库
  9. +--------------------+ 
  10. | Database           | 
  11. +--------------------+ 
  12. | information_schema |  
  13. | mysql              |  
  14. | test               |  
  15. +--------------------+ 
  16. 3 rows in set (0.01 sec) 
  17.  
  18. mysql> use mysql ;  #进入此数据库
  19. Reading table information for completion of table and column names 
  20. You can turn off this feature to get a quicker startup with -A 
  21.  
  22. Database changed 
  23. mysql> show tables;  #查询数据库内的表
  24. +---------------------------+ 
  25. | Tables_in_mysql           | 
  26. +---------------------------+ 
  27. | columns_priv              |  
  28. | db                        |  
  29. | func                      |  
  30. | help_category             |  
  31. | help_keyword              |  
  32. | help_relation             |  
  33. | help_topic                |  
  34. | host                      |  
  35. | proc                      |  
  36. | procs_priv                |  
  37. | tables_priv               |  
  38. | time_zone                 |  
  39. | time_zone_leap_second     |  
  40. | time_zone_name            |  
  41. | time_zone_transition      |  
  42. | time_zone_transition_type |  
  43. | user                      |  
  44. +---------------------------+ 
  45. 17 rows in set (0.00 sec) 
  46.  
  47. mysql> select host,user,password from user;  #查询表内的内容
  48. +-----------------------+------+----------+ 
  49. | host                  | user | password | 
  50. +-----------------------+------+----------+ 
  51. | localhost             | root |          |  
  52. | localhost.localdomain | root |          |  
  53. | 127.0.0.1             | root |          |  
  54. +-----------------------+------+----------+ 
  55. 3 rows in set (0.00 sec) 
  56. mysql> set password for root@'localhost'=password('redhat');  #设定密码
  57. Query OK, 0 rows affected (0.00 sec) 
  58.  
  59. mysql> set password for root@'localhost.localdomain'=password('redhat'); 
  60. Query OK, 0 rows affected (0.00 sec) 
  61.  
  62. mysql> set password for root@'127.0.0.1'=password('redhat'); 
  63. Query OK, 0 rows affected (0.00 sec) 
  64.  
  65. mysql> flush privileges;  #刷新一下
  66. Query OK, 0 rows affected (0.00 sec) 
  67.  
  68. mysql> select host,user,password from user; 
  69. +-----------------------+------+------------------+ 
  70. | host                  | user | password         | 
  71. +-----------------------+------+------------------+ 
  72. localhost             | root | 27c30f0241a5b69f |  
  73. | localhost.localdomain | root | 27c30f0241a5b69f |  
  74. | 127.0.0.1             | root | 27c30f0241a5b69f |  
  75. +-----------------------+------+------------------+ 
  76. 3 rows in set (0.00 sec) 
  77.  
  78. mysql>   

此时就给mysql设置了密码,登录就需要使用mysql -u root -p 命令来登录数据库我们也可以通过一个图形界面工具phpMyadmin来管理我们的数据库。下面就安装并配置一下phpMyadmin。

配置phpMyadmin

  phphpMyAdmin-2.11.10.1-all-languages.zip 此处使用的不是最新版本。         libmcrypt-2.5.7-5.el5.i386.rpm                                       php-mcrypt-5.1.6-5.el5.i386.rpm   扩展需要用到的rpm包

  1. [root@localhost ~]# unzip phpMyAdmin-2.11.10.1-all-languages.zip  
  2. [root@localhost ~]# mv phpMyAdmin-2.11.10.1-all-languages /var/www/html/phpmyadmin 
  3. [root@localhost ~]# cd /var/www/html/phpmyadmin 

 

出现错误信息是因为我们刚刚给mysql设置了密码,所以就进不去mysql,当没有给mysql设置密码的时候就直接进入管理页面,其实这也造成了数据库的不安全性,接下来就给mysql提供用户验证界面

  1. [root@localhost phpmyadmin]# ls |grep conf 
  2. config.sample.inc.php 
  3. show_config_errors.php 
  4.  
  5. [root@localhost phpmyadmin]# cp config.sample.inc.php config.inc.php  
  6. [root@localhost phpmyadmin]# vim config.inc.php  
  7.  
  8.   17 $cfg['blowfish_secret'] = '123456'; /* YOU MUST FIHIS KIE AUTH! */ 
  9. [root@localhost phpmyadmin]# service httpd restart 

代码效果,给mysql提供了用户验证界面

可以看见此时还无法载入mcrypt,通过安装刚刚提供的两个rpm包来解决这一难题,切记要使用yum localinstall 来安装,--nogpgcheck 不进行签名检查。

  1. [root@localhost ~]# yum localinstall --nogpgcheck libmcrypt-2.5.7-5.el5.i386.rpm php-mcrypt-5.1.6-5.el5.i386.rpm -y 

 

此时输入了用户名和密码可以进入到管理图形界面,随意根据自己需要操作数据库

到此phpMyadmin已经配置完毕,下面来搭建phpwind

搭建phpwind

 

phpwind_GBK_8.3.zip 

  1. [root@localhost ~]unzip phpwind_GBK_8.3.zip 
  2. [root@localhost ~]# cd phpwind_GBK_8.3 
  3. [root@localhost phpwind_GBK_8.3]# ls 
  4.   docs  upload 
  5. [root@localhost phpwind_GBK_8.3]# mv upload/ /var/www/html/ 
  6. [root@localhost phpwind_GBK_8.3]# cd /var/www/html/ 
  7. [root@localhost html]# ls 
  8.   phpmyadmin  upload 

在浏览器中访问

出现了乱码,解决的方法是禁用httpd.conf中的AddDefaultCharset UTF-8这一行就ok
  1. [root@localhost html]# vim /etc/httpd/conf/httpd.conf  
  2.  #AddDefaultCharset UTF-8   #禁用这一行 
  3. [root@localhost ~]# service httpd  restart 

 

 

乱码的问题解决,根据要求修改一下目录文件属性为777,此处为了方便,就把文件夹下的所有文件都改为777了,建议不要这样做,而是根据要求吧每一项该为777就可以了。

  1. [root@localhost phpwind]# chmod -R 777 p_w_upload/* 
  2. [root@localhost phpwind]# chmod -R 777 html/* 
  3. [root@localhost phpwind]# chmod -R 777 data/* 

填写了相关信息并成功安装。

删除install.php

  1. [root@localhost phpwind]# rm install.php  
  2. rm锛..??.??涓€?..浠??.nstall.php?. y        #远程终端连接,有乱码滴 

可以进入论坛喽。

进入后台页面,管理论坛

此时一个论坛就完美的建好了,很快吧,。下面再来给大家演示一下另一个经典的建站工具Discuz。

Discuz的搭建

   Discuz_7.2_FULL_SC_GBK.zip

  1. [root@localhost ~]# unzip Discuz_7.2_FULL_SC_GBK.zip 
  2. [root@localhost ~]# mv upload/* /var/www/html 

在浏览器中进行配置

 

把上图中不可写都设置为可写

  1. [root@localhost html]# setfacl -m u:apache:rw config.inc.php  
  2. [root@localhost html]# setfacl -m u:apache:rw p_w_uploads/ 
  3. [root@localhost html]# setfacl -m u:apache:rw ./forumdata/  
  4. [root@localhost html]# setfacl -m u:apache:rw ./forumdata/cache/  
  5. [root@localhost html]# setfacl -m u:apache:rw ./forumdata/templates/  
  6. [root@localhost html]# setfacl -m u:apache:rw ./forumdata/threadcaches/  
  7. [root@localhost html]# setfacl -m u:apache:rw ./forumdata/logs/ 
  8. [root@localhost html]# setfacl -m u:apache:rw uc_client/data/cache/  

下面一步一步安装,此处不再贴图,最终效果图为

 

Discuz 就搭建完毕了,

在这里给大家演示了phpMyadmin的搭建与扩展 ,phpwind 以及Discuz的搭建,希望对大家有所帮助,错误之处请大家指正。。。继续推出精彩博文,希望大家关注。