LAMP实现Discuz论坛

一、安装Apache

1. 安装apr

[root@localhost ~]# tar -zxf apr-1.5.2.tar.gz -C /usr/src/

[root@localhost ~]# cd /usr/src/apr-1.5.2/

[root@localhost apr-1.5.2]# ./configure --prefix=/usr/local/apr && make && make install	

2. 安装apr-util

[root@localhost ~]# tar -zxf apr-util*.tar.gz -C /usr/src/

[root@localhost ~]# cd /usr/src/apr-util-1.5.4/

[root@localhost apr-util-1.5.4]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config 		# 指定apr位置

[root@localhost apr-util-1.5.4]# make && make install

3. 安装httpd

[root@localhost ~]# tar zxf httpd-2.4.25.tar.gz -C /usr/src/

[root@localhost ~]# cd /usr/src/httpd-2.4.25/

[root@localhost httpd-2.4.25]# ./configure --prefix=/usr/local/httpd --enable-so --enable-charset-lite --enable-cgi --enable-rewrite

报错: 原因是系统没有识别到apr-util程序

configure: error: APR-util not found. Please read the documentation.

解决方法:

[root@localhost httpd-2.4.25]# ln -s /usr/local/apr-util/bin/* /usr/local/bin/

再次执行

[root@localhost httpd-2.4.25]# ./configure --prefix=/usr/local/httpd --enable-so --enable-charset-lite --enable-cgi --enable-rewrite

再次报错:缺少 pcre-devel程序

configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

解决方法:

[root@localhost httpd-2.4.25]# yum -y install pcre-devel

再次执行

[root@localhost httpd-2.4.25]# ./configure --prefix=/usr/local/httpd --enable-so --enable-charset-lite --enable-cgi --enable-rewrite && make && make install && make && make install

4. 优化httpd路径

[root@localhost httpd-2.4.25]# ln -s /usr/local/httpd/bin/* /usr/local/bin/

[root@localhost httpd-2.4.25]# cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd

5. 添加httpd为系统服务,添加至系统管理工具(systemctl)

[root@localhost httpd-2.4.25]# vim /etc/init.d/httpd 

添加:

\#chkconfig: 2345 23 22

[root@localhost httpd-2.4.25]# chkconfig --add httpd

[root@localhost httpd-2.4.25]# chmod 755 /etc/init.d/httpd 

6. 检查配置文件启动服务

[root@localhost httpd-2.4.25]# httpd -t

[root@localhost httpd-2.4.25]# systemctl start httpd

[root@localhost httpd-2.4.25]# curl 1.1.1.101

<html><body><h1>It works!</h1></body></html>

二、安装MySQL

1.安装Cmake

[root@localhost ~]# tar -zxf cmake-3.15.1.tar.gz -C /usr/src/

[root@localhost cmake-3.15.1]# cd /usr/src/cmake-3.15.1/

[root@localhost cmake-3.15.1]# ./configure 

CMake has bootstrapped.  Now run gmake.

[root@localhost cmake-3.15.1]# gmake && gmake install

\# gmake与make区别不大, gmake为 GNUmake

2.安装MySQL

[root@localhost ~]# tar zxf mysql-5.6.33.tar.gz -C /usr/src/

[root@localhost ~]# cd /usr/src/mysql-5.6.33/

[root@localhost mysql-5.6.33]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc/ -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all && make && make install

报错: CMakeCache.txt发生冲突 缺少 ncurses、ncurses-devel

remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.

解决方法:

[root@localhost mysql-5.6.33]# rm -rf CMakeCache.txt 

[root@localhost mysql-5.6.33]# yum -y install ncurses ncurses-devel

再次执行:

[root@localhost mysql-5.6.33]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc/ -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all && make && make install

3.优化MySQL

[root@localhost mysql-5.6.33]# useradd -M -s /sbin/nologin mysql

[root@localhost mysql-5.6.33]# chown -R mysql:mysql /usr/local/mysql/

[root@localhost mysql-5.6.33]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

[root@localhost mysql-5.6.33]# cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf

cp:是否覆盖"/etc/my.cnf"? y

[root@localhost mysql-5.6.33]# ln -s /usr/local/mysql/bin/* /usr/local/bin/

[root@localhost mysql-5.6.33]# echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile			# 添加变量,防止不同终端找不到mysql服务

[root@localhost mysql-5.6.33]# source /etc/profile 	# 刷新变量

[root@localhost mysql-5.6.33]# chkconfig --add mysqld

[root@localhost mysql-5.6.33]# chmod 755 /etc/init.d/mysqld 

3.修改配置文件

[root@localhost mysql-5.6.33]# vim /etc/my.cnf

 basedir = /usr/local/mysql/

 datadir = /usr/local/mysql/data

 port = 3306

4.初始化数据库

[root@localhost mysql-5.6.33]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data

报错: 缺少 autoconf库

FATAL ERROR: please install the following Perl modules before executing /usr/local/mysql/scripts/mysql_install_db:

Data::Dumper

解决方法:

[root@localhost mysql-5.6.33]# yum -y install autoconf

再次执行初始化命令

[root@localhost mysql-5.6.33]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data

5.启动数据库

[root@localhost mysql-5.6.33]# systemctl start mysqld

修改mysql密码

[root@localhost mysql-5.6.33]# mysqladmin -u root password

三、安装PHP

1.安装libmcrypt

Libmcrypt为mcrypt的依赖包

[root@localhost ~]# tar zxf php/libmcrypt-2.5.8.tar.gz -C /usr/src/

[root@localhost ~]# cd /usr/src/libmcrypt-2.5.8/

[root@localhost libmcrypt-2.5.8]# ./configure && make && make install

[root@localhost libmcrypt-2.5.8]# ln -s /usr/local/lib/libmcrypt* /usr/lib/

2.安装mhash加密算法

[root@localhost ~]# tar zxf php/mhash-0.9.9.9.tar.gz -C /usr/src/

[root@localhost ~]# cd /usr/src/mhash-0.9.9.9/

[root@localhost mhash-0.9.9.9]# ./configure && make && make install

[root@localhost mhash-0.9.9.9]# ln -s /usr/local/lib/libmhash* /usr/lib

3.安装mcrypt扩展加密模块

[root@localhost ~]# tar zxf php/mcrypt-2.6.8.tar.gz -C /usr/src/

[root@localhost ~]# cd /usr/src/mcrypt-2.6.8/

[root@localhost mcrypt-2.6.8]# ./configure 

报错: mcrypt需要libmcrypt支持,默认目录人找不到,需要设置变量指定libmcrypt所在目录

configure: error: *** libmcrypt was not found

解决方法:

[root@localhost mcrypt-2.6.8]# export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

[root@localhost mcrypt-2.6.8]# ./configure && make && make install

4.安装PHP

[root@localhost ~]# tar zxf php/php-5.3.28.tar.gz -C /usr/src/

[root@localhost ~]# cd /usr/src/php-5.3.28/

[root@localhost php-5.3.28]# ./configure --prefix=/usr/local/php --with-mcrypt --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php --enable-mbstring && make && make install

报错: 缺少依赖包 libxml2-devel

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

解决报错:

[root@localhost php-5.3.28]# yum -y install libxml2-devel

再次执行:

[root@localhost php-5.3.28]# ./configure --prefix=/usr/local/php --with-mcrypt --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php --enable-mbstring && make && make install

报错: 发生冲突

/usr/src/php-5.3.28/Zend/zend_language_parser.h:317:5: 错误:与‘zendparse’类型冲突

make: *** [ext/standard/basic_functions.lo] 错误 1

解决方法:

[root@localhost php-5.3.28]# vim /usr/src/php-5.3.28/Zend/zend_language_parser.h

int zendparse (void);改为:

int zendparse(void *compiler_globals);

再次编译安装

[root@localhost php-5.3.28]# ./configure --prefix=/usr/local/php --with-mcrypt --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php --enable-mbstring && make && make install

如报错:

collect2: error: ld returned 1 exit status

make: *** [libphp5.la] 错误 1

解决方法:

[root@localhost php-5.3.28]# yum -y install libtool libtool-ltdl-devel

再次编译安装:

[root@localhost php-5.3.28]# ./configure --prefix=/usr/local/php --with-mcrypt --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php --enable-mbstring && make && make install

3.修改配置文件PHP.ini

[root@localhost php-5.3.28]# cp php.ini-development /usr/local/php/php.ini

default_charset = "utf-8"			# 去掉#  改为 utf-8

short_open_tag = On				# 改为On

2.修改httpd配置文件得以支持PHP

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

<IfModule dir_module>

​    DirectoryIndex index.html index.php			# 添加 index.php

</IfModule>

​    AddType application/x-httpd-php .php			# 添加该行

[root@localhost ~]# systemctl restart httpd

4.优化PHP(ZendGuardLoader)

[root@localhost ~]# tar zxf php/ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz -C /usr/src/

[root@localhost ~]# cp -r /usr/src/ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/ZendGuardLoader.so  /usr/local/php/lib/php

PHP添加ZendGuardLoader支持

Zend_extension=/usr/local/php/lib/php/ZendGuardLoader.so

Zend_loader.enable=1

5.编写PHP连接数据库测试程序

[root@localhost ~]# vim /usr/local/httpd/htdocs/index.php

<?php

​        $servername='localhost';$username='root';$password='123.com';

\#connect mysql

​        $conn=mysql_connect($servername,$username,$password);

\#connect check

​        if(! $conn){

​                die("cannot connect mysql!!");}echo "successful! NB!";

?>

访问测试:

[root@localhost ~]# curl 1.1.1.101/index.php

successful! NB!!

[root@localhost ~]# 

6.安装PHP 网页数据库管理工具

[root@localhost ~]# tar zxf php/phpMyAdmin-4.2.5-all-languages.tar.gz -C /usr/src/

[root@localhost ~]# cp -r /usr/src/phpMyAdmin-4.2.5-all-languages/ /usr/local/httpd/htdocs/phpMyAdmin

\# 将该程序放入网站根目录下

开启防火墙端口:80

[root@localhost ~]# firewall-cmd --add-port=80/tcp

success

客户端访问:

1.1.1.101/phpMyAdmin

用户名为数据库用户

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-vQxfzzrN-1583226231454)(C:\Users\Administrator\AppData\Local\YNote\data\weixinobU7VjmoDcK6mV43CyWcqdjkLo5g\af4f05a10eb3486fa65e78f77d712c9d\image1.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-MBUVBgOy-1583226231457)(C:\Users\Administrator\AppData\Local\YNote\data\weixinobU7VjmoDcK6mV43CyWcqdjkLo5g\36013a5eb88b4e9bb3dd319303ca57da\image2.png)]

可创建数据库

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-oeDCDaGT-1583226231458)(C:\Users\Administrator\AppData\Local\YNote\data\weixinobU7VjmoDcK6mV43CyWcqdjkLo5g\39b6e4e736c24610b4896205f9559432\image3.png)]

  1. 安装论坛

搭建Discuz论坛

  1. 解压
[root@localhost ~]# unzip php/Discuz_7.2_FULL_SC_UTF8.zip -d /usr/src/discuz
  1. 将Discuz目录下的子目录(upload)copy到网页根目录下
[root@localhost ~]# cp -r /usr/src/discuz/upload/ /usr/local/httpd/htdocs/discuz
  1. 客户端访问 1.1.1.101/discuz/install进行安装

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-cCFTPymc-1583226231462)(C:\Users\Administrator\AppData\Local\YNote\data\weixinobU7VjmoDcK6mV43CyWcqdjkLo5g\7857e770ca44413cbca126043bc71296\image4.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-d9IxgNcc-1583226231464)(C:\Users\Administrator\AppData\Local\YNote\data\weixinobU7VjmoDcK6mV43CyWcqdjkLo5g\bdc2e2f596744268a9250cfb307411ab\image5.png)]

# 不可写表示权限不足

解决方法:

[root@localhost ~]# chmod -R 777 /usr/local/httpd/htdocs/discuz/

再次刷新网页

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-OgjEZwHl-1583226231468)(C:\Users\Administrator\AppData\Local\YNote\data\weixinobU7VjmoDcK6mV43CyWcqdjkLo5g\1f0f60e7a50e4152b1002b5425012459\image6.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-6p8kcJig-1583226231470)(C:\Users\Administrator\AppData\Local\YNote\data\weixinobU7VjmoDcK6mV43CyWcqdjkLo5g\86832b400f464c7b82781bb3fb704eec\image7.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-FnpvhzvE-1583226231471)(C:\Users\Administrator\AppData\Local\YNote\data\weixinobU7VjmoDcK6mV43CyWcqdjkLo5g\28de68a034ad468da7eeacf92350ec0d\image8.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-9sZmAkjs-1583226231473)(C:\Users\Administrator\AppData\Local\YNote\data\weixinobU7VjmoDcK6mV43CyWcqdjkLo5g\db0ee4a030814b239f2738e33ad7f5b5\image9.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-JEIiKE8V-1583226231475)(C:\Users\Administrator\AppData\Local\YNote\data\weixinobU7VjmoDcK6mV43CyWcqdjkLo5g\0fcdb67d00034499a795da78b0566d50\image10.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-bpE4PP1p-1583226231478)(C:\Users\Administrator\AppData\Local\YNote\data\weixinobU7VjmoDcK6mV43CyWcqdjkLo5g\4002764ca8b94a18a6a7a921e07aac7f\image11.png)]

查看数据库中是否多出Discuz库

mysql> use discuz;

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-tixOHvlF-1583226231479)(C:\Users\Administrator\AppData\Local\YNote\data\weixinobU7VjmoDcK6mV43CyWcqdjkLo5g\566b0cff40604bec88e2e2caccb0a4ba\image12.png)]

进入该库中查看该库中所有表

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-7U9va7DE-1583226231486)(C:\Users\Administrator\AppData\Local\YNote\data\weixinobU7VjmoDcK6mV43CyWcqdjkLo5g\a40a7ff415bd4aad864b7dbb05d7604a\image13.png)]

查看数据库(Discuz)中的c_uc_members

C_ 为前缀

查看表(c_uc_members)中信息:

mysql> SELECT * FROM c_uc_members\G

*************************** 1. row ***************************

​          uid: 1				# 表示当前有一个用户

​     username: admin

​     password: 1d847618cca685fc2349592decb46f7b

​        email: [email protected]

​         myid: 

​      myidkey: 

​        regip: hidden

​      regdate: 1572619796

  lastloginip: 0

lastlogintime: 0

​         salt: 47346c

​      secques: 

1 row in set (0.00 sec)

注册一个新用户再次查询

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-pUdZp7lE-1583226231488)(C:\Users\Administrator\AppData\Local\YNote\data\weixinobU7VjmoDcK6mV43CyWcqdjkLo5g\83c8380855984dc2b697fafe825ca916\image14.png)]

mysql> SELECT * FROM c_uc_members\G			# 有几段表示有几个用户

*************************** 1. row ***************************

​          uid: 1

​     username: admin

​     password: 1d847618cca685fc2349592decb46f7b

​        email: [email protected]

​         myid: 

​      myidkey: 

​        regip: hidden

​      regdate: 1572619796

  lastloginip: 0

lastlogintime: 0

​         salt: 47346c

​      secques: 

*************************** 2. row ***************************

​          uid: 2					# 表示为第二个用户

​     username: aaa

​     password: 71c7b006513bf5401954bfb0a9c091be

​        email: [email protected]

​         myid: 

​      myidkey: 

​        regip: 1.1.1.222

​      regdate: 1572620402

  lastloginip: 0

lastlogintime: 0

​         salt: 27afff

​      secques: 

2 rows in set (0.00 sec)

修改后端数据库中的用户表( 将用户aaa 改为bbb之后在使用aaa登录不了找不到该用户)

可使用bbb用户代替aaa进行登录

mysql> update c_uc_members set username=‘bbb’ where username=‘aaa’;

Query OK, 1 row affected (0.00 sec)

Rows matched: 1 Changed: 1 Warnings: 0

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-bhu1ec2l-1583226231489)(C:\Users\Administrator\AppData\Local\YNote\data\weixinobU7VjmoDcK6mV43CyWcqdjkLo5g\a6857302672b4f37ae9d141cbc50f41a\image15.png)]

使用bbb登录 只限于用户名,其余信息没有更改

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-j0jqmBrk-1583226231493)(C:\Users\Administrator\AppData\Local\YNote\data\weixinobU7VjmoDcK6mV43CyWcqdjkLo5g\a3e3dda3802741819691d16b92e559fc\image16.png)]

发布了13 篇原创文章 · 获赞 2 · 访问量 474

猜你喜欢

转载自blog.csdn.net/RunzIyy/article/details/104636394