Gallery2:Installation on a Windows Server with Apache - Gallery Codex
Personal tools

Gallery2:Installation on a Windows Server with Apache

From Gallery Codex

Note: You will probably need administrative access to the computer you're installing on. If you are migrating from Gallery1, please read the Migration Guide.

Note: This guide curently assumes Apache2, PHP5, and MySQL 4.1. If you have experience with different versions, please update this guide.

The paths and URLs in this guide are examples. Be sure to replace them with the paths and URLs specific to your installation.


Installing the components

  1. Download the required components (see the installation requirements). You can get:
  2. Install each package (unzip or run the installer).
    • MySQL notes: During the installation, DO create a secure password for the root MySQL user. Do allow it to listen for connections on the default port, but for security only allow connections from "localhost".


Getting PHP and MySQL to work with Apache2

Add PHP support to Apache2

  1. In Apache's "httpd.conf" add these lines (adjust your php path accordingly):
    LoadModule php5_module c:/php/php5apache2.dll
    AddType application/x-httpd-php .php

  2. Make sure that the "php.ini" file is located in the system path.
    • The quick and easy method is to put "php.ini" in the "C:\Windows" folder.
    • With Apache2, you can add the PHPIniDir directive to "http.conf"
      PHPIniDir "C:/apache/php"
    • The recommended method is to add the php directory (ex. "c:\php\") to your path.
    • You can see the current path in a command window (type "echo %PATH%") and can change it in the "System" control panel ("Advanced" tab -> "Environment Variables" button -> "System variables" box -> "Path" variable). You should restart your computer after changing your PATH, otherwise Apache may not see the change, even after stopping and starting the service.

  3. Test to see if php is working using phpinfo(). Create a test php file in your apache "htdocs" directory with the line:
    <?php phpinfo(); ?>
    • If your "Configuration File (php.ini) Path" section is "C:\WINDOWS\" or anything that doesn't end in "php.ini", it means that your "php.ini" file isn't in the system path and PHP can't find it. For example:

      Bad: "C:\WINDOWS\"
      Good: "C:\WINDOWS\php.ini"


Add MySQL support to PHP

  1. Check the phpinfo() output and see if there is a "mysql" section. If so, great! If not check the following:
    1. The file "libmysql.dll" must be in your system path. You can update your system path (see above) or put it in your "C:\Windows" directory.
    2. The the following line needs to be added to "php.ini":
      extension=php_mysql.dll

      This is strange since the "php.ini" file states: "Note that MySQL and ODBC support is now built in, so no dll is needed for it". This appears to be false. If you do not put the line in your php.ini, mysql support will NOT be present.


Troubleshooting

If you get the "You must have the MySQL PHP module installed" error when trying to add your database.

Make sure that "libmysql.dll" is in your system path. Make sure that "extension=php_mysql.dll" is in your "php.ini". If you've updated your system path, restart and try again.



If you get "Session_start()" errors...


"No such file or directory"

Make sure that your temp Warning: session_start() [function.session-start]:
 open(C:/WINDOWS/Temp/php\sess_78947c37588a8b48e0d7fb5a53631e82, O_RDWR) failed:
 No such file or directory (2) in C:\apache\htdocs\gallery2\install\index.php on line 77

The "No such file or directory" part indicates that probably there is no "php" folder in the "C:\WINDOWS\Temp" directory.



"headers already sent"

Warning: session_start() [function.session-start]: Cannot send session cookie -
 headers already sent by (output started at C:\apache\htdocs\gallery2\install\index.php:77)
 in C:\apache\htdocs\gallery2\install\index.php on line 77

If this is NOT the first error on the page, then don't worry. Once the first error is corrected, these "headers already sent" errors will go away.

This may also indicate that your error reporting level is too high. Try turning off error notices by putting "error_reporting = E_ALL & ~E_NOTICE" in the error reporting section of your "php.ini" file. Alternately, you can tell PHP not to display errors (a good security idea) and only log them by putting "display_errors = Off" and "log_errors = On" in "php.ini"

Technical explanation: The "headers already sent" part indicates a php script tried to send an HTTP header after an HTTP body was already sent (headers have to be sent before the body). This ususally happens when an error or warning is encountered early in a script, before the rest of the script was done sending headers. Since the first error caused an HTTP body to be sent to display error message, subsequent headers can't be sent, causing the "headers already sent" error.


Warning: session_start() [function.session-start]: Cannot send session cache limiter -
 headers already sent (output started at C:\apache\htdocs\gallery2\install\index.php:77) in
 C:\apache\htdocs\gallery2\install\index.php on line 77

The "headers already sent" bit indicates this is the same as above.