码迷,mamicode.com
首页 > Web开发 > 详细

peak学Linux--基于centos 6.5搭建LAMP并安装Discuz X3.2

时间:2016-08-26 23:06:26      阅读:440      评论:0      收藏:0      [点我收藏+]

标签:linux   mysql   lamp   discuz   

实验环境:

VMware Workstation 10.0.0 build-1295980

centos 6.5 32位(系统ip:192.168.10.50,与物理机桥接,保证可以上外网)

所需的压缩包及下载地址

mysql-5.1.72-linux-i686-glibc23

http://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.72-linux-i686-glibc23.tar.gz

php-5.3.28

http://mirrors.sohu.com/php/php-5.3.28.tar.gz

httpd-2.2.31

http://mirrors.sohu.com/apache/httpd-2.2.31.tar.gz

Discuz_X3.2_SC_GBK

http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_GBK.zip



安装配置过程

  1. 安装mysql

[root@peak ~]# cd /usr/local/src/

[root@peak src]# wget http://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.72-linux-i686-glibc23.tar.gz

[root@peak src]# tar zxvf mysql-5.1.72-linux-i686-glibc23.tar.gz

[root@peak src]# mv mysql-5.1.72-linux-i686-glibc23 /usr/local/mysql

[root@peak src]# useradd -s /sbin/nologin mysql

[root@peak src]# cd /usr/local/mysql/

[root@peak mysql]# mkdir -p /data/mysql

[root@peak mysql]# chown -R mysql:mysql /data/mysql

[root@peak mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql

WARNING: The host ‘peak‘ could not be looked up with resolveip.

This probably means that your libc libraries are not 100 % compatible

with this binary MySQL version. The MySQL daemon, mysqld, should work

normally with the exception that host name resolving will not work.

This means that you should use IP addresses instead of hostnames

when specifying MySQL privileges !

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:


./bin/mysqladmin -u root password ‘new-password‘

./bin/mysqladmin -u root -h peak password ‘new-password‘


Alternatively you can run:

./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 . ; ./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 ./bin/mysqlbug script!

#这里进行初始化,有两个OK表示没有问题#

[root@peak mysql]# cp support-files/my-large.cnf /etc/my.cnf

[root@peak mysql]# cp support-files/mysql.server /etc/init.d/mysqld

[root@peak mysql]# chmod 755 /etc/init.d/mysqld

[root@peak mysql]# vim /etc/init.d/mysqld

basedir=    #大概在46行#

datadir=    #大概在47行#

改为

basedir=/usr/local/mysql

datadir=/data/mysql

保存退出

[root@peak mysql]# chkconfig --add mysqld

[root@peak mysql]# chkconfig mysqld on

[root@peak mysql]# service mysqld start

Starting MySQL..                                           [确定]

[root@peak mysql]# ps aux |grep mysql  #可以看下mysql是否启动#


2.安装Apache

[root@peak mysql]# cd /usr/local/src/

[root@peak src]# wget http://mirrors.sohu.com/apache/httpd-2.2.31.tar.gz

[root@peak src]# tar zxvf httpd-2.2.31.tar.gz

[root@peak src]# cd httpd-2.2.31

[root@peak httpd-2.2.31]# ./configure --prefix=/usr/local/apache2  --enable-mods-shared=most  --enable-so

[root@peak httpd-2.2.31]# echo $?  #初始化配置完成后,可以通过该命令检查是否有错误,返回值是0则表示OK#

[root@peak httpd-2.2.31]# make

[root@peak httpd-2.2.31]# echo $?

0

[root@peak httpd-2.2.31]# make install

[root@peak httpd-2.2.31]# echo $?

0

[root@peak httpd-2.2.31]# /usr/local/apache2/bin/apachectl start

#通过浏览器访问192.168.10.50,浏览器会显示It works!证明Apache已经安装好了#

apache加入chkconfig  #可以不用每次开机都自己启动Apache了#

[root@peak www]# cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd

cp:是否覆盖"/etc/init.d/httpd"? y

[root@peak www]# vim /etc/init.d/httpd

在第一行#!/bin/sh下增加两行文字

# chkconfig: 35 70 30

# description: Apache

保存退出

[root@peak www]# chkconfig --level 35 httpd on


3.安装php

[root@peak httpd-2.2.31]# cd /usr/local/src/

[root@peak src]# wget http://mirrors.sohu.com/php/php-5.3.28.tar.gz

[root@peak src]# tar zxvf php-5.3.28.tar.gz

[root@peak src]# cd php-5.3.28

[root@peak php-5.3.28]# ./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

[root@peak php-5.3.28]# echo $?

0

一些常见的报错

configure: error: jpeglib.h not found.

解决方法:

yum -y install libjpeg-devel

继续编译参数


configure: error: mcrypt.h not found. Please reinstall libmcrypt.

解决方法:

[root@peak php-5.3.28]# yum install -y epel-release.noarch

[root@peak php-5.3.28]# yum -y install libmcrypt-devel

继续编译参数

[root@peak php-5.3.28]# make

[root@peak php-5.3.28]# echo $?

0

[root@peak php-5.3.28]# make install

[root@peak php-5.3.28]# echo $?

0



4.配置Apache结合php

[root@peak php-5.3.28]# vim /usr/local/apache2/conf/httpd.conf

#ServerName www.example.com:80   #大概145行#

改为

ServerName localhost:80


<Directory />    #大概在162开始#

    Options FollowSymLinks

    AllowOverride None

    Order deny,allow

    Deny from all

</Directory>

改为

<Directory />

    Options FollowSymLinks

    AllowOverride None

    Order deny,allow

    Allow from all

</Directory>


<IfModule dir_module>   #大概213行#

    DirectoryIndex index.html

</IfModule>

改为

<IfModule dir_module>

    DirectoryIndex index.html index.htm index.php

</IfModule>


AddType application/x-gzip .gz .tgz  #大概356行#

下面增加

AddType application/x-httpd-php .php

保存退出


5.测试php解析

[root@peak ~]# vim /usr/local/apache2/htdocs/1.php

写入:


<?php

    echo "php解析正常";

?>

保存退出

[root@peak ~]# curl localhost/1.php

php解析正常

#如果不能正常解析php,查看/usr/local/apache2/conf/httpd.conf#


[root@peak ~]# vim /usr/local/apache2/htdocs/info.php

写入:

<?php

phpinfo();

?>

保存退出

通过浏览器访问192.168.10.50/info.php



6.安装Discuz

[root@peak ~]# mkdir /data/www

[root@peak ~]# cd /data/www/

[root@peak www]# wget http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_GBK.zip

[root@peak www]# unzip Discuz_X3.2_SC_GBK.zip

[root@peak www]# mv upload/* ./


配置Apache配置文件启动虚拟主机

[root@peak www]# vim /usr/local/apache2/conf/httpd.conf

#Include conf/extra/httpd-vhosts.conf  #大概444行#

改为

Include conf/extra/httpd-vhosts.conf


修改虚拟主机配置文件

[root@peak www]# vim /usr/local/apache2/conf/extra/httpd-vhosts.conf

只留一个虚拟机配置

<VirtualHost *:80>

    ServerAdmin webmaster@dummy-host.example.com

    DocumentRoot "/usr/local/apache2/docs/dummy-host.example.com"

    ServerName dummy-host.example.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>

改为

<VirtualHost *:80>

    DocumentRoot "/data/www"

    ServerName www.peak.com

    #ErrorLog "logs/dummy-host.example.com-error_log"

    #CustomLog "logs/dummy-host.example.com-access_log" common

</VirtualHost>

保存退出

[root@peak www]# /usr/local/apache2/bin/apachectl -t

Syntax OK


修改discuz目录权限

[root@peak www]# chown -R daemon config/ data/ uc_client/data/ uc_server/data/


配置mysql

[root@peak www]# mysql

mysql> create database discuz;

Query OK, 1 row affected (0.00 sec)

mysql> grant all on discuz.* to ‘peak‘@‘localhost‘ identified by ‘123456‘;

Query OK, 0 rows affected (0.04 sec)

mysql> quit

Bye

[root@peak www]# /usr/local/apache2/bin/apachectl restart


在C:\Windows\System32\drivers\etc修改hosts文件添加dns解析  

192.168.10.50 www.peak.com


浏览器访问192.168.10.50

出现Discuz安装界面,点我同意,环境检查点下一步,设置运行环境,选择全新安装点下一步,数据库配置如图,下一步,直到安装完成。

技术分享

浏览器再访问192.168.10.50就可以访问自己的论坛了,至此大功告成!

技术分享

本文出自 “peak学习Linux” 博客,请务必保留此出处http://peak24.blog.51cto.com/2908625/1843010

peak学Linux--基于centos 6.5搭建LAMP并安装Discuz X3.2

标签:linux   mysql   lamp   discuz   

原文地址:http://peak24.blog.51cto.com/2908625/1843010

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!