LAMP(2)--结合discuz配置apache,mysql搭建论坛

★下载discuzphp

  mkdir /data/www   <== 先建立一个目录,用以存放网站程序
  cd /data/www
  wget  http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_GBK.zip
  unzip Discuz_X3.2_SC_GBK.zipmysql

[root@yue www]# ls
Discuz_X3.2_SC_GBK.zip  readme  upload  utility
web

                         ①      ②       ③算法

①③没有什么用处咱们能够将其删掉了
sql

[root@yue www]# mv upload/*
apache

[root@yue www]# ls
admin.php    crossdomain.xml         index.php   robots.txt  upload
api          data                    install     search.php  userapp.php
api.php      Discuz_X3.2_SC_GBK.zip  member.php  source      utility
archiver     favicon.ico             misc.php    static
config       forum.php               plugin.php  template
connect.php  group.php               portal.php  uc_client
cp.php       home.php                readme      uc_servervim

★配置apacheapi

  • 编辑apache主配置文件 vim /usr/local/apache2/conf/httpd.conf
    浏览器

  #Include conf/extra/httpd-vhosts.conf  <== 将此行最前方的#删除,使这行内容发挥做用app

  • vim /usr/local/apache2/conf/extra/httpd-vhosts.conf

    删除第二个虚拟主机,只保留第一个便可,并对其进行配置

    其详细内容说明以下:

<VirtualHost *:80>

    ServerAdmin webmaster@dummy-host.example.com   <== 管理员邮箱,能够不要
    DocumentRoot "/data/www"       <== 网站根目录      
    ServerName
www.cy111.com      <== 自定义的域名
    ServerAlias www.dummy-host.example.com <== 别名
    ErrorLog "logs/dummy-host.example.com-error_log"  <== 错误日志
    CustomLog "logs/dummy-host.example.com-access_log" common  <== 访问日志
</VirtualHost>

咱们这时候红色两行便可,别的能够先暂且不考虑,能够将其先注释掉

[root@yue www]# /etc/init.d/apachectl -t
Syntax OK           检查一下配置文件有没有问题

[root@yue www]# /etc/init.d/apachectl graceful  从新加载一下配置文件

[root@yue www]# curl -x127.0.0.1:80 www.cy111.com  什么都没输出,说明虚拟主机生效了 

★配置mysql

[root@yue www]# /usr/bin/mysqladmin -uroot password '123456'   为root用户设置密码

[root@yue www]# mysql -uroot -p123456   登陆

mysql> create database discuz;         <== 建立库
Query OK, 1 row affected (0.00 sec)   

mysql> grant all on discuz.* to 'sky'@'localhost' identified by 'yueyue';
Query OK, 0 rows affected (0.00 sec) <== 给本地的sky用户授予权限

在浏览器访问www.cy111.com ,开始安装discuz,其中一个页面要求咱们更改几个目录的权限让其支持apache帐号可写(即:chown daemon:daemon  data  uc_server/data  uc_client/data config),更改完成以后即可以执行下一步了,按照要求操做最终咱们成功搭建了一个论坛。

★为虚拟主机配置用户认证

◆什么是用户认证?

  好比咱们成功搭建了一个论坛,在上面有一个用户登陆的地方,咱们经过用户名和密码能够登陆admin用户,以管理员身份登陆后即可以管理论坛的后台,这其实是很是危险的事情,若是你设置的密码很简单或者有人恶意试出了管理员密码,这均可能形成很大的损失。这时咱们能够针对 ***/admin.php网址作一个限制,在经过认证以后才能够进入管理员登陆页面。

◆用户认证的配置

  • 编辑配置文件 vim /usr/local/apache2/conf/extra/httpd-vhosts.conf

  在先前配置apache时添加的虚拟主机中加入如下内容:

  <Directory /data/web/test>
   AllowOverride AuthConfig  <== 规定咱们接下来要作用户认证了
  </Directory>

  • vim /data/web/test/.htaccess
    加入一些内容:
    AuthName "frank share web"
    AuthType Basic
    AuthUserFile /data/web/test/.htpasswd
    require valid-user

  • 建立apache验证用户

    [root@yue data]# /usr/local/apache2/bin/htpasswd -c /data/www/test/.htpasswd yue
    New password:
    Re-type new password:                   <== 首次添加用户须要加-c命令,第二次就不须要了
    Adding password for user yue   

[root@yue data]# /usr/local/apache2/bin/htpasswd --help
Usage:
    htpasswd [-cimBdpsDv] [-C cost] passwordfile username
    htpasswd -b[cmBdpsDv] [-C cost] passwordfile username password

    htpasswd -n[imBdps] [-C cost] username
    htpasswd -nb[mBdps] [-C cost] username password
 -c  Create a new file.
 -n  Don't update file; display results on stdout.
 -b  Use the password from the command line rather than prompting for it.
 -i  Read password from stdin without verification (for script usage).
 -m  Force MD5 encryption of the password (default).       <== 使用MD5的加密算法
 -B  Force bcrypt encryption of the password (very secure).
 -C  Set the computing time used for the bcrypt algorithm
     (higher is more secure but slower, default: 5, valid: 4 to 31).
 -d  Force CRYPT encryption of the password (8 chars max, insecure). <== 默认
 -s  Force SHA encryption of the password (insecure).
 -p  Do not encrypt the password (plaintext, insecure).
 -D  Delete the specified user.
 -v  Verify password for the specified user.

  • vim /usr/local/apache2/conf/extra/httpd-vhosts.conf

    <Directory /data/www/admin.php>  <== 已悄悄将此前的目录改成文件,咱们试验成功说明写成

                                         文件也能够。
       AllowOverride AuthConfig   <== 在此行下加入一些内容

    </Directory>

    加入:

     AuthName "hera"    <== hera为自定义名称,显示为认证时候的提示信息
     AuthType Basic
     AuthUserFile /data/www/test/.htpasswd
     require valid-user

  • 重启apache服务

  刷新网页,使用以前建立的认证用户进行认证

 

wKiom1TQajKRxspZAACxH6CBbGs819.jpg

wKioL1TQaxuRJDdXAACuU2__io0876.jpg

相关文章
相关标签/搜索