LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)

2021年09月15日 阅读数:7
这篇文章主要向大家介绍LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建),主要内容包括基础应用、实用技巧、原理机制等方面,希望对大家有所帮助。

LAMP(Linux-Apache-MySQL-PHP)网站架构是目前国际流行的Web框架,该框架包括:Linux操做系统,Apache网络服务器,MySQL数据库,Perl、PHP或者Python编程语言,全部组成产品均是开源软件,是国际上成熟的架构框架,不少流行的商业应用都是采起这个架构,和Java/J2EE架构相比,LAMP具备Web资源丰富、轻量、快速开发等特色,微软的.NET架构相比,LAMP具备通用、跨平台、高性能、低价格的优点,所以LAMP不管是性能、质量仍是价格都是企业搭建网站的首选平台。php

下面咱们便开始lamp环境的搭建,及lamp的应用。
为方便咱们后续软件包的安装,
配置本地yum:
[root@localhost ~]# vim /etc/yum.repos.d/rhel-debuginfo.repo
[rhel-server]
name=Red Hat Enterprise Linux server
baseurl=file:///mnt/cdrom/Server
enabled=1
gpgcheck=1
gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-redhat-release
LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_lamp
yum配置完成,开始lamp环境搭建:
查看相关的软件包:
[root@localhost ~]# yum list all |grep -E "httpd|mysql|php"
LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_discuz_02
而后来安装咱们所需的软件包:
[root@localhost ~]# yum install httpd mysql mysql-server php php-mysql php-gd php-mbstring php-xml
LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_环境搭建_03
LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_discuz_04
接下来便要开启相关服务:
[root@localhost ~]# service httpd start
启动 httpd:                                                [肯定]
[root@localhost ~]# service mysqld start
LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_discuz_05
LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_lamp_06
设置开机启动:
[root@localhost ~]# chkconfig httpd on
[root@localhost ~]# chkconfig mysqld on
[root@localhost ~]#
同时还能够查看咱们的mysql服务的端口:
[root@localhost ~]# netstat -tupln |grep mysqld
LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_discuz_07
咱们能够尝试进入数据库,初始默认root,密码为空。
[root@localhost ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.77 Source distribution
 
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show databases;                //查看全部数据库
+--------------------+
| Database            |
+--------------------+
| information_schema |
| mysql               |
| test                |
+--------------------+
3 rows in set (0.00 sec)
 
mysql>
mysql> use mysql;                     //使用数据库(此处使用mysql数据库)
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
 
Database changed
mysql> show tables;                  //查看该数据库全部表(mysql数据库下的全部表)
+---------------------------+
| Tables_in_mysql            |
+---------------------------+
| columns_priv               |
| db                         |
| func                       |
| help_category              |
| help_keyword               |
| help_relation              |
| help_topic                 |
| host                       |
| proc                       |
| procs_priv                 |
| tables_priv                |
| time_zone                  |
| time_zone_leap_second      |
| time_zone_name             |
| time_zone_transition       |
| time_zone_transition_type |
| user                       |
+---------------------------+
17 rows in set (0.00 sec)
 
mysql>
mysql> \q;                                               //退出数据库操做界面
Bye
[root@localhost ~]#
LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_phpmyadmin_08
LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_phpmyadmin_09
LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_环境搭建_10
为咱们的root帐号配置密码:
[root@localhost ~]# mysqladmin -u root -p password '123'          配置新密码为 123
Enter password:                注意:此处要输入的是旧密码,为空,咱们直接回车便可。
[root@localhost ~]#
LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_discuz_11
而后即可以在进入试试,看看密码是否已经生效:
[root@localhost ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.0.77 Source distribution
 
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
 
mysql>
LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_phpmyadmin_12
如图示,密码已经生效。
而后,进入/var/www/html目录下,编辑index.php文件
[root@localhost html]# vim index.php
<?php
phpinfo();
?>
~    
LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_lamp_13
而后咱们便在宿主机上看看能不能访问到这个页面:
在宿主机浏览器或运行里输入虚拟机的ip:
LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_discuz_14
LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_环境搭建_15
如上图,咱们已经可以查看php的相关信息了。
接下来进行进一步的测试:
从新编辑咱们的index.php文件:
[root@localhost html]# vim index.php
<?php
$link=mysql_connect('127.0.0.1','root','123');
if($link)
echo "ok";
else
echo "not";
?>
LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_lamp_16
   
而后再进行上面的操做,在宿主机上:
LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_环境搭建_17
LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_discuz_18
如上图所示,成功访问。
当咱们关闭mysqld服务时,就不能访问了。以下图:
LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_phpmyadmin_19
LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_discuz_20
咱们这部分的测试已经结束了,接下来安装phpmyadmin(注意版本匹配问题),图形化管理。
以下图所示,咱们的root/目录下已经有了相关软件包:
LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_discuz_21
解压缩:
拆解到当前目录,而后移动到/var/www/html/phpmyadmin
[root@localhost ~]# unzip phpMyAdmin-2.11.10.1-all-languages.zip
[root@localhost ~]# mv phpMyAdmin-2.11.10.1-all-languages /var/www/html/phpmyadmin
[root@localhost ~]#
 
 
在咱们的浏览器里访问 http://192.168.44.127/phpmyadmin
出现了以下页面:                                   

LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_环境搭建_22

 

解决上面问题的办法:
先拷贝咱们的阳样例文件,命名为config.inc.php,而后修改config.inc.php文件
[root@localhost phpmyadmin]# cp -p config.sample.inc.php config.inc.php
修改第十七行,引号之间的内容能够随便填:

 

LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_phpmyadmin_23

LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_环境搭建_24

 

保存退出后,
重启咱们的apache服务:
[root@localhost phpmyadmin]# service httpd restart
中止 httpd:                                                [肯定]
启动 httpd:                                                [肯定]
[root@localhost phpmyadmin]#
刷新咱们刚才的页面,便么有问题了。(若是不行,请清理浏览器的缓存)

 

LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_phpmyadmin_25

 

 

能够发现页面下方还报有一个小错误,没法载入mcrypt扩展。
那么咱们便要安装mcrypt安装包
[root@localhost ~]# rpm -ivh libmcrypt-2.5.7-5.el5.i386.rpm    //该包为关联包
warning: libmcrypt-2.5.7-5.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 217521f6
Preparing...                 ########################################### [100%]
   1:libmcrypt              ########################################### [100%]
[root@localhost ~]# rpm -ivh php-mcrypt-5.1.6-5.el5.i386.rpm
warning: php-mcrypt-5.1.6-5.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 217521f6
Preparing...                 ########################################### [100%]
   1:php-mcrypt             ########################################### [100%]
[root@localhost ~]#
而后咱们再去刷新以前的页面,即可以发现没有问题了:

 

LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_phpmyadmin_26

 

而后咱们登陆进去,root用户,密码123.

 

LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_lamp_27

 

 

进入图形化管理界面,咱们能够随意建立一个数据库,假设咱们建立一个论坛的数据库discuz。

 

LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_discuz_28

LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_phpmyadmin_29

如图示,咱们已经成功建立discuz数据库。html

搭建好lamp环境以后,咱们即可以进入实际应用过程了:
假设咱们搭建一个论坛,
请自行到discuz官网下载最新压缩包,
在咱们的root目录下已经有Discuz_X2.5_SC_GBK.zip了:

(咱们在此处使用的是discuz,一样流行的还有phpwind以及国外的wordpress,使用方法大同小异)mysql

LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_环境搭建_30

 

解压缩到/var/www/html/mybbs目录下
[root@localhost ~]# unzip Discuz_X2.5_SC_GBK.zip -d /var/www/html/mybbs
进入/var/www/html/mybbs目录下查看

 

LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_环境搭建_31

 

而后咱们能够试图直接访问index.php页面:

 

LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_discuz_32

 

 

如上图所示,能成功访问,可是由于编码格式,会出现乱码问题。
咱们须要修改etc/httpd/conf目录下的httpd.conf文件
将UTF-8字符集禁掉(能够在滴行命令模式下搜索UTF:”:/UTF”)
而后重启apache服务:
[root@localhost upload]# vim /etc/httpd/conf/httpd.conf

 

LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_环境搭建_33

 

 

[root@localhost upload]# service httpd restart
中止 httpd:                                                [肯定]
启动 httpd:                                                [肯定]
[root@localhost upload]#
而后咱们从新访问,便不会出现编码问题了:

 

LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_lamp_34

 

进入安装向导,能够看到很详细的安装步骤。
可是由于权限问题,会出现以下提示:

 

LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_phpmyadmin_35

 

那么咱们便去修改相关目录的权限:
[root@localhost upload]# chmod -R o+w data        //-R参数为递归修改
[root@localhost upload]# chmod -R o+w config
[root@localhost upload]# chmod -R o+w uc_client/
[root@localhost upload]# chmod -R o+w uc_server/
[root@localhost upload]#

 

LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_phpmyadmin_36

 

而后刷新咱们的页面,即可以正常进行了:

 

LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_discuz_37

LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_环境搭建_38

LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_discuz_39

LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_环境搭建_40

 

成功安装后,咱们能够进入mysql查看一下:
[root@localhost upload]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 5.0.77 Source distribution
 
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
 
mysql> show databases;
+--------------------+
| Database            |
+--------------------+
| information_schema |
| discuz              |
| mysql               |
| test                |
+--------------------+
4 rows in set (0.00 sec)
 
mysql> use discuz;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
 
Database changed
mysql> show tables;
+--------------------------------------+
| Tables_in_discuz                      |
+--------------------------------------+
| discuz_common_admincp_cmenu           |
| discuz_common_admincp_group           |
| discuz_common_admincp_member          |
| discuz_common_admincp_perm            |
| discuz_common_admincp_session         |
| discuz_common_admingroup              |
| discuz_common_adminnote               |
| discuz_common_advertisement           |
| discuz_common_advertisement_custom    |
| discuz_common_banned                  |
| discuz_common_block                   |
| discuz_common_block_favorite          |
| discuz_common_block_item              |
| discuz_common_block_item_data         |
| discuz_common_block_permission        |
| discuz_common_block_pic               |
| discuz_common_block_style             |
| discuz_common_block_xml               |
| discuz_common_cache                   |
| discuz_common_card                    |
| discuz_common_card_log                |
| discuz_common_card_type               |
| discuz_common_connect_guest           |
| discuz_common_credit_log              |
| discuz_common_credit_rule             |
| discuz_common_credit_rule_log         |
| discuz_common_credit_rule_log_field |
| discuz_common_cron                    |
| discuz_common_devicetoken             |
| discuz_common_district                |
| discuz_common_diy_data                |
| discuz_common_domain                  |
| discuz_common_failedlogin             |
| discuz_common_friendlink              |
| discuz_common_grouppm                 |
| discuz_common_invite                  |
| discuz_common_magic                   |
| discuz_common_magiclog                |
| discuz_common_mailcron                |
| discuz_common_mailqueue               |
| discuz_common_member                  |
| discuz_common_member_action_log       |
| discuz_common_member_connect          |
| discuz_common_member_count            |
| discuz_common_member_crime            |
| discuz_common_member_field_forum      |
| discuz_common_member_field_home       |
| discuz_common_member_grouppm          |
| discuz_common_member_log              |
| discuz_common_member_magic            |
| discuz_common_member_medal            |
| discuz_common_member_profile          |
| discuz_common_member_profile_setting |
| discuz_common_member_security         |
| discuz_common_member_stat_field       |
| discuz_common_member_status           |
| discuz_common_member_validate         |
| discuz_common_member_verify           |
| discuz_common_member_verify_info      |
| discuz_common_myapp                   |
| discuz_common_myinvite                |
| discuz_common_mytask                  |
| discuz_common_nav                     |
| discuz_common_onlinetime              |
| discuz_common_patch                   |
| discuz_common_plugin                  |
| discuz_common_pluginvar               |
| discuz_common_process                 |
| discuz_common_regip                  |
| discuz_common_relatedlink             |
| discuz_common_report                  |
| discuz_common_searchindex             |
| discuz_common_secquestion             |
| discuz_common_session                 |
| discuz_common_setting                 |
| discuz_common_smiley                  |
| discuz_common_sphinxcounter           |
| discuz_common_stat                    |
| discuz_common_statuser                |
| discuz_common_style                   |
| discuz_common_stylevar                |
| discuz_common_syscache                |
| discuz_common_tag                     |
| discuz_common_tagitem                 |
| discuz_common_task                    |
| discuz_common_taskvar                 |
| discuz_common_template                |
| discuz_common_template_block          |
| discuz_common_template_permission     |
| discuz_common_uin_black               |
| discuz_common_usergroup               |
| discuz_common_usergroup_field         |
| discuz_common_word                    |
| discuz_common_word_type               |
| discuz_connect_disktask               |
| discuz_connect_feedlog                |
| discuz_connect_memberbindlog          |
| discuz_connect_postfeedlog            |
| discuz_connect_tthreadlog             |
| discuz_forum_access                   |
| discuz_forum_activity                 |
| discuz_forum_activityapply            |
| discuz_forum_announcement             |
| discuz_forum_p_w_upload               |
| discuz_forum_p_w_upload_0            |
| discuz_forum_p_w_upload_1             |
| discuz_forum_p_w_upload_2             |
| discuz_forum_p_w_upload_3             |
| discuz_forum_p_w_upload_4             |
| discuz_forum_p_w_upload_5             |
| discuz_forum_p_w_upload_6             |
| discuz_forum_p_w_upload_7             |
| discuz_forum_p_w_upload_8             |
| discuz_forum_p_w_upload_9             |
| discuz_forum_p_w_upload_exif          |
| discuz_forum_p_w_upload_unused        |
| discuz_forum_attachtype               |
| discuz_forum_bbcode                   |
| discuz_forum_collection               |
| discuz_forum_collectioncomment        |
| discuz_forum_collectionfollow         |
| discuz_forum_collectioninvite         |
| discuz_forum_collectionrelated        |
| discuz_forum_collectionteamworker     |
| discuz_forum_collectionthread         |
| discuz_forum_creditslog               |
| discuz_forum_debate                   |
| discuz_forum_debatepost               |
| discuz_forum_faq                      |
| discuz_forum_forum                    |
| discuz_forum_forum_threadtable        |
| discuz_forum_forumfield               |
| discuz_forum_forumrecommend           |
| discuz_forum_groupcreditslog          |
| discuz_forum_groupfield               |
| discuz_forum_groupinvite              |
| discuz_forum_grouplevel               |
| discuz_forum_groupuser                |
| discuz_forum_p_w_picpathtype                |
| discuz_forum_medal                    |
| discuz_forum_medallog                 |
| discuz_forum_memberrecommend          |
| discuz_forum_moderator                |
| discuz_forum_modwork                  |
| discuz_forum_onlinelist               |
| discuz_forum_order                    |
| discuz_forum_poll                     |
| discuz_forum_polloption               |
| discuz_forum_pollvoter                |
| discuz_forum_post                     |
| discuz_forum_post_location            |
| discuz_forum_post_moderate            |
| discuz_forum_post_tableid             |
| discuz_forum_postcache                |
| discuz_forum_postcomment              |
| discuz_forum_postlog                  |
| discuz_forum_poststick                |
| discuz_forum_promotion                |
| discuz_forum_ratelog                  |
| discuz_forum_relatedthread            |
| discuz_forum_replycredit              |
| discuz_forum_rsscache                 |
| discuz_forum_spacecache               |
| discuz_forum_statlog                  |
| discuz_forum_thread                   |
| discuz_forum_thread_moderate          |
| discuz_forum_threadaddviews           |
| discuz_forum_threadclass              |
| discuz_forum_threadclosed             |
| discuz_forum_threaddisablepos         |
| discuz_forum_threadp_w_picpath              |
| discuz_forum_threadlog                |
| discuz_forum_threadmod                |
| discuz_forum_threadpartake            |
| discuz_forum_threadpreview            |
| discuz_forum_threadrush               |
| discuz_forum_threadtype               |
| discuz_forum_trade                    |
| discuz_forum_tradecomment             |
| discuz_forum_tradelog                 |
| discuz_forum_typeoption               |
| discuz_forum_typeoptionvar            |
| discuz_forum_typevar                  |
| discuz_forum_warning                 |
| discuz_home_album                     |
| discuz_home_album_category            |
| discuz_home_appcreditlog              |
| discuz_home_blacklist                 |
| discuz_home_blog                      |
| discuz_home_blog_category            |
| discuz_home_blog_moderate             |
| discuz_home_blogfield                 |
| discuz_home_class                     |
| discuz_home_click                     |
| discuz_home_clickuser                 |
| discuz_home_comment                   |
| discuz_home_comment_moderate          |
| discuz_home_docomment                 |
| discuz_home_doing                     |
| discuz_home_doing_moderate            |
| discuz_home_favorite                  |
| discuz_home_feed                      |
| discuz_home_feed_app                  |
| discuz_home_follow                    |
| discuz_home_follow_feed               |
| discuz_home_follow_feed_archiver      |
| discuz_home_friend                    |
| discuz_home_friend_request            |
| discuz_home_friendlog                 |
| discuz_home_notification              |
| discuz_home_pic                       |
| discuz_home_pic_moderate              |
| discuz_home_picfield                  |
| discuz_home_poke                      |
| discuz_home_pokearchive               |
| discuz_home_share                     |
| discuz_home_share_moderate            |
| discuz_home_show                      |
| discuz_home_specialuser               |
| discuz_home_userapp                   |
| discuz_home_userappfield              |
| discuz_home_visitor                   |
| discuz_mobile_setting                 |
| discuz_portal_article_content         |
| discuz_portal_article_count           |
| discuz_portal_article_moderate        |
| discuz_portal_article_related         |
| discuz_portal_article_title           |
| discuz_portal_article_trash           |
| discuz_portal_p_w_upload              |
| discuz_portal_category                |
| discuz_portal_category_permission     |
| discuz_portal_comment                 |
| discuz_portal_comment_moderate        |
| discuz_portal_rsscache                |
| discuz_portal_topic                   |
| discuz_portal_topic_pic               |
| discuz_security_evilpost              |
| discuz_security_eviluser              |
| discuz_security_failedlog             |
| discuz_ucenter_admins                 |
| discuz_ucenter_applications           |
| discuz_ucenter_badwords               |
| discuz_ucenter_domains                |
| discuz_ucenter_failedlogins           |
| discuz_ucenter_feeds                  |
| discuz_ucenter_friends                |
| discuz_ucenter_mailqueue              |
| discuz_ucenter_memberfields           |
| discuz_ucenter_members                |
| discuz_ucenter_mergemembers           |
| discuz_ucenter_newpm                  |
| discuz_ucenter_notelist               |
| discuz_ucenter_pm_indexes             |
| discuz_ucenter_pm_lists               |
| discuz_ucenter_pm_members             |
| discuz_ucenter_pm_messages_0          |
| discuz_ucenter_pm_messages_1          |
| discuz_ucenter_pm_messages_2          |
| discuz_ucenter_pm_messages_3          |
| discuz_ucenter_pm_messages_4          |
| discuz_ucenter_pm_messages_5          |
| discuz_ucenter_pm_messages_6          |
| discuz_ucenter_pm_messages_7          |
| discuz_ucenter_pm_messages_8          |
| discuz_ucenter_pm_messages_9          |
| discuz_ucenter_protectedmembers       |
| discuz_ucenter_settings               |
| discuz_ucenter_sqlcache               |
| discuz_ucenter_tags                   |
| discuz_ucenter_vars                   |
+--------------------------------------+
271 rows in set (0.00 sec)
 
mysql> \q
Bye
[root@localhost upload]#
没有问题,那么接下来咱们试试看 可不能够访问了:

 

LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_discuz_41

 

 

如上图所示,成功访问。
咱们以管理员身份登陆,即可以在该页面对搭建的论坛进行操做了。

 

LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_phpmyadmin_42

LAMP环境搭建及应用(phpmyadmin+discuz论坛搭建)_phpmyadmin_43

至于discuz的使用,编者就不在此赘述了,读者能够自行摸索。git