Centos7 安装搭建 Discuz3.4 论坛

本贴最后更新于 2164 天前,其中的信息可能已经事过景迁

Centos7 安装搭建 Discuz3.4 论坛

1.安装 php 环境

查看 PHP 是否已经安装

[root@ppl ~]# pwd
/root
[root@ppl ~]# yum list installed | grep php
[root@ppl ~]# 

安装 PHP 吧,这里装的是 PHP7.1 版本

这个清理工作命令,不一定用的上。但是为了防止您的 centos 上面发生 php 冲突,所以,这个命令还是先执行一下更好些。

yum -y remove php*

1、安装 epel-release

输入指令:yum -y install epel-release

[root@ppl ~]# yum -y install epel-release
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-11 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

Installed:
  epel-release.noarch 0:7-11                                                        

Complete!
[root@ppl ~]# 

回车等待安装成功.

2、安装 PHP7.0

1.首先我们先来获取 PHP7.1 的 yum 源,执行下面的指令:

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

php 高版本的 yum 源地址,有两部分,其中一部分是 epel-release,另外一部分来自 webtatic。如果跳过 epel-release 的话,安装 webtatic 的时候,会有错误爆出。

执行过程如下:

[root@ppl ~]# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
Retrieving https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
warning: /var/tmp/rpm-tmp.KO470q: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Preparing...                          ################################# [100%]
        package epel-release-7-11.noarch is already installed
[root@ppl ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
Retrieving https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
warning: /var/tmp/rpm-tmp.QOsCJv: Header V4 RSA/SHA1 Signature, key ID 62e74ca5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:webtatic-release-7-3             ################################# [100%]
[root@ppl ~]# 

获取成功后我们可通过下面的指令来查看 php7.1 的扩展名称,可以按照自己的要求安装

2.查看扩展名指令:yum search php71w 或者 yum -y install php72w

[root@ppl ~]# yum search php71w
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
epel/x86_64/metalink                                         | 5.8 kB  00:00:00     
 * base: mirrors.aliyun.com
 * epel: mirror01.idc.hinet.net
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
 * webtatic: us-east.repo.webtatic.com
epel                                                         | 3.2 kB  00:00:00     
webtatic                                                     | 3.6 kB  00:00:00     
(1/5): epel/x86_64/updateinfo                                | 939 kB  00:00:00     
(2/5): webtatic/x86_64/group_gz                              |  448 B  00:00:01     
(3/5): epel/x86_64/group_gz                                  |  88 kB  00:00:02     
(4/5): webtatic/x86_64/primary_db                            | 424 kB  00:00:02     
(5/5): epel/x86_64/primary                                   | 3.6 MB  00:00:03     
epel 
=============================== N/S matched: php71w ================================
mod_php71w.x86_64 : PHP module for the Apache HTTP Server
php71w-bcmath.x86_64 : A module for PHP applications for using the bcmath library
php71w-cli.x86_64 : Command-line interface for PHP
php71w-common.x86_64 : Common files for PHP
php71w-dba.x86_64 : A database abstraction layer module for PHP applications
php71w-devel.x86_64 : Files needed for building PHP extensions
php71w-embedded.x86_64 : PHP library for embedding in applications
php71w-enchant.x86_64 : Enchant spelling extension for PHP applications
php71w-fpm.x86_64 : PHP FastCGI Process Manager
php71w-gd.x86_64 : A module for PHP applications for using the gd graphics library
php71w-imap.x86_64 : A module for PHP applications that use IMAP
php71w-interbase.x86_64 : A module for PHP applications that use Interbase/Firebird
                        : databases
php71w-intl.x86_64 : Internationalization extension for PHP applications
php71w-ldap.x86_64 : A module for PHP applications that use LDAP
php71w-mbstring.x86_64 : A module for PHP applications which need multi-byte string
                       : handling
php71w-mcrypt.x86_64 : Standard PHP module provides mcrypt library support
php71w-mysql.x86_64 : A module for PHP applications that use MySQL databases
php71w-mysqlnd.x86_64 : A module for PHP applications that use MySQL databases
php71w-odbc.x86_64 : A module for PHP applications that use ODBC databases
php71w-opcache.x86_64 : An opcode cache Zend extension
php71w-pdo.x86_64 : A database access abstraction module for PHP applications
php71w-pdo_dblib.x86_64 : MSSQL database module for PHP
php71w-pear.noarch : PHP Extension and Application Repository framework
php71w-pecl-apcu.x86_64 : APCu - APC User Cache
php71w-pecl-apcu-devel.x86_64 : APCu developer files (header)
php71w-pecl-geoip.x86_64 : Extension to map IP addresses to geographic places
php71w-pecl-igbinary.x86_64 : Replacement for the standard PHP serializer
php71w-pecl-igbinary-devel.x86_64 : Igbinary developer files (header)
php71w-pecl-imagick.x86_64 : Provides a wrapper to the ImageMagick library
php71w-pecl-imagick-devel.x86_64 : Imagick developer files (header)
php71w-pecl-libsodium.x86_64 : Wrapper for the Sodium cryptographic library
php71w-pecl-memcached.x86_64 : Extension to work with the Memcached caching daemon
php71w-pecl-mongodb.x86_64 : PECL package MongoDB driver
php71w-pecl-redis.x86_64 : Extension for communicating with the Redis key-value
                         : store
php71w-pecl-xdebug.x86_64 : PECL package for debugging PHP scripts
php71w-pgsql.x86_64 : A PostgreSQL database module for PHP
php71w-phpdbg.x86_64 : Interactive PHP debugger
php71w-process.x86_64 : Modules for PHP script using system process interfaces
php71w-pspell.x86_64 : A module for PHP applications for using pspell interfaces
php71w-recode.x86_64 : A module for PHP applications for using the recode library
php71w-snmp.x86_64 : A module for PHP applications that query SNMP-managed devices
php71w-soap.x86_64 : A module for PHP applications that use the SOAP protocol
php71w-tidy.x86_64 : Standard PHP module provides tidy library support
php71w-xml.x86_64 : A module for PHP applications which use XML
php71w-xmlrpc.x86_64 : A module for PHP applications which use the XML-RPC protocol

  Name and summary matches only, use "search all" for everything.
[root@ppl ~]# 

3.yum 安装 php71w 和各种拓展,选自己需要的即可。安装的时候有两次要输入 Y 回车,才会继续安装的.

yum install php71w php71w-bcmath php71w-cli php71w-common php71w-devel php71w-embedded php71w-fpm php71w-gd php71w-mbstring php71w-mysqlnd php71w-opcache php71w-pdo php71w-xml
///
执行过程
[root@ppl ~]# yum install php71w php71w-bcmath php71w-cli php71w-common php71w-devel php71w-embedded php71w-fpm php71w-gd php71w-mbstring php71w-mysqlnd php71w-opcache php71w-pdo php71w-xml
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirror01.idc.hinet.net
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
 * webtatic: us-east.repo.webtatic.com
Resolving Dependencies
--> Running transaction check
。。。
---> Package perl-Thread-Queue.noarch 0:3.02-2.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

Install  13 Packages (+8 Dependent packages)

Total download size: 16 M
Installed size: 64 M
Is this ok [y/d/N]: y
Downloading packages:
(1/21): automake-1.13.4-3.el7.noarch.rpm                     | 679 kB  00:00:00     
。。。  
(21/21): php71w-embedded-7.1.24-1.w7.x86_64.rpm              | 1.4 MB  00:00:09     
------------------------------------------------------------------------------------
Total                                                  1.1 MB/s |  16 MB  00:14     
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-webtatic-el7
Importing GPG key 0x62E74CA5:
 Userid     : "Webtatic EL7 <rpms@webtatic.com>"
 Fingerprint: 830d b159 6d9b 9b01 99dc 24a3 e87f d236 62e7 4ca5
 Package    : webtatic-release-7-3.noarch (installed)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-webtatic-el7
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction

  pcre-devel.x86_64 0:8.32-17.el7          perl-Data-Dumper.x86_64 0:2.145-3.el7   
  perl-Test-Harness.noarch 0:3.28-3.el7    perl-Thread-Queue.noarch 0:3.02-2.el7   

Complete!
[root@ppl ~]# 

4.安装成功了,我来查看以下是否安装成功了,输入下面的指令看出版本试试吧!

指令:php -v

能看到下图的内容就证明安装成功了!

[root@ppl ~]# php -v
PHP 7.1.24 (cli) (built: Nov 11 2018 08:03:49) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.1.24, Copyright (c) 1999-2018, by Zend Technologies
[root@ppl ~]# 

5.(选做)安装完成之后,#whereis php 可以看到 php 的安装目录,然后我们来给 php 配置环境,实际上在 centos7 上 php.ini 已经不用像在 Windows 上那样配置了。我们只需要修改这个文件的参数设置 cgi.fix_pathinfo,默认设置值为“1”,用;进行注释或修改为 0 即可。

2.PHP 启动

这个 php-fpm.service 文件,位于下述路径中:/lib/systemd/system/ 中。在这个目录下面,可以看到相关的开机服务项目。

systemctl status php-fpm.service   //查看PHP运行状态
systemctl start php-fpm.service    //启动PHP
systemctl stop php-fpm.service     //停止PHP
systemctl restart php-fpm.service  //重启PHP
systemctl reload php-fpm.service   //重启修改配置
//开机启动
systemctl enable php-fpm.service
systemctl start php-fpm.service

开启 fpm 服务,就基本上大功告成了。

查看PHP状态
[root@ppl ~]# systemctl status php-fpm.service
● php-fpm.service - The PHP FastCGI Process Manager
   Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
[root@ppl ~]# 
[root@ppl ~]## systemctl start php-fpm.service
[root@ppl ~]## systemctl status php-fpm.service
● php-fpm.service - The PHP FastCGI Process Manager
   Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor preset: disabled)
   Active: active (running) since Tue 2018-12-18 05:06:31 EST; 6s ago
 Main PID: 5603 (php-fpm)
   Status: "Ready to handle connections"
   CGroup: /system.slice/php-fpm.service
           ├─5603 php-fpm: master process (/etc/php-fpm.conf)
           ├─5604 php-fpm: pool www
           ├─5605 php-fpm: pool www
           ├─5606 php-fpm: pool www
           ├─5607 php-fpm: pool www
           └─5608 php-fpm: pool www

Dec 18 05:06:31 ppl systemd[1]: Starting The PHP FastCGI Process Manager...
Dec 18 05:06:31 ppl systemd[1]: Started The PHP FastCGI Process Manager.
[root@ppl html]# 

PHP 的监听端口配置

more /etc/php-fpm.d/www.confimage

3.上传 discuz 安装包

1.建立目录

#建立目录,也可以直接部署到html目录中
mkdir /usr/local/nginx/html/bbs

将 Discuz_X3.4_SC_UTF8.zip 解压 (SC 为简体中文版),并将其中 upload 目录下的所有文件上传到前面建立的 BBS 中。

使用-R 参数可实现递归功能,即所有子目录中的文件与目录均拷贝 $ cp -R 源目录/* 目地目录

[root@ppl dir_SC_UTF8]# ll -h
total 4.0K
drwxr-xr-x  2 root root  102 Dec 29  2017 readme
drwxr-xr-x 13 root root 4.0K Dec 29  2017 upload
drwxr-xr-x  4 root root   94 Dec 29  2017 utility
[root@ppl dir_SC_UTF8]# cp -R upload/* /usr/local/nginx/html/bbs

2.修改目录权限

[root@ppl bbs]# cd ../
[root@ppl html]# chmod -R 777 bbs/
[root@ppl html]# ll -h
total 12K
-rw-r--r--  1 root root  537 Nov 23 03:57 50x.html
drwxrwxrwx 13 root root 4.0K Dec 18 05:12 bbs
-rw-r--r--  1 root root  612 Nov 23 03:57 index.html

3.配置 Nginx

        #
        location ~ \.php$ {
            include fastcgi_params;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html/bbs$fastcgi_script_name;
        }

4.进入 nginx 目录并启动

[root@ppl conf]# /usr/local/nginx/sbin/nginx -t 
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@ppl conf]# 
//启动
[root@ppl nginx-1.14.0]# cd /usr/local/nginx
[root@ppl nginx]# pwd
/usr/local/nginx
[root@ppl nginx]# /usr/local/nginx/sbin/nginx
或者
./nginx -c /usr/local/nginx/conf/nginx.conf
//查看Nginx启动状态
[root@ppl sbin]# ps -ef | grep nginx
root       7098      1  0 05:36 ?        00:00:00 nginx: master process ./nginx -c /usr/local/nginx/conf/nginx.conf
nobody     7099   7098  0 05:36 ?        00:00:00 nginx: worker process
root       7121   5777  0 05:36 pts/1    00:00:00 grep --color=auto nginx
[root@ppl sbin]# 

4.浏览器打开安装

http://192.168.153.100/install

ppl0187png
ppl0188png
ppl0189png

安装完毕后,记得一定要删除 install 目录或者删除 install 下面的 index.php。

重命名即可

cd /usr/local/nginx/html/bbs
mv install install.bak
或者
rm -rf ./install

5.扩展

为了让 apache 支持 php7.2,需要修改 apache 的配置文件:

首先,找到 php 的配置文件:php.ini,利用 find 命令:

find / -name php.ini

通常情况下位于/etc 中,也就是/etc/php.ini。

然后找到 apache 的配置文件:httpd.conf

find / -name httpd.conf

然后修改该文件,在该文件最后一行加上:

PHPIniDir /etc/php.ini

表示告诉 apache,php 的配置信息文件。


技术改变人生 Q 群:702101215
爱学习:www.aixx123.com
IT 资源网:www.pplsunny.top


  • B3log

    B3log 是一个开源组织,名字来源于“Bulletin Board Blog”缩写,目标是将独立博客与论坛结合,形成一种新的网络社区体验,详细请看 B3log 构思。目前 B3log 已经开源了多款产品:SymSoloVditor思源笔记

    1063 引用 • 3453 回帖 • 203 关注
  • Linux

    Linux 是一套免费使用和自由传播的类 Unix 操作系统,是一个基于 POSIX 和 Unix 的多用户、多任务、支持多线程和多 CPU 的操作系统。它能运行主要的 Unix 工具软件、应用程序和网络协议,并支持 32 位和 64 位硬件。Linux 继承了 Unix 以网络为核心的设计思想,是一个性能稳定的多用户网络操作系统。

    943 引用 • 943 回帖
  • 建站
    12 引用 • 75 回帖
  • Discuz
    3 引用

相关帖子

欢迎来到这里!

我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。

注册 关于
请输入回帖内容 ...