CentOS7.2安装XAMPP

简洁配置步骤:

 

一、 下载XAMPP

使用以下命令进行下载: # wget https://www.apachefriends.org/xampp-files/5.6.24/xampp-linux-x64-5.6.24-1-installer.run

若wget命令不能执行请先执行:

#yum install wget -y

下载成功后,会在目录中看到名为:

[root@localhost ~]# ls
xampp-linux-x64-5.6.24-1-installer.run

二、 安装

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

[root@localhost ~]# chmod 777 xampp-linux-x64-5.6.24-1-installer.run

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

 [root@localhost ~]# ./xampp-linux-x64-5.6.24-1-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:Enter
----------------------------------------------------------------------------
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%
 ########################################
至此,安装步骤就已经完成了  启动xampp:

[root@localhost ~]# sudo /opt/lampp/lampp start

停止xampp: [root@localhost ~]# sudo /opt/lampp/lampp stop

卸载xampp: [root@localhost ~]# sudo /opt/lampp/lampp stop # rm -rf /opt/lampp

 

三、 让局域网均可访问

1. xampp的配置文件:/opt/lampp/etc/extra/httpd-xampp.conf中将以下内容屏蔽

<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">
#Require local
ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var

2. 如果按照以上修改后,还是不能访问,则可能是防火墙把80端口给干掉了,要么把防火墙关闭,要么配置一下80端口允许访问。

3./opt/lampp/etc/httpd.conf

<Directory />
    AllowOverride none
    Require all denied
</Directory>

改成如下

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>

四、 安装设置

在默认的安装过程中,xampp所有均是没有密码的,为了安全,我们应该为xampp设置密码。该如何操作呢?

# /opt/lampp/lampp security

  • 1

设置xampp的密码: 

XAMPP: Quick security check…  XAMPP: Your XAMPP pages are NOT secured by a password.  XAMPP: Do you want to set a password? [yes] yew  XAMPP: Do you want to set a password? [yes] yes  XAMPP: Password:  XAMPP: Password (again):

用户名默认是:xampp

设置phpMyAdmin的密码:

  XAMPP: The MySQL/phpMyAdmin user pma has no password set!!!  XAMPP: Do you want to set a password? [yes] yes  XAMPP: Password:  XAMPP: Password (again):  XAMPP: Setting new MySQL pma password.  XAMPP: Setting phpMyAdmin’s pma password to the new one.

设置mysql的root账户: 

XAMPP: MySQL has no root passwort set!!!  XAMPP: Do you want to set a password? [yes] yes  XAMPP: Write the password somewhere down to make sure you won’t forget it!!!  XAMPP: Password:  XAMPP: Password (again):  XAMPP: Setting new MySQL root password.  XAMPP: Change phpMyAdmin’s authentication method.

设置ftp密码: 

XAMPP: The FTP password for user ‘daemon’ is still set to ‘xampp’.  XAMPP: Do you want to change the password? [yes] yes  XAMPP: Password:  XAMPP: Password (again):

 

用命令sudo /opt/lampp/lampp start 启动xampp

[root@localhost lampp]# sudo /opt/lampp/lampp start
Starting XAMPP for Linux 5.6.24-1...
XAMPP: Starting Apache.../opt/lampp/share/xampp/xampplib: line 22: netstat: command not found
/opt/lampp/share/xampp/xampplib: line 22: netstat: command not found
ok.
XAMPP: Starting MySQL.../opt/lampp/share/xampp/xampplib: line 22: netstat: command not found
ok.
XAMPP: Starting ProFTPD.../opt/lampp/share/xampp/xampplib: line 22: netstat: command not found
ok.

         sudo /opt/lampp/lampp stop  停止xampp

         sudo /opt/lampp/lampp restart  重启xampp

 [root@localhost lampp]# sudo /opt/lampp/lampp restart
Restarting XAMPP for Linux 5.6.24-1...
XAMPP: Stopping Apache...ok.
XAMPP: Stopping MySQL...ok.
XAMPP: Stopping ProFTPD...ok.
XAMPP: Starting Apache.../opt/lampp/share/xampp/xampplib: line 22: netstat: command not found
/opt/lampp/share/xampp/xampplib: line 22: netstat: command not found
ok.
XAMPP: Starting MySQL.../opt/lampp/share/xampp/xampplib: line 22: netstat: command not found
ok.
XAMPP: Starting ProFTPD.../opt/lampp/share/xampp/xampplib: line 22: netstat: command not found
ok.

置开机自动启动xampp

sudo ln -s /opt/lampp/lampp /etc/init.d/lampp
sudo chkconfig --add lampp

 

修改配置文允许远程访问xampphttpd-xampp.conf

用命令 cd /opt/lampp/etc/extra进入目录,ls列出文件,找到httpd-xampp.conf

sudo vim httpd-xampp.conf

在底部找到

<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">
        Require local
        ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</LocationMatch>

修改为

<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">
       # Require local
       # ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var

      allow from all
</LocationMatch>

重启xampp sudo /opt/lampp/lampp restart

英文原文