Centos7安装搭建Discuz3.4论坛

  |   0 评论   |   2,250 浏览

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


技术改变人生 Q群:702101215 程序之家3群
IT资源网:www.pplsunny.top
程序之家5群:757629668

评论