在CentOS安裝XAMPP

在CentOS安裝XAMPP

之前曾分享安裝XAMPP在Windows系統上,今天來分享裝在Linux系統!
Linux又分好幾套,大眾的有:CentOS和Ubuntu這兩套,哪個比較適合當web server呢?可以看看這篇文章的比較。


一個Server穩定是首要的,所以我選擇CentOS!
下載最新版的CentOS7:https://www.centos.org/download/

安裝可參考:
http://linux.vbird.org/linux_basic/0157installcentos7.php
https://blog.gtwang.org/linux/centos-7-installation-tutorial/

安裝XRDP讓Windows用遠端桌面連線登入

Step 1. Install EPEL and nux Desktop repository rpms by automatic. (recommended)

1
# rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm

Step 2. The following command to install xrdp, and you will get the following output, make sure you are getting package from the newly created repository.

1
# yum -y install xrdp tigervnc-server

Step 3. Once it is installed, lets start the xrdp service.

1
# systemctl start xrdp.service

Step 4. The xrdp will listen on 3389, lets confirm this by issuing following command.

1
# netstat -antup | grep xrdp

Step 5. By default, services wont auto start after system reboot, issue the following command to enable the service at system start up.

1
# systemctl enable xrdp.service

Step 6. Next is to create iptables rule to allow rdp connection from the external machines, following command will add the exception for xrdp port (3389).

1
# firewall-cmd --permanent --zone=public --add-port=3389/tcp
1
# firewall-cmd --reload

Step 7. Now take rdp from any windows machine using Remote Desktop Connection, enter ip address of Linux server in computer field and click on connect.

接下來用putty遠端連線操作

開始安裝XAMPP

選擇你要安裝的XAMPP版本:https://sourceforge.net/projects/xampp/files/XAMPP%20Linux/

1
wget https://sourceforge.net/projects/xampp/files/XAMPP%20Linux/5.6.30/xampp-linux-x64-5.6.30-0-installer.run
1
chmod 755 xampp-linux-x64-5.6.30-0-installer.run
1
sudo ./xampp-linux-x64-5.6.30-0-installer.run

在CentOS安裝XAMPP

XAMPP安裝完成後,可以在/opt/lampp下看到安裝的檔案

啟動XAMPP

1
sudo /opt/lampp/lampp start

停止XAMPP

1
sudo /opt/lampp/lampp stop

查看狀態

1
sudo /opt/lampp/lampp status

設定XAMPP開機自動啟動

vi /etc/rc.d/rc.local

touch /var/lock/subsys/local
/opt/lampp/lampp start

設定密碼

1
/opt/lampp/lampp security

XAMPP 頁面密碼
phpMyAdmin 帳號pma 的密碼
MySQL 帳號root 的密碼
FTP 帳號daemon 的密碼

設定防火牆

1
firewall-cmd --permanent --zone=public --add-port=80/tcp
1
firewall-cmd --permanent --zone=public --add-port=21/tcp
1
firewall-cmd --permanent --add-service=ftp
1
firewall-cmd --reload

設定Ftp,上傳檔案

可編輯/opt/lampp/etc/proftpd.conf

設定目錄或帳號

上傳wordpress檔案,我這邊路徑是/opt/lampp/htdocs/web/wordpress

設定網站目錄

編輯/opt/lampp/etc/httpd.conf
找到
#Include etc/extra/httpd-vhosts.conf
改成
Include etc/extra/httpd-vhosts.conf

編輯/opt/lampp/etc/extra/httpd-vhosts.conf

添加

<VirtualHost *:80>
    ServerAdmin admin@yourname.com
    DocumentRoot "/opt/lampp/htdocs"
    ServerName 127.0.0.1
</VirtualHost>

在CentOS安裝XAMPP
在CentOS安裝XAMPP

<VirtualHost *:80>
ServerAdmin admin@yourname.com
DocumentRoot "/opt/lampp/htdocs/web/wordpress"
ServerName wordpress.yourname.com
ErrorLog "logs/wordpress.yourname.com-error_log"
CustomLog "logs/wordpress.yourname.com-access_log" common
</VirtualHost>

在CentOS安裝XAMPP

建立資料庫

開啟瀏覽器,htp://127.0.0.1/phpmyadmin,建立資料庫

建立WordPress

開啟瀏覽器,htp://wordpress.yourname.com

在CentOS安裝XAMPP


建立網站過程我遇到這個錯誤 this version of PCRE is compiled without UTF support at offset 0

查詢指令 /opt/lampp/bin/pcretest -C

PCRE version 8.37 2015-04-28
Compiled with
8-bit support
No UTF-8 support
No Unicode properties support
No just-in-time compiler support
Newline sequence is LF
\R matches all Unicode newlines
Internal link size = 2
POSIX malloc threshold = 10
Parentheses nest limit = 250
Default match limit = 10000000
Default recursion depth limit = 10000000
Match recursion uses stack

顯示不支援UTF-8...

解決方式:

下載PCRE:https://sourceforge.net/projects/pcre/files/pcre/

解壓縮後,在pcre資料夾執行

sudo ./configure --prefix=/opt/lampp --enable-utf8 --enable-unicode-properties

sudo make

sudo make install

若在安裝過程中有出現錯誤,可能少了gcc和c++元件

yum install -y gcc gcc-c++

重啟XAMPP,安裝成功

PCRE version 8.40 2017-01-11
Compiled with
8-bit support
UTF-8 support
Unicode properties support
No just-in-time compiler support
Newline sequence is LF
\R matches all Unicode newlines
Internal link size = 2
POSIX malloc threshold = 10
Parentheses nest limit = 250
Default match limit = 10000000
Default recursion depth limit = 10000000
Match recursion uses stack

 

參考:

https://www.openfoundry.org/tw/enterprise-application/9349-centos7

http://stackoverflow.com/questions/35801425/xampp-mysql-this-version-of-pcre-is-compiled-without-utf-support-at-offset-0

wordpress建站該選擇Linux主機還是Windows主機?
https://www.xgllseo.com/?p=2254

關於作者 多力哥
在CentOS安裝XAMPP
影像創作攝影師/網頁動畫設計師/系統網路工程師/水草研究生
景文科大畢業後,我成為一名網站動畫設計師,並副修MIS電腦資訊管理。2004年,我開始接觸單眼相機,並在2008年正式成為一名接案攝影師,目前使用Canon系統進行拍攝。2016年,我愛上了美麗的水草缸,這讓我的生活多了另一層次的放鬆。每天在電腦前修圖時,能欣賞紅吱吱、綠油油的水草,彷彿多了一份平靜與愉悅。攝影與水草讓我的生活充滿了藝術與自然的交融。
連絡信箱:hello@hahasmile.com (歡迎合作提案)
DORIGO IMAGE 攝影工作室:https://dorigo-image.com
如果你喜歡我的內容,可以用行動贊助我一杯咖啡☕,支持我持續創作,也讓這個網站可以繼續營運下去喔!

若您喜歡這篇文章,歡迎按讚分享喔!
0 回復

發表評論

想要留言嗎?
歡迎歡迎!

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *