In this post I’m going to show you how to install apache, php, and mysql manually.
If you are doing this for the second time (you have already installed it before and you want to reinstall it because of some problems) you have to do the following before you continue:
- Delete the MySQL folder located in the Program Files folder or where you installed it before. The uninstaller doesn’t automatically delete this folder (I don’t really know, maybe it does when you restart your computer).
- Delete the MySQL folder located in the following address when you’re on Windows XP:
C:\Documents and Settings\All Users\Application Data
And if you’re on Windows Vista or Windows 7 where user_name is the username of the current user.
Here’s the order of installation:
First we install Apache. Just follow the following screenshots.
Enter the network domain, server name and the administrator’s email address. If the website that you are hosting in the Apache server is just accessible in a local area network then you can use localhost. If not then enter what’s applicable to your configuration, you can use the example given in the installer as a reference.
By default apache will be stored on the following location:
c:\program files\apache software foundation
It’s fine if you just use the default but if you want to make it more memorable the use the example below:
Next is PHP.
If you’re bored you can read the EULA. If not then immediately accept it. And yes, you’re free to read the EULA even if you’re not bored.
To make it more memorable change the installation path to the following:
Select Apache 2.2
Now you need to browse the location where the http.conf file is located.
Select the extensions and extras that you wish to install.
Lastly we install MySQL.
This EULA is way too long, you might as well skip it and just check on the agreement
Click Next twice. Then click Finish.
At this point in time MySQL has already been installed but not yet configured. Click Next to continue with the configuration.
Select Detailed Configuration then click Next.
You can either choose Server Machine or Dedicated Server Machine. But for the purpose of hosting a site I think it’s better to use Server Machine Configuration. Click Next.
Again this requires you to decide. Just read the description for each type to determine the suitable configuration. You can just use Multifunctional Database if you’re not sure what to choose. If the system that you’re trying to host is a transactional type of system (Point of Sale, Billing System, Tax Collection System etc.) then select transactional database. If it’s just a system for a school project then you can choose non-transactional database.
This is where you choose the location of the mysql data (Data stored in your mysql databases)
This configuration depends on the number of concurrent users of the system. It’s up for you to decide what to choose.
The default port used by MySQL is 3306. You’re free to change it if you think another application is already using it. Check enable strict mode and click Next.
Again this depends upon you. If you think you’re going to store Chinese or Japanese or ASCII characters in your database today or in the near future then just select Best Support For Multilingualism. Click Next.
Just use the defaults. If you don’t want to use the MySQL console in running MySQL commands you might want to check the include bin directory in windows path option. This allows you to run MySQL commands from the Windows Command Line.
Enter your desired password:
Click Execute. This won’t take a minute, if it takes more than a minute maybe you haven’t deleted the folders I was talking about a while ago.
To configure Apache you need to open up the httpd.conf file and change the following line.
PHPIniDir "" LoadModule php5_module "php5apache2_2.dll"
To something like the one below. Just change the location to where you installed php.
PHPIniDir "C:\php" LoadModule php5_module "C:\php\php5apache2_2.dll"
Next you need to tell Apache to make use of the index files as default files on your server. Because by default index files are being treated like ordinary files. Here’s the default.
<Directory /> Options FollowSymLinks AllowOverride None Order deny,allow Deny from all </Directory>
You need to change it to this so that index.php and index.php will be treated as the default files.
<Directory /> Options FollowSymLinks AllowOverride None Order deny,allow Deny from all DirectoryIndex index.php index.html </Directory>
We’ve done this so that you can avoid the problem wherein all the files in a specific directory are being listed in a nice way (not really nice).
To configure PHP open up the php.ini file. In this example the php.ini file is located in the following location:
First you need to change the error_reporting.
error_reporting = E_ALL & ~E_DEPRECATED //default error_reporting = E_ALL //change to this
Display errors, html errors and display startup errors is disabled by default.
display_errors = Off //default display_errors = On //change to this
html_errors = Off //default html_errors = On //change to this
display_startup_errors = Off //default display_startup_errors = On //change to this
Only do this if you’re still on the testing phase. You don’t want your users to see any errors.
Next set the defaults for MySQL connection.
mysql.default_port = 3306 mysql.default_socket = mysql.default_host = localhost mysql.default_user = root mysql.default_password = secret
Another one that you might want to look at is the time zone. If you’re setting the time zone in a configuration file you might also get warnings to avoid that all you need to do is to set the timezone in the php.ini file.
date.timezone = UTC //change this to your timezone
If you are a Wampserver user, you might have also noticed that your redirects aren’t working anymore. If you’re getting this kind of error then follow the answers of the people at Stackoverflow. That is if your code is not made up of 99.9% of bad code, modifying it might actually lead to even more bugs. Just do the following and try not to use Wampserver the next time you develop your php application. I’ve also learned my lesson here, Wampserver is actually hiding a lot of errors and warnings because its php.ini file is configured to do so. Just enable output buffering:
output_buffering = On
What this does is to allow you to send headers, cookies, sessions after you have already outputted something on the page. You might have noticed that php doesn’t actually allow you to redirect the page if you’ve already outputted something that is if you’re not using Wampserver. Yes, Wampserver encourages bad coding practice and I’ll admit that I’m also a victim. If you’re reading this as a beginner in the world of web development then I encourage you not to use Wampserver and XAMPP. As you might already know XAMPP also encourages bad coding practice because it’s short open tag directive is enabled by default:
short_open_tag = On //this is in XAMPP, don't do this
And what this means is that it allows you the developer to use shorthand php tags:
<? //code here ?>
O yeah, you just saved 3 characters there but it’s not actually a good coding practice. Try to avoid this at all cost.
Finally, if you’re like me and you’ve mindlessly checked the Enable Strict Mode a while ago just change the following line in the my.ini file.
Into this line:
Sorry about that, I’ve actually told you to enable strict mode a while ago. So if you didn’t do it. There’s no need for you to do this step.
So why exactly did we disable strict mode? Because it’s to strict. One example of it being strict is that if you don’t pass a value to a field while performing an insert query, the query won’t execute and you’ll get a warning which tells that one of the fields didn’t get any value. If you didn’t quite get the picture here’s an example.
We have a table named TABLE (yeah, very creative way of naming huh):
We performed an insert query:
INSERT INTO TABLE SET name = 'luffy'
As you can see we didn’t set a value for the address since we didn’t even call it in our query we can just go away with it if it’s not strict mode. But if it’s strict mode we have to set up a value for every field in the table. Pretty nasty isn’t it?
That’s it! I’ve written this tutorial while actually figuring out what’s wrong with the configuration. I hope I’ve help someone save some hours by writing this tutorial. The result is actually pretty nasty if you’ve developed your application using WAMP or XAMPP then you suddenly install each of the software manually. So I guess the lesson here is that don’t try to develop in WAMP or in XAMPP if you think you’re gonna be using the manual installation on system deployment.