CentOS 更新YUM源

[1] 首先备份/etc/yum.repos.d/CentOS-Base.repo

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

[2] 进入yum源配置文件所在文件夹

[root@localhost yum.repos.d]# cd /etc/yum.repos.d/

[3] 下载163/阿里云的yum源配置文件,放入/etc/yum.repos.d/(操作前请做好相应备份)

[root@localhost yum.repos.d]# wget
[root@localhost yum.repos.d]# wget

[4] 运行yum makecache生成缓存

[root@localhost yum.repos.d]# yum makecache
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Repository contrib is listed more than once in the configuration
base | 3.6 kB 00:00
extras | 3.4 kB 00:00
updates | 3.4 kB 00:00
(1/8): extras/7/x86_64/prestodelta | 77 kB 00:00
(2/8): extras/7/x86_64/other_db | 707 kB 00:05
(3/8): extras/7/x86_64/filelists_db | 466 kB 00:06
(4/8): updates/7/x86_64/prestodelta | 763 kB 00:02
(5/8): base/7/x86_64/other_db | 2.3 MB 00:11
(6/8): updates/7/x86_64/filelists_db | 4.7 MB 00:12
(7/8): base/7/x86_64/filelists_db | 6.2 MB 00:22
(8/8): updates/7/x86_64/other_db | 68 MB 02:13
Loading mirror speeds from cached hostfile
Metadata Cache Created

[5] 更新系统

[root@localhost yum.repos.d]# yum -y update

[6] 安装vim编辑器

[root@localhost ~]# yum -y install vim*

XAMPP linux 官方说明


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.


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 
# ./ 


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.


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/ - 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.


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">

  • In the next line after "</Directory>" paste this:
<Directory "/yourDirectory/">
    Options Indexes FollowSymLinks ExecCGI Includes
    AllowOverride All
    Require all granted
  • 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
  • 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


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

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


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


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 or ::1 but not with

CentOS network-script


CentOS的ifconfig, route以及ip指令的实战应用

CentOS安装后ifconfig 无法显示网卡

CentOS的ifconfig, route以及ip指令的实战应用

ifconfig: command not found

CentOS 6.2下ifconfig输出网口和ip


Apache: You don't have permission to access the requested directory


I usually get this error when creating a new virtual site on Apache:


"You don't have permission to access the requested directory"


That usually is because of Deny from all or the no existence of the Allow from all directive in the folder I'm working on.


Suppose you have this <VirtualHost> configuration:


CentOS hosts

[root@localhost extra]# sudo vim /etc/hosts
[root@localhost extra]#   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6