WinNMP - Advanced usage and Debugging

What to do if a Local Virtual Server cannot be reached

After adding a new project with a local test domain name like myprojectname.test you should test in the browser if it is reachable by browsing to http://myprojectname.test. If it is unreachable you should try the following:

  • open Hosts File Editor, and manually add myprojectname.test if missing
  • apply changes in Hosts File Editor: CLICK SAVE - (CTRL-S) and File>Exit (ALT-F4)
  • close your browser and repoen it
  • your hosts file c:\Windows\System32\drivers\etc\hosts could be corrupted if you manually edited it and saved it with non-windows newlines \r\n

How to Debug Configuration Files:

After changing the configuration files, one server like nginx might refuse start. In order to find out the reason, you need to Check Configuration Syntax:

  • In the WinNMP Manager window, use Reload Nginx if Configuration Syntax is ok or Restart MariaDb if Configuration Syntax is ok buttons to see the start up errors for Nginx and MySql
  • For PHP, if there are any startup errors, they will be shown as alert messages.
  • Also check the server logs in WinNMP\log
  • To see the commands used to start each service, look in log\winnmp.log
  • If nothing works, delete that configuration file, or from WinNMP\conf nginx.conf, mysql.ini, php.ini , kill all servers and restart WinNMP.exe. The Server Manager will copy the default configuration files to WinNMP\conf.

Dealing with PHP-CGI crashes:

If Nginx respondes with 502 Bad Gateway and you notice a lot of Detected CRASHED process 900x in log\winnmp.log it means that PHP-CGI stops or crashes and WinNMP will try to restart it.

Usually the reason is conflicting php extensions or a stack overflow generated by your php code. The real reason is very hard to find, as php-cgi will not output anything to STDERR or log\php_error.log.

Starting WinNMP with winnmp.exe --debug will enable capturing STDOUT and STDERR in log\php_cgi_900x.txt but usually php crashes before writing to this files, and they will remain empty.

You could also start php-cgi in visible windows by pressing Kill php in WinNMP and then running bin\PHP\phpStartVisible.bat

You could try disabling some or all php extensions in conf\php.ini or you could remove everything from php.ini except for the first few lines, in order to start with default values. Then you need to restart PHP.

Delete conf\php.ini and restart WinNMP in order to revert to the basic php.ini settings.

How to Copy/Clone/Sync WinNMP stack to a new machine:

WinNMP is portable. You can safely copy or move the WinNMP stack without loosing any data, projects, databases or settings. You can even copy and run it from a flash drive.

If you move WinNMP stack to a new machine without running the installer, PHP or WinNMP Manager might refuse to start, because they require Visual C++ Redistributable for Visual Studio. You should install it manually.

Syncing your work from C:\MyWork\WinNMP on Machine1 to D:\WinNMP on Machine2 should be done by running the installer once on Macine2 (and choosing D:\WinNMP as destination) then overwriting D:\WinNMP each time you need to sync your work.

If MariaDb Crashes after upgrade

If you upgrade WinNMP and you find that MariaDB dose not start, try the following:

  • Open a command prompt and enter CD c:\WinNMP\bin\MariaDB\bin

  • Check if the configuration file syntax is correct by pressing the corresponding button in WinNMP Manager

  • Check c:\WinNMP\log\mysql.log for any clues

  • If you find a line like [ERROR] Table 'mysql.user' doesn't exist , in order to recreate the table, enter in the command prompt window:

    mysql_install_db -d c:\WinNMP\data 
  • If your access to the database is denied, kill mysqld and try to repair the privilege tables:

    mysqld.exe --defaults-file=c:\WinNMP\conf\mysql.ini --skip-grant-tables
    mysqlcheck.exe -u root --repair --force --silent --use-frm --databases mysql
    mysql_upgrade.exe -u root --force

If your access is still denied (root with no password), you could trigger the execution of the commands above plus root password reset by deleting the file c:\WinNMP\bin\mysql.bat and restartig WinNMP

  • After you manage to start MariaDB, you could check the integrity of your tables by running

    mysqlcheck.exe -u root --all-databases --auto-repair`
  • If there are still some InnoDB crashed tables, you could try to recover your data:

    Set temprarily innodb_force_recovery = 1 in conf\mysql.ini under [mysqld], start MariaDB, dump all data data with mysqldump -u root --opt --default-character-set=utf8 --triggers --routines --all-databases > c:\WinNMP\backup\dump.sql, stop MariaDB, remove all data del /f /s /q c:\WinNMP\data\*, execute mysql_install_db.exe --datadir=c:\WinNMP\data then remove innodb_force_recovery from conf\mysql.ini, start MariaDB, then import your data back.

  • Or you could delete c:\WinNMP\data if you don't need to recover any data, and execute the latest installer

Also, don't forget to backup your databases regulary..

How to set / change / reset mysql(mariadb) root password on WinNMP:

Don`t do it! WinNMP needs to perform some maintainance tasks on MariaDB and it needs root access without password. This is no more of a security risk than having a password for WinNMP stored somewhere on the disk or registry.

How to Install Extras:

Let`s say you want to use Nginx 1.2.x instead of the currently installed version, or PHP 5.3.x