Xampp Wordpress



  • I installed WordPress on XAMPP. I get an error: “Error establishing a database connection”. As far as I know, “The ‘Error establishing a database connection’ issue can be caused by incorrect database information in your WordPress settings, corrupt database, or an irresponsive database server.” (https://www.wpbeginner.com/wp-tutorials/how-to-fix-the-error-establishing-a-database-connection-in-wordpress/)

    In wp-config.php I have:
    define(‘DB_NAME’, ‘wordpress’);
    /** MySQL database username */
    define(‘DB_USER’, ‘root’);
    /** MySQL database password */
    define(‘DB_PASSWORD’, ”);
    /** MySQL hostname */
    define(‘DB_HOST’, ‘localhost’);

    PhpMyAdmin starts up without any problem. The database is there and is called ‘wordpress’. config.inc.php file contains the following data:
    $cfg[‘Servers’][$i][‘user’] = ‘root’;
    $cfg[‘Servers’][$i][‘password’] = ”;
    $cfg[‘Servers’][$i][‘host’] = ‘127.0.0.1’;

    So the database login credentials are correct, right? If yes, what else should I check?

    • This topic was modified 5 months, 2 weeks ago by . Reason: moved to 'localhost installs'

XAMPP is an acronym for cross (X) platform, Apache, MySQL, Pearl, and PHP. In the above, ‘Apache’ is the webserver software, while ‘PHP’ is a programming language and ‘MySQL’ is a database management software. It would be a daunting task for any beginner to install each software individually to make WordPress run.

  • Hi there,

    Looking at the wp-config.php snippet you provided, it looks like you didn’t use a password or removed it to post it here. If you didn’t you a password please try the following. After define(‘DB_PASSWORD’, there is a ' instead of '. Please change this.

    IF you removed the password form the snippet, please double check the password in the wp-config.php. This may sound redundant, but I have seen it happen before that a typo slipped in.

    I hope this helps.

    Regards,
    Arno

    If this is a Windows-based system, you should never use localhost for the MySQL hostname in a PHP application. Your snippet from phpMyAdmin provides the answer: use 127.0.0.1 for the hostname.

    Also make sure your Windows firewall isn’t blocking port 3306 because it will be used by MySQL.

    If that’s the case, then you will need this for the hostname:

    define(‘DB_HOST’, ‘127.0.0.1:3307’);

    Your firewall should be fine since phpMyAdmin is successfully accessing MySQL on port 3307.

This simple tutorial explains how to run WordPress on XAMPP (Apache, MariaDB & PHP) locally on Ubuntu GNU/Linux 64 bit. You can apply this tutorial for Mint, elementary, BlankOn, or any other GNU/Linux distro. However, if you have 32 bit computer, you cannot use XAMPP. The most important step here is number 4 which is doing chown over 'wordpress' directory for Apache's user account. Finally, I hope this will be easy for all beginners. Happy learning!
  • How to Install XAMPP, Ready for WordPress. XAMPP is available on all three desktop operating systems. However, in my experience XAMPP is the easiest to use on Windows, and for that reason this article will focus on Windows. In Linux I feel it’s easier to manually install WordPress directly onto the operating system.
  • Because it's instant. If you need to merely learning PHP/MySQL locally, XAMPP is very suitable. However, XAMPP is not the only solution as you can install Apache & MariaBD manually. Download WordPress Software The software, WordPress, is actually a collection of PHP source code that integrated to form a website management system (WMS).
Subscribe to UbuntuBuzz Telegram Channel to get article updates directly.

Why XAMPP?


Because it's instant. If you need to merely learning PHP/MySQL locally, XAMPP is very suitable. However, XAMPP is not the only solution as you can install Apache & MariaBD manually.

Download WordPress Software


The software, WordPress, is actually a collection of PHP source code that integrated to form a website management system (WMS). You should not confuse WordPress (the software) with WordPress.com (the web service by Automattic). You can download WordPress as a package (either on ZIP or TAR) from WordPress Software Project website https://wordpress.org/download. At the time I write this article (June 22nd 2017) it reached version 4.8.

1. Install XAMPP


Follow this XAMPP Installation Tutorial. Please be aware this is only for 64bit computers.

2. Extract WordPress Package


Place the WordPress package on your $HOME. Right-click > extract it.
This should give you a 'wordpress' named folder there.

3. Move WordPress Directory


Open your Terminal and perform this command:
sudo mv wordpress /opt/lampp/htdocs/

Now check the target directory and you should find /opt/lampp/htdocs/wordpress.

4. Change Directory Ownership


The most important thing now is changing ownership of the whole 'wordpress' directory to be owned by the user of XAMPP's web server.
So the first thing is to know the username of the web server. Run this command:
ps aux | grep httpd

and you should see at the most left column the username 'daemon'. This is the username your XAMPP used to run Apache Web Server (the /opt/lampp/bin/httpd).

Finally, do chown the 'wordpress' directory recursively so it owned by 'daemon' username:

Xampp Wordpress Bitnami


sudo chown -R daemon /opt/lampp/htdocs/wordpress/

5. Set XAMPP Security


Before going to local WordPress installation, set your phpMyAdmin and MySQL/MariaDB root passwords. For example, pma password='root' and MySQL password='root'. Run this command and do it:
sudo /opt/lampp/lampp security

6. Create Database


Xampp wordpress インストールNow, close Terminal and you can head to browser by typing http://localhost/phpmyadmin. Login with the password you've set by yourself at Step 5. Go to database page and create a new database with the name 'wordpress'.

7. Run WordPress Installation


The last step: now visit the address http://localhost/wordpress > go forward > fill the blanks with Database='wordpress'Wordpress; Username='root'; Password='root' just as examples you've followed before. See picture below.
When it works (because you've already set chown wordpress/ folder) you'll fill the website info as you wish. Determine username and password as you wish.

8. Login to WordPress


Once finished, now visit the address http://localhost/wordpress. You should see the home page of the WordPress site. To manage it, login to Dashboard at the address http://localhost/wordpress/wp-admin.

Xampp Wordpress Slow


This is the Dashboard inside of WordPress WMS:

Xampp Wordpress Download


It's all completed and have a good learning with WordPress!