作者:虹銷-雨霽
前言
因工作需要,近期一直在研究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 或更高版本。
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”更換為您的域名
輸入以下內容:
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”更換為您的域名
DirectoryIndex index。html index。php
Options FollowSymLinks
AllowOverride All
Require all granted
儲存並關閉檔案。重新啟動apache服務以使更改生效:
systemctl restart httpd。service
3、安裝LimeSurvey
在瀏覽器中輸入您的域名或者IP地址,開始安裝LimeSurvey。
4、可能會出現的問題
安裝到第3步,有可能會報錯,無法繼續安裝,如圖所示:
需要修改php。ini及php。conf兩個檔案:
vi /etc/php。ini
找到session。save_path,刪除前面的註釋符“;”,路徑改為“/tmp”,如圖所示:
vi /etc/httpd/conf。d/php。conf
找到session。save_path,路徑改為“/tmp”,如圖所示:
儲存並關閉檔案。重新啟動apache服務以使更改生效:
systemctl restart httpd。service
在瀏覽器中輸入您的域名或者IP地址,重新開始安裝LimeSurvey。(重要)
如果還是報錯,可能需要使用“reboot”命令重啟系統後重試。
總結
第一次發文,難免有疏漏之處,希望大家多批評指正。希望能對學習研究的朋友有所幫助。