Архив метки: Apache

Installing and configuring XAMPP

XAMPP is an easy-to-install bundle for Windows, Linux or Mac, that contains PHP, Apache, MySQL (MariaDB) and phpMyAdmin. Add Git and Composer and you are set to start local PHP development.

But actually, XAMPP requires some additional configuring if you want to make things working right. This mini-guide explains it step-by-step.

Installation

Change MySQL root password

By default, MySQL user name is root with an empty password. An empty password is not very secure, and there can be situations when an empty password doesn’t work and some actual password is required. So let’s change it to password, for example.

  • Open XAMPP Control Panel.
  • Open XAMPP shell (one of the buttons on the right side).
  • Execute command mysqladmin.exe -u root password.

Change password in phpMyAdmin

After changing the MySQL password we need to change it in phpMyAdmin config too.

  • Open file \xampp\phpMyAdmin\config.inc.php.
  • Add password to line: $cfg['Servers'][$i]['password'] = 'password';.

Correct the timezones

In some cases, you may end up with timezones out-of-sync between PHP, Apache and MySQL. Let’s sync them to Europe/Moscow timezone, for example.

Set correct timezone for PHP

  • Open \xampp\php\php.ini.
  • Add line date.timezone = "Europe/Moscow".

Set correct timezone for Apache

  • Open \xampp\apache\conf\httpd.conf.
  • Add line SetEnv TZ Europe/Moscow.

Set correct timezone for MySQL

  • Open \xampp\mysql\bin\my.ini.
  • Add line default-time-zone = "Europe/Moscow".

Ready, steady, go!

We’ve finished configuring XAMPP, grats! Now let’s start the servers.

  • Open XAMPP Control Panel.
  • Stop Apache and MySQL.
  • Start Apache.
  • Start MySQL.

If you open http://localhost in your browser, you should be redirected to http://localhost/dashboard and see the XAMPP welcome page.

To open phpMyAdmin, press MySQL‘s Admin button in XAMPP Control Panel or open http://localhost/phpmyadmin directly.

DB connection settings

To connect to DB from your code (PHP in this case), use these settings:

That’s it! Now you are ready to code!