Difference between revisions of "Setting up Apache, PHP and MySQL manually"

From Joomla! Documentation

(Several markup changes.)
 
(26 intermediate revisions by 4 users not shown)
Line 1: Line 1:
WIP
 
 
==Overview==
 
==Overview==
Here follows a brief overview of the steps to setup a Apache, PHP, MySQL in a Windows environment and also refer to various related tools to maintain and work with most of the tasks related to Joomla!.
+
Here's a brief overview of the steps to setup a Apache, PHP and MySQL in a Windows environment and also refer to various related tools to maintain and work with most of the tasks related to Joomla!.
  
 
In order to make the instruction clear and succinct, we will assume that wherever we are not stating any explicit instruction, you will let the default setup paths apply without modification.
 
In order to make the instruction clear and succinct, we will assume that wherever we are not stating any explicit instruction, you will let the default setup paths apply without modification.
  
==MySQL setup==
+
===Warning===
# Download the appropriate MySQL installer option for your platform (commonly x86, 32-bit) from http://www.mysql.com/downloads/mysql/  
+
If you already have any of the prepackaged AMP stacks installed on your machine:
# Start the installation and choose Custom installation path
+
* Going back to your AMP stack will be difficult. The various installations we will do below will overwrite registry values and make general environment changes. (This applies at least to the PC/Windows environment.)
# Click through the whole installation process and click Finish
+
* If you need to maintain any configuration (Apache, MySQL or PHP) or data (your existing websites and related databases), before making attempts of following this instruction, make proper backups.
# You will now be presented with the "MySQL Server Instance Configuration Wizard"
+
(needs to be expanded with specific advice on how to achieve the above...)
## Make sure that the "Standard Configuration" is selected and go to Next
+
 
## In the next window Check for "Include Bind Directory in Windows PATH". By doing this you will be able to access the various MySQL utilities from the command line.  
+
==MySQL Setup==
 +
# [https://dev.mysql.com/downloads/mysql/ Download] the appropriate MySQL installer option for your platform.
 +
# Start the installation and choose Custom installation path.
 +
# Click through the whole installation process and click Finish.
 +
# You will now be presented with the ''MySQL Server Instance Configuration Wizard''.
 +
## Make sure that the ''Standard Configuration'' is selected and go to Next.
 +
## If you already have MySQL installed you may get the message ''A Windows service with the name MySQL already exists. Please uninstall this service correctly or choose a different name for the new service.''  If so, choose an alternative service name.
 +
## In the next window check for ''Include Bin Directory in Windows PATH''. By doing this you will be able to access the various MySQL utilities from the command line.  
 
## In the next window you will be able to create password for your root MySQL user, the user with highest access level on your server.  
 
## In the next window you will be able to create password for your root MySQL user, the user with highest access level on your server.  
## In the next and final window all the changes you have configured until now will be saved when you press the Execute button, and the windows service for this instance will be started.
+
## In the final window all the changes you have configured so far will be saved when you press the ''Execute'' button and the windows service for this instance will be started.
  
 
===Notes===
 
===Notes===
# In order to make the instruction as accessible as possible we skipped a number of configuration scenarios of your MySQL instance, such as being able to relocate your database files etc. This and more is outlined in http://dev.mysql.com/doc/refman/5.1/en/mysql-config-wizard.html
+
# In order to make the instruction as accessible as possible we skipped a number of configuration scenarios of your MySQL instance, such as being able to relocate your database files.
# MySQL installs as default with a STRICT mode which might give rise to some errors when using extensions or applications that haven't considered this. Refer to this resource for more on this: http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html
+
# MySQL installs as default with a STRICT mode which might give rise to some errors when using extensions or applications that haven't considered this.
 
+
===Resources===
===Resources and tools to work with your MySQL instance===
+
* [https://www.heidisql.com/ HeidiSQL] An easy to use and extensible full-client replacement of phpMyAdmin under constant development.
* HeidiSQL: http://www.heidisql.com/ easy to use and extensible full-client replacement of phpMyAdmin under constant development
+
* [https://dev.mysql.com/downloads/workbench/ MySQL Workbench] Various tools among which you will appreciate the Administrator, which helps you to configure your MySQL instance. Requires  the [https://dotnet.microsoft.com/en-us/ .Net framework].
* MySQL Workbench: http://www.mysql.com/downloads/workbench/ consists of various tools among which you will appreciate the Administrator, which helps you to configure your MySQL instance and requires .Net framework http://www.microsoft.com/net/
+
* [https://www.phpmyadmin.net/ phpMyAdmin] A powerful web based MySQL client for administrating anything related to MySQL.
* phpMyAdmin: http://www.phpmyadmin.net/ , powerful web based MySQL client for administrating anything related to MySQL
+
* [https://dev.mysql.com/doc/ MySQL documentation]
* MySQL documentation http://dev.mysql.com/doc/ available in different formats
 
  
==Apache setup==
+
==Apache Setup==
# Download the installer of your preference. Currently you should aim for version 2.2.*, Win32 Binary without crypto applies) from http://httpd.apache.org/download.cgi
+
# [https://httpd.apache.org/download.cgi Download the installer] of your preference.
# Run the installer wizard and click through each step until you reach the Server Information window and give the options below respectively and in the given order in each of the fields, unless you have any specific requirements as to how your web server is setup:
+
# Run the installer wizard and click through each step until you reach the Server Information window. Give the options below respectively and in the given order in each of the fields unless you have any specific requirements as to how your web server is setup:
 
## localhost,
 
## localhost,
 
## localhost and  
 
## localhost and  
 
## admin@localhost
 
## admin@localhost
# Click through the wizard which will install and start the apache web server as a windows service.
+
# Click through the wizard which will install and start the Apache web server as a windows service.
 
# In the windows status bar you will now see a pink colored feather with a green colored play button indicating Apache is up and running. Point your browser to http://localhost/ and you should get a page indicating its working.
 
# In the windows status bar you will now see a pink colored feather with a green colored play button indicating Apache is up and running. Point your browser to http://localhost/ and you should get a page indicating its working.
# Let us now go to the location where Apache is installed which commonly is at C:\Program Files\Apache Software Foundation\Apache2.2 and go through the various directories
+
# Let us now go to the location where Apache is installed which commonly is at ''C:\Program Files\Apache Software Foundation\Apache2.2'' and go through the various directories
## bin - contains the various binary files some of which are listed below. In order to access these applications, most of which are command based, we would need to add the path to the bin directory in our global PATH variable. To do that right click on My Computer > Properties > Advanced > Environments Variables and in the System Variables list locate and select the Variable PATH and click on Edit and add a trailing a semi-colon, if not already there, followed by the absolute path to your bin directory. And click out from the System Properties dialogue by accepting.
+
## ''bin'' - contains the various binary files some of which are listed below. In order to access these applications, most of which are command based, we would need to add the path to the ''bin'' directory in our global PATH variable. To do that, right click on My Computer > Properties > Advanced > Environments Variables and in the System Variables list locate and select the Variable PATH and click on Edit and add a trailing a semi-colon, if not already there, followed by the absolute path to your bin directory. Click out from the System Properties dialogue by accepting.
### httpd.exe which is the Apache webserver itself, which is spawned to several child processes while serving as many simultaneous incoming clients requests as required by MaxClients directive;  
+
### ''httpd.exe'' which is the Apache webserver itself, which is spawned to several child processes while serving as many simultaneous incoming clients requests as required by MaxClients directive;  
### ab.exe is a benchmarking tool that comes with Apache allowing you to see how well your application can perform per time unit
+
### ''ab.exe'' is a benchmarking tool that comes with Apache allowing you to see how well your application can perform per time unit
## conf - folder where various configuration files are located of which the following are of most interest in our case
+
## ''conf'' - folder where various configuration files are located of which the following are of most interest in our case
### httpd.conf - most of the server directives are located in this file and for easy access you should associate the .conf file type with a user friendly editor, i.e. anything other than the default Notepad.
+
### ''httpd.conf'' - most of the server directives are located in this file and for easy access you should associate the ''.conf'' file type with a user friendly editor, i.e. anything other than the default Notepad.
### extra\httpd-vhosts.conf - contains directives that would allow you use your local server as virtual host, i.e. able to run several servers on your PC. One usage scenario is that during a development phase if you want to map the actual domain you are working for to your local copy, you would be able to do so by making minor tweaks in this file. We will discuss this in more detail below.
+
### ''extra\httpd-vhosts.conf'' - contains directives that would allow you use your local server as virtual host, i.e. able to run several servers on your PC. One usage scenario is that during a development phase if you want to map the actual domain you are working for to your local copy, you would be able to do so by making minor tweaks in this file. We will discuss this in more detail below.
## htdocs - the default web server root, this is where the http://localhost/ is mapped if you don't reconfigure it.
+
## ''htdocs'' - the default web server root, this is where the http://localhost/ is mapped, i.e. if you don't reconfigure it in ''httpd.conf'' above.
## logs - access and error logs, when trying to address various issues related to your server or even your application
+
## ''logs'' - access and error logs, when trying to address various issues related to your server or even your application
 +
===Virtual Hosting===
 +
 
 
===Resources===
 
===Resources===
* http://httpd.apache.org/docs/2.2/ reference documentation
+
* The [https://httpd.apache.org/docs/current/ Apache reference documentation]
===Virtual hosting===
 
  
==PHP setup==
+
==PHP Setup==
# Download PHP from http://windows.php.net/download/ and choose commonly VC6 x86 Thread Safe in Zip format. The various options have to do with how the PHP code base was compiled to binary and is probably nothing you should worry about for now.
+
# [https://windows.php.net/download/ Download PHP] and choose commonly VC6 x86 Thread Safe in Zip format. The various options have to do with how the PHP code base was compiled to binary and is probably nothing you should worry about for now.
 
# Create a folder under your C:\Program Files\ (or wherever your program directory is located) a folder called PHP.  
 
# Create a folder under your C:\Program Files\ (or wherever your program directory is located) a folder called PHP.  
 
# Locate your downloaded Zip file and move it to the newly created folder and unpack it directly into the folder.
 
# Locate your downloaded Zip file and move it to the newly created folder and unpack it directly into the folder.
# Let us now add the PHP path to our global PATH variable by following the instruction above
+
# Let us now add the PHP path to our global PATH variable by following the instruction above.
  
 
===Configuring PHP===
 
===Configuring PHP===
The configuration amounts to editing the php.ini file. A sample file for different scenarios are already in your PHP folder. Let us rename php.ini-development to php.ini and open it in your favorite text editor. The common values to tweak are as follows and all of these variables are well documented in the php.ini file (please note that this is a server wide setting applying to all your projects):
+
The configuration amounts to editing the ''php.ini'' file. A sample file for different scenarios is already in your PHP folder. Let us rename ''php.ini-development'' to ''php.ini'' and open it in your favourite text editor. The common values to tweak are as follows and all of these variables are well documented in the ''php.ini'' file. (Note that this is a server wide setting applying to all your projects.):
* max_execution_time - whenever you have scripts that run for too long and the server returns various unexpected results which you think is due to not being able to run through the whole process
+
* ''max_execution_time'' - whenever you have scripts that run for too long and the server returns various unexpected results which you think is due to not being able to run through the whole process
* memory_limit
+
* ''memory_limit''
* error_reporting  
+
* ''error_reporting''
* display_errors
+
* ''display_errors''
* log_errors - a variable you would need to take note of in production scenarios
+
* ''log_errors'' - a variable you would need to take note of in production scenarios
* upload_tmp_dir
+
* ''upload_tmp_dir''
* upload_max_filesize
+
* ''upload_max_filesize''
* extension_dir - in order to avoid complications we will point out the directory where the following extensions are located by uncommenting this variable and assign the absolute location of the folder, and the complete line should read as follows
+
* ''extension_dir' - in order to avoid complications we will point out the directory where the following extensions are located by uncommenting this variable and assign the absolute location of the folder. The complete line should read as follows
 
<pre>
 
<pre>
 
extension_dir = "C:\Program Files\PHP\ext"
 
extension_dir = "C:\Program Files\PHP\ext"
 
</pre>
 
</pre>
* Dynamic extensions section contains various additional modules that you want to be loaded with, and the commented once are those that comes prepackaged with PHP and can be found in the ext directory in your PHP folder. If you want to activate any just remove the commenting as you should do with the following extensions:
+
* Dynamic extensions section contains various additional modules that you want to be loaded with, and the commented ones are those that comes prepackaged with PHP and can be found in the ''ext'' directory in your PHP folder. If you want to activate any, just remove the commenting as you should do with the following extensions:
 
** php_curl.dll
 
** php_curl.dll
 
** php_gd2.dll
 
** php_gd2.dll
Line 76: Line 82:
 
* session.save_path
 
* session.save_path
  
===Configuring Apache to work with PHP===
+
===Configuring Apache to Work with PHP===
Now that we have configured PHP to work as we want it, lets go to Apache and do the same.  
+
Now that we have configured PHP to work as we want it, let's go to Apache and do the same.  
* Open httpd.conf. and in the "Dynamic Shared Object (DSO) Support" section add the following directives (if you have located your PHP folder differently do make corresponding change for php5apache2_2.dll below):  
+
* Open ''httpd.conf'' and in the "Dynamic Shared Object (DSO) Support" section add the following directives. (If you have located your PHP folder differently do make corresponding change for php5apache2_2.dll below.):  
 
<pre>
 
<pre>
 
LoadModule php5_module "C:/Program Files/PHP/php5apache2_2.dll"  
 
LoadModule php5_module "C:/Program Files/PHP/php5apache2_2.dll"  
 
AddType application/x-httpd-php .php
 
AddType application/x-httpd-php .php
 
</pre>  
 
</pre>  
* In the DirectoryIndex add index.php as possible file to serve when directory is requested as follows
+
* In the DirectoryIndex add ''index.php'' and ''index.htm'' as possible files to serve when directory is requested as follows:
 
<pre>
 
<pre>
 
DirectoryIndex index.html index.htm index.php
 
DirectoryIndex index.html index.htm index.php
</pre>.
+
</pre>
* At the end of the file add the following line which will point out where the php.ini file is located
+
* At the end of the file add the following line which will point out where the ''php.ini'' file is located
 
<pre>
 
<pre>
 
PHPIniDir "C:/Program Files/PHP"
 
PHPIniDir "C:/Program Files/PHP"
 
</pre>
 
</pre>
  
===Restart and test PHP===
+
===Restart and Test PHP===
As soon as you make any change to any of php.ini or httpd.conf or any other configuration files you need to restart Apache to see the actual effect of the changes. So lets now restart Apache by using the Apache Monitor tool you can find in your Windows status bar. Hopefully you are not prompted with any dialogues and the Apache Monitor continues to run green.
+
As soon as you make any change to ''php.ini'',  ''httpd.conf'' or any other configuration files, you need to restart Apache to see the effect of the changes. So let's now restart Apache by using the Apache Monitor tool that you can find in your Windows status bar. Hopefully you are not prompted with any dialogues and the Apache Monitor continues to run green.
 
 
We will now make a test that PHP is working. Go to your web servers document root (in the default case C:\Program Files\Apache Software Foundation\Apache2.2\htdocs) and add a file called phpinfo.php with the following content:
 
  
 +
We will now test that PHP is working. Go to your web server's document root (in the default case ''C:\Program Files\Apache Software Foundation\Apache2.2\htdocs'') and add a file called ''phpinfo.php'' with the following content:
 
<pre>
 
<pre>
 
<?php
 
<?php
Line 104: Line 109:
 
</pre>
 
</pre>
  
This will render a page containing information about your PHP setup and about the various modules/extensions that are currently loaded. Point now your browser to http://localhost/phpinfo.php.
+
This will render a page containing information about your PHP setup and about the various modules/extensions that are currently loaded. Point your browser to http://localhost/phpinfo.php.
 +
 
 +
===Installing and Configuring ''xdebug''===
 +
# Point your browser to [https://xdebug.org/wizard Xdebug Installation Wizard]. This page will assist you to find a suitable version of Xdebug.
 +
# Copy the entire page of the ''phpinfo'' page we ran above and paste it into the textarea and follow the instructions provided to install.
 +
===Resources===
 +
* The [https://www.php.net/docs.php PHP Manual] Excellent and up to date documentation with valuable additional comments from users. Downloadable versions are available.
 +
* The [https://xdebug.org/docs/ Xdebug 3 Documentation]
  
===Installing and configuring xdebug===
+
[[Category:Bug Squad]]
# Point your browser to http://www.xdebug.org/find-binary.php. This page will assist you to find the latest suitable version of xdebug.
 
# Copy the entire page of the phpinfo page we ran above and paste it into the textarea and follow the instructions provided to install
 
===Resources for PHP and xdebug===
 
* http://www.php.net/docs.php excellent and up to date documentation with valuable additional comments from users. Also a downloadable versions are available.
 
* http://devzone.zend.com/article/2803 excellent and in depth tutorial on debugging with xdebug
 
* http://xdebug.org/docs/ xdebug reference documentation
 

Latest revision as of 10:12, 29 September 2022

Overview[edit]

Here's a brief overview of the steps to setup a Apache, PHP and MySQL in a Windows environment and also refer to various related tools to maintain and work with most of the tasks related to Joomla!.

In order to make the instruction clear and succinct, we will assume that wherever we are not stating any explicit instruction, you will let the default setup paths apply without modification.

Warning[edit]

If you already have any of the prepackaged AMP stacks installed on your machine:

  • Going back to your AMP stack will be difficult. The various installations we will do below will overwrite registry values and make general environment changes. (This applies at least to the PC/Windows environment.)
  • If you need to maintain any configuration (Apache, MySQL or PHP) or data (your existing websites and related databases), before making attempts of following this instruction, make proper backups.

(needs to be expanded with specific advice on how to achieve the above...)

MySQL Setup[edit]

  1. Download the appropriate MySQL installer option for your platform.
  2. Start the installation and choose Custom installation path.
  3. Click through the whole installation process and click Finish.
  4. You will now be presented with the MySQL Server Instance Configuration Wizard.
    1. Make sure that the Standard Configuration is selected and go to Next.
    2. If you already have MySQL installed you may get the message A Windows service with the name MySQL already exists. Please uninstall this service correctly or choose a different name for the new service. If so, choose an alternative service name.
    3. In the next window check for Include Bin Directory in Windows PATH. By doing this you will be able to access the various MySQL utilities from the command line.
    4. In the next window you will be able to create password for your root MySQL user, the user with highest access level on your server.
    5. In the final window all the changes you have configured so far will be saved when you press the Execute button and the windows service for this instance will be started.

Notes[edit]

  1. In order to make the instruction as accessible as possible we skipped a number of configuration scenarios of your MySQL instance, such as being able to relocate your database files.
  2. MySQL installs as default with a STRICT mode which might give rise to some errors when using extensions or applications that haven't considered this.

Resources[edit]

  • HeidiSQL An easy to use and extensible full-client replacement of phpMyAdmin under constant development.
  • MySQL Workbench Various tools among which you will appreciate the Administrator, which helps you to configure your MySQL instance. Requires the .Net framework.
  • phpMyAdmin A powerful web based MySQL client for administrating anything related to MySQL.
  • MySQL documentation

Apache Setup[edit]

  1. Download the installer of your preference.
  2. Run the installer wizard and click through each step until you reach the Server Information window. Give the options below respectively and in the given order in each of the fields unless you have any specific requirements as to how your web server is setup:
    1. localhost,
    2. localhost and
    3. admin@localhost
  3. Click through the wizard which will install and start the Apache web server as a windows service.
  4. In the windows status bar you will now see a pink colored feather with a green colored play button indicating Apache is up and running. Point your browser to http://localhost/ and you should get a page indicating its working.
  5. Let us now go to the location where Apache is installed which commonly is at C:\Program Files\Apache Software Foundation\Apache2.2 and go through the various directories
    1. bin - contains the various binary files some of which are listed below. In order to access these applications, most of which are command based, we would need to add the path to the bin directory in our global PATH variable. To do that, right click on My Computer > Properties > Advanced > Environments Variables and in the System Variables list locate and select the Variable PATH and click on Edit and add a trailing a semi-colon, if not already there, followed by the absolute path to your bin directory. Click out from the System Properties dialogue by accepting.
      1. httpd.exe which is the Apache webserver itself, which is spawned to several child processes while serving as many simultaneous incoming clients requests as required by MaxClients directive;
      2. ab.exe is a benchmarking tool that comes with Apache allowing you to see how well your application can perform per time unit
    2. conf - folder where various configuration files are located of which the following are of most interest in our case
      1. httpd.conf - most of the server directives are located in this file and for easy access you should associate the .conf file type with a user friendly editor, i.e. anything other than the default Notepad.
      2. extra\httpd-vhosts.conf - contains directives that would allow you use your local server as virtual host, i.e. able to run several servers on your PC. One usage scenario is that during a development phase if you want to map the actual domain you are working for to your local copy, you would be able to do so by making minor tweaks in this file. We will discuss this in more detail below.
    3. htdocs - the default web server root, this is where the http://localhost/ is mapped, i.e. if you don't reconfigure it in httpd.conf above.
    4. logs - access and error logs, when trying to address various issues related to your server or even your application

Virtual Hosting[edit]

Resources[edit]

PHP Setup[edit]

  1. Download PHP and choose commonly VC6 x86 Thread Safe in Zip format. The various options have to do with how the PHP code base was compiled to binary and is probably nothing you should worry about for now.
  2. Create a folder under your C:\Program Files\ (or wherever your program directory is located) a folder called PHP.
  3. Locate your downloaded Zip file and move it to the newly created folder and unpack it directly into the folder.
  4. Let us now add the PHP path to our global PATH variable by following the instruction above.

Configuring PHP[edit]

The configuration amounts to editing the php.ini file. A sample file for different scenarios is already in your PHP folder. Let us rename php.ini-development to php.ini and open it in your favourite text editor. The common values to tweak are as follows and all of these variables are well documented in the php.ini file. (Note that this is a server wide setting applying to all your projects.):

  • max_execution_time - whenever you have scripts that run for too long and the server returns various unexpected results which you think is due to not being able to run through the whole process
  • memory_limit
  • error_reporting
  • display_errors
  • log_errors - a variable you would need to take note of in production scenarios
  • upload_tmp_dir
  • upload_max_filesize
  • extension_dir' - in order to avoid complications we will point out the directory where the following extensions are located by uncommenting this variable and assign the absolute location of the folder. The complete line should read as follows
extension_dir = "C:\Program Files\PHP\ext"
  • Dynamic extensions section contains various additional modules that you want to be loaded with, and the commented ones are those that comes prepackaged with PHP and can be found in the ext directory in your PHP folder. If you want to activate any, just remove the commenting as you should do with the following extensions:
    • php_curl.dll
    • php_gd2.dll
    • php_mbstring.dll
    • php_mysql.dll
    • php_mysqli.dll
    • php_pdo.dll
    • php_pdo_mysql.dll
    • php_xsl.dll
  • session.save_path

Configuring Apache to Work with PHP[edit]

Now that we have configured PHP to work as we want it, let's go to Apache and do the same.

  • Open httpd.conf and in the "Dynamic Shared Object (DSO) Support" section add the following directives. (If you have located your PHP folder differently do make corresponding change for php5apache2_2.dll below.):
LoadModule php5_module "C:/Program Files/PHP/php5apache2_2.dll" 
AddType application/x-httpd-php .php
  • In the DirectoryIndex add index.php and index.htm as possible files to serve when directory is requested as follows:
DirectoryIndex index.html index.htm index.php
  • At the end of the file add the following line which will point out where the php.ini file is located
PHPIniDir "C:/Program Files/PHP"

Restart and Test PHP[edit]

As soon as you make any change to php.ini, httpd.conf or any other configuration files, you need to restart Apache to see the effect of the changes. So let's now restart Apache by using the Apache Monitor tool that you can find in your Windows status bar. Hopefully you are not prompted with any dialogues and the Apache Monitor continues to run green.

We will now test that PHP is working. Go to your web server's document root (in the default case C:\Program Files\Apache Software Foundation\Apache2.2\htdocs) and add a file called phpinfo.php with the following content:

<?php
phpinfo();
phpinfo(INFO_MODULES);
?> 

This will render a page containing information about your PHP setup and about the various modules/extensions that are currently loaded. Point your browser to http://localhost/phpinfo.php.

Installing and Configuring xdebug[edit]

  1. Point your browser to Xdebug Installation Wizard. This page will assist you to find a suitable version of Xdebug.
  2. Copy the entire page of the phpinfo page we ran above and paste it into the textarea and follow the instructions provided to install.

Resources[edit]

  • The PHP Manual Excellent and up to date documentation with valuable additional comments from users. Downloadable versions are available.
  • The Xdebug 3 Documentation