从零开始,在CentOS 7上部署安装LimeSurvey

2022-09-13 14:15:16 10点赞 182收藏 9评论

前言

因工作需要,近期一直在研究LimeSurvey的部署安装。作为一个小白,在安装过程中,遇到了不少问题,也查阅了各种教程,无奈网上的各种教程要么涵盖不全,要么版本老旧,对新手不是很友好。本着我为人人,人人为我的分享精神,趁着正式部署的机会,收集了素材,把我的安装过程记录下来,方便以后自己查阅,也为各位同好提供参考。本教程旨在为初学者提供帮助,把我遇到的各种问题予以呈现并给出解决办法,难免啰嗦,希望各位大佬不要见笑。第一次发文,不妥之处也请大家多多指教。

本文参考了一下文章,对原作者表示感谢。

http://www.vue5.com/centos/22971.html

https://www.cnblogs.com/it-tsz/p/13211464.html

https://www.cnblogs.com/w-j-q/p/14995398.html

LimeSurve简介

LimeSurvey(前身为PHPSurveyor)是一款在线问卷调查程序,它用PHP语言编写并可以使用MySQL,PostgreSQL或者MSSQL等多种数据库,同时它也是一个开源软件,其最新版本的软件包可以完全免费获取和使用。它集成了调查程序开发、问卷的设计、修改、发布、回收和统计等多项功能,使用它,用户不必了解这些功能的编程细节。

LimeSurve官方网站:https://www.limesurvey.org/

LimeSurve部署安装教程

本教程基于CentOS 7.6系统,其他版本可做参考。

本教程假定在一个全新的CentOS系统中进行部署安装,需要安装Mariadb数据库和PHP,如已安装可跳过这两个步骤。

本教程命令需在“root”账户下运行,如果不是,可使用“su”命令提权,或者在命令前添加“sudo”以获取root权限。

首先更新系统版本。

yum clean all

yum -y update

(一)安装Mariadb

1、安装Mariadb

通过yum安装mariadb-server,默认依赖安装mariadb,一个是服务端、一个是客户端。

yum install mariadb-server

出现如下提示时,输入“y”,等待安装完成。

Install 1 Package (+9 Dependent packages)

Total download size: 21 M

Installed size: 110 M

Is this ok [y/d/N]: y

2、配置Mariadb

1)安装完成后首先要把MariaDB服务开启,并设置为开机启动。

systemctl start mariadb

systemctl enable mariadb

出现如下提示时,表示设置成功。

Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

2)首次安装需要进行数据库的配置。

mysql_secure_installatio

3)配置出现的各个选项。

Enter current password for root (enter fornone): # 输入数据库root密码(注意不是系统root密码),第一次安装还没有设置密码,直接回车即可

Set root password? [Y/n] # 设置密码,y

New password: # 输入您的新密码

Re-enter new password: # 再次输入密码

Remove anonymous users? [Y/n] # 移除匿名用户, y

Disallow root login remotely? [Y/n] # 拒绝root远程登录,y

Remove test database and access to it?[Y/n] # 删除test数据库,y

Reload privilege tables now? [Y/n] # 重新加载权限表,y

4)测试是否能够登录成功

mysql -u root -p

Enter password: # 输入数据库root密码

出现 MariaDB [(none)]> 就表示已经能够正常登录使用MariaDB数据库了。

Welcome to the MariaDB monitor. Commands end with ; or g.

Your MariaDB connection id is 8

Server version: 5.5.60-MariaDB MariaDBServer

Copyright (c) 2000, 2018, Oracle, MariaDBCorporation Ab and others.

Type 'help;' or 'h' for help. Type 'c' toclear the current input statement.

MariaDB [(none)]>

5)登录到数据库服务器后,需要创建一个LimeSurvey安装数据库。

CREATE DATABASE limesurvey_db; #创建名为limesurvey_db的数据库

GRANT ALL PRIVILEGES on limesurvey_db.* to 'root'@'localhost' identified by 'YourPassword'; # "YourPassword"更改为您的数据库root密码

FLUSH PRIVILEGES;

exit

(二)安装PHP7

本文写作时,LimeSurve最新版本是5.3.32,需要 PHP 7.2.5 或更高版本。

从零开始,在CentOS 7上部署安装LimeSurvey

1、更改yum源

CentOS的yum源不存在php7.x,我们首先要更改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

如果出现以下错误,需要配置dns。

//curl: (6) Could not resolve host: mirror.webtatic.com; Unknown error

//error: skipping https://mirror.webtatic.com/yum/el7/webtatic-release.rpm - transfer failed

1)打开文件/etc/resolv.conf:

vi /etc/resolv.conf

2)输入“i”添加以下内容:

nameserver 8.8.8.8

3)输入“:wq”保存并退出编辑。

4)重启网卡

systemctl restart network

2、安装PHP7

1)查看目前能够安装的PHP版本

yum list php*

可以看到可安装的PHP最新版为:php72w。

2)安装php72w

yum -y install php72w

3)安装拓展

yum install php72w-common php72w-fpm php72w-opcache php72w-gd php72w-mysqlnd php72w-mbstring php72w-pecl-redis php72w-pecl-memcached php72w-devel

上述命令一共会安装30个拓展包,安装过程较慢,请耐心等待。

安装的拓展包如下:

php-api, php-bz2, php-calendar, php-ctype, php-curl, php-date, php-exif, php-fileinfo, php-filter, php-ftp, php-gettext, php-gmp, php-hash, php-iconv, php-json, php-libxml, php-openssl, php-pcre, php-pecl-Fileinfo, php-pecl-phar, php-pecl-zip, php-reflection, php-session, php-shmop, php-simplexml, php-sockets, php-spl, php-tokenizer, php-zend-abi, php-zip, php-zlib

4)查看PHP版本

php -v

显示如下信息,说明php72w开发环境基本安装完成。

PHP 7.2.34 (cli) (built: Oct 1 2020 13:37:37) ( NTS )

Copyright (c) 1997-2018 The PHP Group

Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

with Zend OPcache v7.2.34, Copyright (c) 1999-2018, by Zend Technologies

5)重启httpd服务,并设置为开机启动。

systemctl restart httpd.service

systemctl enable httpd.service

出现如下提示时,表示设置成功。

Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

6)安装httpd服务

如果执行重启httpd服务出现以下提示,说明没有安装httpd服务。

Failed to restart httpd.service: Unit notfound.

如果没有安装,则执行下面命令进行安装。

yum install httpd -y

启动httpd服务,并设置为开机启动。

systemctl start httpd.service

systemctl enable httpd.service

(三)安装LimeSurvey

1、下载最新版LimeSurvey

首先要做的是去LimeSurvey的下载页面,查看最新的稳定版本的LimeSurvey CE的下载链接,并使用wget命令下载。

LimeSurvey下载页面:https://community.limesurvey.org/downloads/

wget https://download.limesurvey.org/latest-stable-release/limesurvey5.3.32+220817.zip #加粗文字可换为最新的下载链接

将LimeSurvey存档解压缩到服务器上的文档根目录。

unzip limesurvey5.3.32+220817.zip #加粗文字需更换为下载的实际文件名

如果提示以下内容,说明未安装uzip。

-bash: uzip: command not found

安装uzip。

yum install unzip

移动limesurvey文件夹。

mv limesurvey /var/www/html/

更改文件夹权限。

chown apache:apache -R /var/www/html/limesurvey/

2、配置Apache Web服务器

为您的LimeSurvey网站创建Apache虚拟主机。首先使用文本编辑器创建"/etc/httpd/conf.d/vhosts.conf"文件。

vi /etc/httpd/conf.d/vhosts.conf

输入以下内容:

IncludeOptional vhosts.d/*.conf

保存并关闭文件。接下来,创建虚拟主机。

mkdir /etc/httpd/vhosts.d/

vi /etc/httpd/vhosts.d/yourdomain.com.conf #“yourdomain.com”更换为您的域名

输入以下内容:

<VirtualHost *:80>

ServerAdmin webmaster@yourdomain.com

DocumentRoot /var/www/html/limesurvey/

ServerName www.yourdomain.com #“www.yourdomain.com”更换为您的域名

ErrorLog /var/log/httpd/www.yourdomain.com -error_log #“www.yourdomain.com”更换为您的域名

CustomLog /var/log/httpd/www.yourdomain.com -access_log combined #“www.yourdomain.com”更换为您的域名


<Directory /var/www/html/limesurvey/>

DirectoryIndex index.html index.php

Options FollowSymLinks

AllowOverride All

Require all granted

</Directory>

</VirtualHost>

保存并关闭文件。重新启动apache服务以使更改生效:

systemctl restart httpd.service

3、安装LimeSurvey

在浏览器中输入您的域名或者IP地址,开始安装LimeSurvey。

首选语言选择为中文,点击“开始安装”首选语言选择为中文,点击“开始安装”

点击“我接受“点击“我接受“

点击“下一页”点击“下一页”

数据库用户为“root”,数据库密码为您设置的root密码,数据库名为“limesurvey_db”数据库用户为“root”,数据库密码为您设置的root密码,数据库名为“limesurvey_db”

点击“填充数据库“点击“填充数据库“

设置“管理员登录名”、“管理员登录密码”,默认语言选中文,点击“下一页”设置“管理员登录名”、“管理员登录密码”,默认语言选中文,点击“下一页”

至此完成全部安装,点击“管理”进入管理页面至此完成全部安装,点击“管理”进入管理页面

管理页面管理页面

4、可能会出现的问题

安装到第3步,有可能会报错,无法继续安装,如图所示:

session.save_path: /var/lib/php/sessionsession.save_path: /var/lib/php/session

需要修改php.ini及php.conf两个文件:

vi /etc/php.ini

找到session.save_path,删除前面的注释符“;”,路径改为“/tmp”,如图所示:

从零开始,在CentOS 7上部署安装LimeSurvey

vi /etc/httpd/conf.d/php.conf

找到session.save_path,路径改为“/tmp”,如图所示:

从零开始,在CentOS 7上部署安装LimeSurvey

保存并关闭文件。重新启动apache服务以使更改生效:

systemctl restart httpd.service

在浏览器中输入您的域名或者IP地址,重新开始安装LimeSurvey。(重要)

如果还是报错,可能需要使用“reboot”命令重启系统后重试。

总结

第一次发文,难免有疏漏之处,希望大家多批评指正。希望能对学习研究的朋友有所帮助。

作者声明本文无利益相关,欢迎值友理性交流,和谐讨论~

展开 收起
9评论

  • 精彩
  • 最新
  • 我还以为我上的是CSDN…

    校验提示文案

    提交
    哈哈哈,马上发到CSDN

    校验提示文案

    提交
    收起所有回复
  • 谢谢分享~DOCKER装更方便

    校验提示文案

    提交
    是的,docker有封装好的,只是版本有些老

    校验提示文案

    提交
    收起所有回复
  • 怎么使用呢?感觉好复杂的逻辑

    校验提示文案

    提交
    如果只是简单的调查问卷,并不复杂。官网有教程。

    校验提示文案

    提交
    收起所有回复
  • 谢谢分享!

    校验提示文案

    提交
  • 学习到了,之前对这个没有了解!!! [ok了]

    校验提示文案

    提交
  • 建议再多截些limesurvey的界面,就会更有吸引力!

    校验提示文案

    提交
提示信息

取消
确认
评论举报

相关文章推荐

更多精彩文章
更多精彩文章
挂件

虹銷-雨霽

Ta还没有介绍自己

关注 打赏
最新文章 热门文章
182
扫一下,分享更方便,购买更轻松