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

英文原文


Xampp

 
 

XAMPP is an easy to install Apache distribution containing MySQL, PHP and Perl. It contains: Apache, MySQL, PHP & PEAR, Perl, ProFTPD, phpMyAdmin, OpenSSL, GD, Freetype2, libjpeg, libpng, gdbm, zlib, expat, Sablotron, libxml, Ming, Webalizer, pdf class, ncurses, mod_perl, FreeTDS, gettext, mcrypt, mhash, eAccelerator, SQLite and IMAP C-Client.

Installation

Using AUR package

Install xamppAUR.

Manual Installation

Download the installer from the website.

The downloaded file is an installer script. Make it executable and run it by typing:

# chmod +x xampp-linux-version-installer.run 
# ./xampp-linux-version-installer.run 

Removal

Be sure to stop all lampp services.

# /opt/lampp/lampp stop

All the files needed by Xampp to be installed are located in the previous /opt/lampp folder. So, to uninstall Xampp:

# rm -rf /opt/lampp
Note: If you created symlinks, you may need to destroy them too.

Configuration

Setting the individual parts of XAMPP can by made by editing following files:

/opt/lampp/etc/httpd.conf - Apache configuration. For example you can change folder with web page's source files.

/opt/lampp/etc/php.ini - PHP configuration.

/opt/lampp/phpmyadmin/config.inc.php - phpMyAdmin configuration.

/opt/lampp/etc/proftpd.conf - proFTP configuration.

/opt/lampp/etc/my.cnf - MySQL configuration.

If you would like to set up security of server, you can do it simply by this command:

# /opt/lampp/lampp security

You will be asked step by step to choose passwords for web page's access, user "pma" for phpMyAdmin, user "root" for MySQL and user "nobody" for proFTP.

Usage

Use the following commands to control XAMPP:
# /opt/lampp/lampp start,stop,restart

If you get this error when you start it:

Starting XAMPP for Linux 1.7.7...
/opt/lampp/lampp: line 21: netstat: command not found
/opt/lampp/lampp: line 21: netstat: command not found
XAMPP: Starting Apache with SSL (and PHP5)...
/opt/lampp/lampp: line 241: /bin/hostname: No such file or directory
/opt/lampp/lampp: line 21: netstat: command not found
XAMPP: Starting MySQL...
/opt/lampp/bin/mysql.server: line 263: hostname: command not found
/opt/lampp/lampp: line 21: netstat: command not found
XAMPP: Starting ProFTPD...
XAMPP for Linux started.

Install net-tools and inetutils from the official repositories.

Hosting files outside the htdocs directory

The document root (web root) directory is located at /opt/lampp/htdocs/. All files placed in this directory will be processed by the web server.

To host other files on your system with XAMPP, you can configure an alias with apache.

  • Edit apache's httpd.conf with your favorite editor.
# nano /opt/lampp/etc/httpd.conf
  • Find "DocumentRoot", you will see something like:
DocumentRoot "/opt/lampp/htdocs"
<Directory "/opt/lampp/htdocs">
    ...    
    ...

</Directory>
  • In the next line after "</Directory>" paste this:
<Directory "/yourDirectory/">
    Options Indexes FollowSymLinks ExecCGI Includes
    AllowOverride All
    Require all granted
</Directory>
  • Next find the "<IfModule alias_module>":
<IfModule alias_module>

    #
    # Redirect: Allows you to tell clients about documents that used to 
    # exist in your server's namespace, but do not anymore. The client 
    # will make a new request for the document at its new location.
    # Example:
    # Redirect permanent /foo http://www.example.com/bar
  ...
</IfModule>
  • And before the "</IfModule>" paste this:
Alias /yourAlias /yourDirectory/
  • Now do not forget to restart Apache:
# /opt/lampp/lampp restart

This will allow you to host files from your home directory (or any other directory) with XAMPP.

In the above example, you can access the files by pointing your web browser to localhost/yourAlias.

Debugging and profiling with Xdebug and Xampp

For detailed instructions go here.

You must first download the Xampp Development Tools from the same download page here.

Extract this into your Xampp directory:

# tar xvfz xampp-linux-devel-x.x.x.tar.gz -C /opt

You should be able to successfully run

/opt/lampp/bin/phpize

in your xdebug folder.

PhpMyAdmin 403 Access Forbidden

If your http://localhost/phpmyadmin returns "403 Access Forbidden", you need to edit the following settings in /opt/lampp/etc/extra/httpd-xampp.conf:

<Directory "/opt/lampp/phpmyadmin">
	AllowOverride AuthConfig Limit
	#Order allow,deny
	#Allow from all
	Require all granted
</Directory>

Local test server security

Apache and MySQL can be configured so that they only listen to requests from your own computer. For most test systems this is fine and it greatly reduces the risk because the services are not reachable from the Internet.

Before you start XAMPP for the first time find and edit these files:

For Apache edit the files xampp\apache\conf\httpd.conf and xampp\apache\conf\extra\httpd-ssl.conf. Look for lines starting with "Listen" such as

Listen 80

and replace them with

Listen 127.0.0.1:80

For MySQL open the file xampp\mysql\bin\my.cnf find the section "[mysqld]" and add this line

bind-address=localhost

After starting the services, verify the result by going to a command window and start and execute:

netstat -a -n

For the entries marked as LISTEN in the last column, look at the Listen column. It should always start with 127.0.0.1 or ::1 but not with 0.0.0.0.