LAMP源码安装Discuz论坛

一、Mysql安装

http://mirrors.sohu.com/mysql/MySQL-5.1/   Mysql下载网站
cd /usr/local/src/
wget http://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.72-linux-i686-glibc23.tar.gz
tar zxvf mysql-5.1.72-linux-i686-glibc23.tar.gz 
mv mysql-5.1.72-linux-i686-glibc23 /usr/local/mysql
cd ../ 
ll 
useradd -s /sbin/nologin -M mysql
mkdir -p /data/mysql
chown -R mysql:mysql /data/mysql
cd mysql/
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql    #初始化数据
echo $?

cp /etc/my.cnf /etc/my.cnf.bak                         #备份配置文件
cp support-files/my-large.cnf /etc/my.cnf            #复制配置模板到
vim /etc/my.cnf           编译MySql配置文件
#log-bin=mysql-bin            #记录查询、删除、更新数据时记录日志,配置MySql主从时需要,这里暂时不需要,先注释
#binlog_format=mixed
#server-id      = 1
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld    #复制启动脚本到init.d目录下
 vim /etc/init.d/mysqld               #编辑启动配置文件,指定数据目录
basedir=/usr/local/mysql
datadir=/data/mysql

vim /etc/profile.d/path.sh         #将mysql添加进PATH路径#!/bin/bashexport PATH=$PATH:/usr/local/mysql/bin/source !$    #更新PATH路径echo $PATH    #查看是否生效/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/mysql/bin/
chkconfig --add mysqld             #开机启动
chkconfig mysqld on

/etc/init.d/mysqld start              #启动服务
Starting MySQL... SUCCESS! 
netstat -tnplu | grep mysql
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      1282/mysqld  
如果启动不了,请到 /data/mysql/ 下查看错误日志,这个日志通常是主机名.err.

错误1:
Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
解决方法:
yum install  libaio-devel –y

错误2:
./bin/my_print_defaults: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory
解决方法:
下载64位数据库

错误3:
Starting MySQL.Manager of pid-file quit without updating fi[FAILED]
解决方法:
vim /etc/init.d/mysqld               #编辑启动配置文件,指定数据目录
basedir=/usr/local/mysql
datadir=/data/mysql

二、安装Apache

yum install -y pcre pcre-devel apr apr-devel  zlib-devel  #安装相关依赖包cd /usr/local/src/
wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.2.31.tar.gz
tar xvf httpd-2.2.31.tar.gz 
cd httpd-2.2.31
./configure --prefix=/usr/local/apache2 --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --with-pcre
echo $?
make
echo $?
make install
echo $?
vim /etc/profile.d/path.sh         #将apache添加进PATH路径#!/bin/bashexport PATH=$PATH:/usr/local/mysql/bin/:/usr/local/apache2/bin/source 
!$    #更新PATH路径
echo $PATH    #查看是否生效
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/mysql/bin/
apachectl start       #启动服务
ps aux | grep httpd      #查看进程
root     32632  0.0  0.1   4200  1936 ?        Ss   07:54   0:00 /usr/local/apache2/bin/httpd -k start
daemon   32670  0.0  0.1   4200  1100 ?        S    08:02   0:00 /usr/local/apache2/bin/httpd -k start
root     32679  0.0  0.0   6048   776 pts/0    S+   08:05   0:00 grep httpd
netstat -tnlp | grep httpd      #查看端口
tcp        0      0 :::80                       :::*                        LISTEN      32632/httpd

2.1、编译参数详解:

--prefix=/usr/local/apache2     #安装目录

--with-included-apr    #依赖的组件模块,支持跨平台

--enable-rewrite=shared    #动态扩展的模式安装

--with-pcre     #正则的支持库

2.2、错误信息:

安装错误

2.2.1.configure: error: mod_deflate has been requested but can not be built due to prerequisite failures
解决方法:
yum install zlib-devel -y 
wget ftp://rpmfind.net/linux/centos/6.7/os/i386/Packages/zlib-devel-1.2.3-29.el6.i686.rpm  
rpm -ivh zlib-devel-1.2.3-29.el6.i686.rpm
2.2.2checking for APR-util... reconfig
configure: error: Cannot use an external APR with the bundled APR-util
解决方法:
yum install apr apr-util -y

启动错误:

2.2.3:httpd: apr_sockaddr_info_get() failed for lab-1-c6.7-x32
httpd: Could not reliably determine the server‘s fully qualified domain name, using 127.0.0.1 for ServerName
解决方法:
vim /etc/hosts    #编辑hosts文件,增加主机名
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4 lab-1-c6.7-x32
2.2.4:httpd: Could not reliably determine the server‘s fully qualified domain name, using lab-1-c6.7-x32 for ServerName
解决方法:
 cp /usr/local/apache2/conf/httpd.conf /usr/local/apache2/conf/httpd.conf.bak    #备份配置文
找到以下内容,取消注释#ServerName www.example:80
 /usr/local/apache2/bin/apachectl restart    #重启服务

2.3、配置Apache

apachectl -t    #查看Apache配置文件语法是否错误

apachectl start\restart\stop\graceful  开启\重启\关闭\重载

apachectl -M    #查看Apache模块

ls /usr/local/apache2/modules/           #绿色的是动态加载模块

httpd.exp  mod_deflate.so  mod_expires.so  mod_rewrite.so

ls /usr/local/apache2/bin/httpd           #橙色的是静态态加载模块

/usr/local/apache2/bin/httpd

apachectl -l    #查看Apache静态模块和工作模式

三、Apache的工作模式

/usr/local/src/httpd-2.2.31/./configure --help | less
  --with-mpm=MPM          Choose the process model for Apache to use.
                          MPM={beos|event|worker|prefork|mpmt_os2|winnt}

#常见的工作模式有worker、prefork两种,2.2默认是prefork,2.4默认是event

/usr/local/apache2/bin/apachectl -l      #查看Apache当前工作模式
prefork.c

3.1、prefork模式

[[email protected] ~]# ps aux | grep httpd        #一个主进程,多个子进程
root     32632  0.0  0.1   4200  1944 ?        Ss   07:54   0:00 /usr/local/apache2/bin/httpd -k start
daemon   32696  0.0  0.1   4200  1100 ?        S    08:21   0:00 /usr/local/apache2/bin/httpd -k start
daemon   32697  0.0  0.1   4200  1100 ?        S    08:21   0:00 /usr/local/apache2/bin/httpd -k start
daemon   32698  0.0  0.1   4200  1100 ?        S    08:21   0:00 /usr/local/apache2/bin/httpd -k start
daemon   32699  0.0  0.1   4200  1100 ?        S    08:21   0:00 /usr/local/apache2/bin/httpd -k start
daemon   32700  0.0  0.1   4200  1100 ?        S    08:21   0:00 /usr/local/apache2/bin/httpd -k start
root       332  0.0  0.0   6048   772 pts/1    S+   08:40   0:00 grep httpd

3.2、worker模式

不仅有主进程和子进程,而且每个子进程下面还有线程

线程的优点:

线程之间共享一段内存,当高并发的情况下,线程很占优势,占用很少的内存

线程的缺点:

一个进程的所有内存会共享给下面所有的线程,若进程下面的某一个线程出现故障,则进程下面其他所有的线程就会收到牵连

3.3、event模式

和worker一样,也是线程的工作形式,但是优化了许多

3.4、worker、prefork和event模式对比

prefork:进程之间故障,不会影响其他进程,但高并发时占用内存较大

worker:同一进程下的线程故障,会影响整个进程,但高并发时占用内存可观

3.5、Apache工作模式的配置

--with-mpm=worker     #编译时指定工作模式

四、PHP编译安装

cd /usr/local/src/ 
wget http://mirrors.sohu.com/php/php-5.5.31.tar.gz
tar xf php-5.5.31.tar.gz 

yum install  zlib libxml libjpeg freetype libpng gd curl libiconv zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gb-devel gb-devel curl-devel  libxslt-devel openssl-devel  bzip2 bzip2-devel  libmcrypt-devel.x86_64 -y    #安装依赖包
cd php-5.5.31

 ./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       #编译参数
echo $?
make
echo $?
make install 
echo $?

4.1 安装错误信息

configure: error: xml2-config not found. Please check your libxml2 installation

解决方法:yum install -y libxml2-devel libxml2

configure: error: Cannot find OpenSSL‘s <evp.h>

解决方法:yum install openssl-devel -y

configure: error: Please reinstall the BZip2 distribution

解决方法:yum install -y bzip2 bzip2-devel

configure: error: jpeglib.h not found.

解决方法:yum install libjpeg-devel -y

configure: error: png.h not found.

解决方法: yum install libpng-devel -y

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

解决方法:yum install -y libmcrypt-devel  #可能需要安装扩展源

4.2 编译参数详解

--with-apxs2=/usr/local/apache2/bin/apxs      #自动安装Apache扩展模块

--with-mysql=/usr/local/mysql           #指定mysql的安装目录

4.3 PHP常见参数
/usr/local/php/bin/php -m    #常见当前模块
/usr/local/php/bin/php -i    #常见模块的配置

五、测试PHP解析

vim /usr/local/apache2/conf/httpd.conf
#找到
#AddType application/x-gzip .tgz
#添加一行:
AddType application/x-httpd-php .php
#添加index.php
DirectoryIndex index.html index.php
/usr/local/apache2/bin/apachectl -t    #检测语法
Syntax OK
cd /usr/local/apache2//htdocs     #编写一个php文件
 vim info.php
<?php
phpinfo();
?>
/usr/local/php/bin/php -i | less         #测试,同时也记录PHP编译参数
phpinfo()
PHP Version => 5.5.31
System => Linux lab-1-c6.7-x32 2.6.32-573.el6.i686 #1 SMP Thu Jul 23 12:37:35 UTC 2015 i686
Build Date => Jan 19 2016 10:09:40
Configure Command =>  ‘./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‘ ‘--enab
cat /usr/local/apache2/build/config.nice  #apache编译参数路径cat /usr/local/mysql/bin/mysqlbug | grep -i conf  #Mysql编译参数路径curl 192.168.1.200/info.php | head -10   #使用curl查看  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current                                 Dload  Upload   Total   Spent    Left  Speed  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><style type="text/css">body {background-color: #ffffff; color: #000000;}

5.1PHP的配置

cp /usr/local/src/php-5.5.31/php.ini-production /usr/local/php/etc/php   #复制配置文件
apachectl graceful  重新加载PHP配置文件

六、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/* ./
rm -rf readme/ utility/ upload/ Discuz_X3.2_SC_GBK.zip 
vim /usr/local/apache2/conf/httpd.conf
找到以下内容,取消注释
#Include conf/extra/httpd-vhosts.conf     #启用虚拟主机配置文件
cp  /usr/local/apache2/conf/extra/httpd-vhosts.conf  /usr/local/apache2/conf/extra/httpd-vhosts.conf.bak      #备份配置文件
vim /usr/local/apache2/conf/extra/httpd-vhosts.conf
<VirtualHost *:80>
   #ServerAdmin [email protected]           #管理员邮箱,不使用先注释
    DocumentRoot "/data/www"                               #指定文件目录
    ServerName www.szk.com                                #指定域名
    ServerAlias www.test.com                               #指定域名别名
   #ErrorLog "logs/dummy-host.example.com-error_log"       #错误日志和访问日志先注释
   #CustomLog "logs/dummy-host.example.com-access_log" common
</VirtualHost>
apachectl -t                #检查配置文件语法
httpd: Could not reliably determine the server‘s fully qualified domain name, using lab-1-c6.7-x32 for ServerName
Syntax OK
vim /usr/local/apache2/conf/httpd.conf
找到以下内容,取消注释
#ServerName www.example:80
/usr/local/apache2/bin/apachectl start
访问报403错误,不允许访问
vim /usr/local/apache2/conf/httpd.conf
#找到Deny from all改成Allow from all
/usr/local/apache2/bin/apachectl graceful   #重载服务,进入Discuz安装页面,发现很多目录没有权限

cd /data/www
chown -R daemon config data uc_client/data uc_server/data/    #刷新重试
chown -R php-fpm config data uc_client/data uc_server/data/    #若Nginx更改此所属组

6.1 创建MySql用户

mysql    #进入MySQL
create database discuz;     #创建一个数据库
grant all on discuz.* to ‘szk‘@‘localhost‘ identified by ‘szk‘;    #创建一个用户szk,密码也是

6.2 设定discuz安装参数

6.3 OK

时间: 2024-07-30 10:17:10

LAMP源码安装Discuz论坛的相关文章

centos下lamp源码安装

LAMP指的Linux(操作系统).ApacheHTTP 服务器,MySQL(有时也指MariaDB,数据库软件) 和PHP(有时也是指Perl或Python) 的第一个字母,一般用来建立web 服务器. 安装mysql这里我们用的是mysql-5.6.15-linux-glibc2.5-x86_64.tar.gz的绿色软件包 解压mysql绿色软件包 [[email protected] lamp]# tar -zxvf mysql-5.6.15-linux-glibc2.5-x86_64.t

RHEL7搭建LAMP环境并安装Discuz论坛

一.安装httpd [[email protected] ~]# yum install httpd Loaded plugins: product-id, search-disabled-repos Resolving Dependencies --> Running transaction check ---> Package httpd.x86_64 0:2.4.6-40.el7 will be installed --> Processing Dependency: httpd-

Lamp源码安装参考教程

1.确认搭建LAMP所需的环境是否已经安装: [[email protected] ~]#rpm -q make gcc gcc-c++ zlib-devel libtool libtool-ltdl libtool-ltdl-devel bisonncurses-devel 备注:安装libpng时需要zlib-devel           安装php时需要libtool.libtool-ltdl.libtool-ltdl-devel           安装mysql时需要bison.nc

生产环境下:LAMP源码安装,搭建zabbix监控

1.系统环境检查,版本说明 1)版本说明 #httpd-2.4.25#mysql-5.7.17-linux-glibc2.5-x86_64 二进制压缩版#php5.6.30 #zabbix-3.0.8 2)关闭selinux.iptables,检查系统版本信息 sed -i 's/SELINUX=enabled/SELINUX=disabled/g' /etc/selinux/configgetenforce 0/etc/init.d/iptables stopcat /etc/redhat-r

LAMP源码安装,搭建zabbix监控

#LAMP#httpd-2.2.32#mysql-5.7.17-linux-glibc2.5-x86_64 二进制压缩版#php5.3.271.系统环境优化检查sed -i 's/SELINUX=enabled/SELINUX=disabled/g' /etc/selinux/configgetenforce 0/etc/init.d/iptables stopcat /etc/redhat-release CentOS release 6.7 (Final)uname -r2.6.32-431

lamp源码安装之二进制MySQL5.6.25安装

111 下载解压源码,由于是二进制文件,所以需要解压到/usr/local/目录下 先把自带的mysql移除 [[email protected] lib]# rpm -qa|grep mysql mysql-devel-5.1.73-3.el6_5.x86_64 mysql-libs-5.1.73-3.el6_5.x86_64 mysql-5.1.73-3.el6_5.x86_64 [[email protected] ~]# yum remove mysql 由于源码编译时间太长,所以这里的

lamp 源码安装之 centos6.5源码安装之php5.6.9

下载php5.6.9包并解压 [[email protected] ~]# wget http://cn2.php.net/distributions/php-5.6.9.tar.bz2 [[email protected] ~]# tar xf php-5.6.9.tar.bz2 编译安装 我的编译选项如下 --prefix=/usr/local/php:定义安装的路径 --with-mysql=/usr/local/mysql :指定mysql安装目录 --with-mysqli=/usr/

lamp源码安装出错及解决方案

一. 安装zlib时代码 cd /lamp/zlib-1.2.3 ./configure make make install 之后安装png,代码 cd /lamp/libpng-1.2.31 ./configure --prefix=/usr/local/libpng make make install 在make时 便报错,如下 /lib/libz.a(crc32.o): relocation R_X86_64_32 against `.rodata' can not be used whe

LAMP源码安装

在安装之前首先把开发包组安装. [[email protected] ~]# yum groupinstall "Development Tools" "Development Libraries" -y [[email protected] ~]# yum install gcc gcc-c++ openssl-devel -y 上传需要的安装包: [[email protected] ~]# tar -xf apr-1.5.2.tar.gz -C /usr/lo