CentOS操作系统安装XAMPP教程(及无法正常启动Apache解决!)

一、 下载XAMPP

可疑直接使用wget从xampp的官网上下载。方法就是输入一行命令:

[opc@oracle-centos ~]$ wget https://www.apachefriends.org/xampp-files/7.4.26/xampp-linux-x64-7.4.26-0-installer.run
wget从xampp的官网上下载
wget从xampp的官网上下载

以上命令行直接下载XAMPP 7.4版本(也就是PHP 7.4版本),如果下载其他的版本可以更换链接“ https://www.apachefriends.org/xampp-files/7.4.26/xampp-linux-x64-7.4.26-0-installer.run ”,链接去官网直接复制要下载XAMPP版本地址的链接即可,官方下载链接https://www.apachefriends.org/download.html

例如我们要下载7.3版本,即可到下载页面右击复制下载地址:https://www.apachefriends.org/xampp-files/7.3.33/xampp-linux-x64-7.3.33-0-installer.run

复制xampp下载链接

下载成功后,会在目录中看到名为: xampp-linux-x64-7.4.26-0-installer.run 的文件。

下载的xampp
下载的xampp

二、 安装XAMPP

安装前,需要先给xampp安装包可执行的权限

chmod 777 xampp-linux-x64-7.4.26-0-installer.run

./xampp-linux-x64-7.4.26-0-installer.run

运行 ./xampp-linux-x64-7.4.26-0-installer.run  进行安装操作。根据提示进行选择需要安装的部分即可:

[root@oracle-centos opt]# chmod 777 xampp-linux-x64-7.4.26-0-installer.run
[root@oracle-centos opt]# ./xampp-linux-x64-7.4.26-0-installer.run
----------------------------------------------------------------------------
Welcome to the XAMPP Setup Wizard.

----------------------------------------------------------------------------
Select the components you want to install; clear the components you do not want 
to install. Click Next when you are ready to continue.

XAMPP Core Files : Y (Cannot be edited)

XAMPP Developer Files [Y/n] :y

Is the selection above correct? [Y/n]: y

----------------------------------------------------------------------------
Installation Directory

XAMPP will be installed to /opt/lampp
Press [Enter] to continue:

----------------------------------------------------------------------------
Setup is now ready to begin installing XAMPP on your computer.

Do you want to continue? [Y/n]: y

----------------------------------------------------------------------------
Please wait while Setup installs XAMPP on your computer.

 Installing
 0% ______________ 50% ______________ 100%
 #########################################

----------------------------------------------------------------------------
Setup has finished installing XAMPP on your computer.
命令行安装xampp
命令行安装xampp

启动xampp:/opt/lampp/lampp start

停止xampp: /opt/lampp/lampp stop

重新启动xampp:/opt/lampp/lampp restart

安装基本完成!

三、报错

问题: XAMPP: Starting Apache…fail.

[root@oracle-centos opt]# /opt/lampp/lampp start
XAMPP:  SELinux is activated. Making XAMPP fit SELinux...
chcon: cannot access '/opt/lampp/lib/mysql/*.so': No such file or directory
Starting XAMPP for Linux 7.4.26-0...
XAMPP: Starting Apache...fail.
httpd: Syntax error on line 522 of /opt/lampp/etc/httpd.conf: Syntax error on line 13 of /opt/lampp/etc/extra/httpd-xampp.conf: Cannot load modules/mod_perl.so into server: libnsl.so.1: cannot open shared object file: No such file or directory
XAMPP: Starting MySQL...ok.
XAMPP: Starting ProFTPD...ok.

解决方法:

yum install libnsl.x86_64

解决后使用restart命令重新启动XAMPP

[root@oracle-centos opt]# /opt/lampp/lampp start
Starting XAMPP for Linux 7.4.26-0...
XAMPP: Starting Apache...ok.
XAMPP: Starting MySQL...ok.
XAMPP: Starting ProFTPD...already running.

解决方法,参考网友的一篇文章,具体报错及问题解决分析,可以参考:https://www.jianshu.com/p/494c005d3a7d

四、访问http://<your-ip>/dashboard/

目前为止,你到浏览器访问xampp页面还是不可以的。

五、关闭防火墙

使用命令行关闭防火墙,命令为:

service firewalld stop

查看firewall的状态

firewall-cmd --state

开启、重启、关闭、firewalld.service服务

# 开启
service firewalld start
# 重启
service firewalld restart
# 关闭
service firewalld stop

参考链接:https://www.cnblogs.com/xxoome/p/7115614.html

六、完成

centos安装xampp完成
centos安装xampp完成
滚动至顶部