Linux:LAMP搭建DISCU!论坛

LAMP搭建DISCU!论坛

试验机为centos6.8 i686

应用的包

  mysql-5.1.73-linux-i686-glibc23.tar.gz

  httpd-2.2.24.tar.bz2

  php-5.4.44.tar.gz

  Discuz_X3.2_SC_GBK.zip


 

 

mysql

下载

cd /usr/local/src/
wget http://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.73-linux-i686-glibc23.tar.gz

 

 

初始化

 tar zxvf /usr/local/src/mysql-5.1.73-linux-i686-icc-glibc23.tar.gz //解压
 mv mysql-5.1.73-linux-i686-icc-glibc23 /usr/local/mysql //挪动位置
 useradd -s /sbin/nologin mysql //建立 mysql 用户
 cd /usr/local/mysql
 mkdir -p /data/mysql // 创建 datadir,数据库文件会放到这里面
 chown -R mysql:mysql /data/mysql //更改权限
 ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql

--user 定义数据库的所属主,--datadir 定义数据库安装到哪里

 

验证一下 echo $?

 

常见问题

(1)错误: ./bin/mysqld: error while loading shared libraries: libstdc++.so.5: cannot
      open shared object file:
    解决:
      yum install -y compat-libstdc++-33
(2)错误:./scripts/mysql_install_db: ./bin/my_print_defaults: /lib/ld-linux.so.2: bad
      ELF interpreter: No such file or directory
    这是因为,你的系统版本和 mysql 版本不一致。比如,你的系统是 32 位,结果你下载
    了一个 64 位的包。所以,解决办法是,下载合适的包。

 

配置 
  拷贝配置文件
   

  cp support-files/my-large.cnf /etc/my.cnf

 


  拷贝启动脚本文件并修改其属性
   

  cp support-files/mysql.server /etc/init.d/mysqld
  chmod 755 /etc/init.d/mysqld

 


  修改启动脚本
   

  vim /etc/init.d/mysqld
  修改的地方 “datadir=/data/mysql” (前面初始化数据库时定义的目录)

 

 

   把启动脚本加入系统服务项,设定开机启动并启动 mysql
  
   

  chkconfig --add mysqld
  chkconfig mysqld on
  service mysqld start

 


常见问题
    如果启动不了,请到 /data/mysql/ 下查看错误日志,这个日志通常是主机名.err。

    检查mysql 是否启动的命令为:

    
    

   ps aux |grep mysqld

 


 

Apache 

 

下载

 cd /usr/local/src/
 wget http://www.lishiming.net/data/attachment/forum/httpd-2.2.24.tar.bz2

 


解压

 tar jvxf httpd-2.2.24.tar.bz2

 


配置编译参数

cd httpd-2.2.24
./configure --prefix=/usr/local/apache2 --enable-mods-shared=most --enable-so
--prefix 指定安装到哪里, --enable-so 表示启用 DSO

 


常见问题 

 

  (1)

  (2)

  错误

  error: mod_deflate has been requested but can not be built due to prerequisite failures

  解决:
  yum install -y zlib-devel

编译和安装
 

 make
 make install

 



查看 apache 工作模式的命令
 

/usr/local/apache2/bin/apachectl -M
Loaded Modules:
core_module (static)
authn_file_module (static)
authn_default_module (static)
authz_host_module (static)
authz_groupfile_module (static)
authz_user_module (static)
authz_default_module (static)
auth_basic_module (static)
include_module (static)
filter_module (static)
log_config_module (static)
env_module (static)
setenvif_module (static)
version_module (static)
mpm_prefork_module (static)
http_module (static)
mime_module (static)
status_module (static)
autoindex_module (static)
asis_module (static)
cgi_module (static)
negotiation_module (static)
dir_module (static)
actions_module (static)
userdir_module (static)
alias_module (static)
so_module (static)
deflate_module (shared)
expires_module (shared)
rewrite_module (shared)
通过这个命令也可以看到哪些模块时动态,哪些是静态。

 


 

 

php

 

下载 

 cd /usr/local/src
 wget http://cn2.php.net/distributions/php-5.4.44.tar.gz

 


解压源码包

 tar zxf php-5.4.44.tar.gz

 


配置编译参数
 

cd php-5.4.44
 ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php/etc         
--with-mysql=/usr/local/mysql/ --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir
--with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif --disable-ipv6

 

 

常见问题

  安装过程中出现下面这样的错误,说明系统内缺少库文件


   解决的方法是用

  yum list |grep openssl  

  查看库文件包名

  再yum install 进行安装

  如果centos内没有那个库文件yum install -y epel-release安装epel,再安装库文件.

 

编译安装 

 make
 make install

 


配置

  

  1)拷贝 php 配置文件:
   

  cp php.ini-production /usr/local/php/etc/php.ini

 


  2)修改 apache 配置文件
   

  vi /usr/local/apache2/conf/httpd.conf
  找到:
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
  改为:
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
</Directory>
  找到:
AddType application/x-gzip .gz .tgz
  在该行下面添加:
AddType application/x-httpd-php .php
说明,要想支持 php 脚本解析,必须要加上对应的类型。
  找到:
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
  将该行改为:
<IfModule dir_module>
DirectoryIndex index.html index.htm index.php
</IfModule>
说明: 增加针对 php 的索引,如果一个站点默认页为 index.php,那么就得加上这个
index.php 的支持。
找到:
#ServerName www.example.com:80
修改为:
ServerName localhost:80

 



查看配置文件是否有问题

 /usr/local/apache2/bin/apachectl -t

如果显示 Syntax OK,说明配置没问题了。

 

启动服务

 

/usr/local/apache2/bin/apachectl start

 

检查 apache 是否正常启动
 

ps aux |grep httpd

看有没有进程列表。

 

测试 php 解析

vi /usr/local/apache2/htdocs/1.php
写入:
<?php
echo "php works.";
?>
保存后,继续测试:
 curl localhost/1.php

php works. 只有显示这个信息,才算正常解析。如果你的访问不太顺畅,请检测
iptables 规则。

 iptables -nvL
 iptables -F
 service iptables save

 

 


 

 

安装 Discuz !

 

下载 

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.zip
mv upload/* .

 


配置第一个虚拟主机
  删除vim /usr/local/apache2/conf/httpd.conf中的下面这行前面的警号
 

  Include conf/extra/httpd-vhosts.conf

 


  编辑该配置文件
     

   vim /usr/local/apache2/conf/extra/httpd-vhosts.conf
  在最后面,加入如下配置:
  <VirtualHost *:80>
  DocumentRoot "/data/www"
  ServerName www.spiro.com
  </VirtualHost>

 


  先检查配置是否正确
      

  /usr/local/apache2/bin/apachectl -t

 


  

  重启 apache 服务
  

   /usr/local/apache2/bin/apachectl restart

 


 配置 mysql ,给 Discuz !增加一个账户
    给 mysql root 账户设置密码,然后命令行进入 mysql,创建新的库,并创建一个新的帐
    号对该库有所有权限:

 /usrl/local/mysql/bin/mysql -uroot
这样就可以进入到 mysql 命令行内部,接着输入下面的命令,最前面的>不用输入。
> create database discuz;
> grant all on discuz.* to 'spiro'@'localhost' identified by '123456';
> quit

mysql账户是spiro,密码是123456


安装 Discuz !

  在浏览器输入:
  http://www.spiro.com/install/
  根据提示,修改对应目录的权限
   

cd /data/www
chown -R daemon:daemon data uc_server/data uc_client/data config

  让这几个目录支持 apache 运行帐号可写,daemon 就是 apache 的运行账号,在
  /usr/local/apache2/conf/httpd.conf 中用 User 和 Group 定义的。

 

 

posted @ 2017-02-16 18:45  Spiro-k  阅读(1141)  评论(0编辑  收藏  举报