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

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了peak学Linux--基于centos 6.5搭建LAMP并安装Discuz X3.2相关的知识,希望对你有一定的参考价值。

实验环境:

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

[[email protected] ~]# cd /usr/local/src/

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

[[email protected] src]# tar zxvf mysql-5.1.72-linux-i686-glibc23.tar.gz

[[email protected] src]# mv mysql-5.1.72-linux-i686-glibc23 /usr/local/mysql

[[email protected] src]# useradd -s /sbin/nologin mysql

[[email protected] src]# cd /usr/local/mysql/

[[email protected] mysql]# mkdir -p /data/mysql

[[email protected] mysql]# chown -R mysql:mysql /data/mysql

[[email protected] 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表示没有问题#

[[email protected] mysql]# cp support-files/my-large.cnf /etc/my.cnf

[[email protected] mysql]# cp support-files/mysql.server /etc/init.d/mysqld

[[email protected] mysql]# chmod 755 /etc/init.d/mysqld

[[email protected] mysql]# vim /etc/init.d/mysqld

basedir=    #大概在46行#

datadir=    #大概在47行#

改为

basedir=/usr/local/mysql

datadir=/data/mysql

保存退出

[[email protected] mysql]# chkconfig --add mysqld

[[email protected] mysql]# chkconfig mysqld on

[[email protected] mysql]# service mysqld start

Starting MySQL..                                           [确定]

[[email protected] mysql]# ps aux |grep mysql  #可以看下mysql是否启动#


2.安装Apache

[[email protected] mysql]# cd /usr/local/src/

[[email protected] src]# wget http://mirrors.sohu.com/apache/httpd-2.2.31.tar.gz

[[email protected] src]# tar zxvf httpd-2.2.31.tar.gz

[[email protected] src]# cd httpd-2.2.31

[[email protected] httpd-2.2.31]# ./configure --prefix=/usr/local/apache2  --enable-mods-shared=most  --enable-so

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

[[email protected] httpd-2.2.31]# make

[[email protected] httpd-2.2.31]# echo $?

0

[[email protected] httpd-2.2.31]# make install

[[email protected] httpd-2.2.31]# echo $?

0

[[email protected] httpd-2.2.31]# /usr/local/apache2/bin/apachectl start

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

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

[[email protected] www]# cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd

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

[[email protected] www]# vim /etc/init.d/httpd

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

# chkconfig: 35 70 30

# description: Apache

保存退出

[[email protected] www]# chkconfig --level 35 httpd on


3.安装php

[[email protected] httpd-2.2.31]# cd /usr/local/src/

[[email protected] src]# wget http://mirrors.sohu.com/php/php-5.3.28.tar.gz

[[email protected] src]# tar zxvf php-5.3.28.tar.gz

[[email protected] src]# cd php-5.3.28

[[email protected] 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

[[email protected] 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.

解决方法:

[[email protected] php-5.3.28]# yum install -y epel-release.noarch

[[email protected] php-5.3.28]# yum -y install libmcrypt-devel

继续编译参数

[[email protected] php-5.3.28]# make

[[email protected] php-5.3.28]# echo $?

0

[[email protected] php-5.3.28]# make install

[[email protected] php-5.3.28]# echo $?

0



4.配置Apache结合php

[[email protected] 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解析

[[email protected] ~]# vim /usr/local/apache2/htdocs/1.php

写入:


<?php

    echo "php解析正常";

?>

保存退出

[[email protected] ~]# curl localhost/1.php

php解析正常

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


[[email protected] ~]# vim /usr/local/apache2/htdocs/info.php

写入:

<?php

phpinfo();

?>

保存退出

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



6.安装Discuz

[[email protected] ~]# mkdir /data/www

[[email protected] ~]# cd /data/www/

[[email protected] www]# wget http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_GBK.zip

[[email protected] www]# unzip Discuz_X3.2_SC_GBK.zip

[[email protected] www]# mv upload/* ./


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

[[email protected] www]# vim /usr/local/apache2/conf/httpd.conf

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

改为

Include conf/extra/httpd-vhosts.conf


修改虚拟主机配置文件

[[email protected] www]# vim /usr/local/apache2/conf/extra/httpd-vhosts.conf

只留一个虚拟机配置

<VirtualHost *:80>

    ServerAdmin [email protected]

    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>

保存退出

[[email protected] www]# /usr/local/apache2/bin/apachectl -t

Syntax OK


修改discuz目录权限

[[email protected] www]# chown -R daemon config/ data/ uc_client/data/ uc_server/data/


配置mysql

[[email protected] 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

[[email protected] 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(centos 6.5) 调用java脚本以及定时运行的脚本实例及配置文件具体解释

CentOS 6.5环境下配置Arcgis Server 10.3

[linux]centos7.4上升级python2版本到python3.6.5 安装双版本,默认python3

CentOS-6.5(X64)使用yum安装LAMP环境

Linux学习之CentOS(十三)--CentOS6.4下Mysql数据库的安装与配置

CentOS 6.5安装WordPress(基于LNMP)