How to install Apache, PHP and MySQL on Windows

Apache

First, I recommend you read the Platform Specific Notes of Apache for Windows – it explains some Windows-specific features like running as a service that you don’t have on other OSes and you probably have never used before.

As mentioned in these platform specific notes, Apache doesn’t provide binaries for Windows, however they have links to several third-party sites that provide binaries, for example Apache Lounge.

From that website, we can download either the 32-Bit version (win32) or the 64-Bit one (Win64) – if your OS is 64-Bit you should always try to install 64-Bit versions of software, but note that you’ll need to use 64-Bit modules as well, that means if you only have a 32-Bit module then download the 32-Bit Apache.

Here’s the version that I used when writing this : Apache 2.4.10 Win64 – it was the latest version when this answer was last updated (look at the edit date at the bottom of the post).

Once downloaded, just extract the Apache24 folder to the root of your hard drive, so that you have a path like C:\Apache24\bin.

Open a command line window (Windows+R and type cmd then press Enter), change directory into C:\Apache24\bin and run httpd.exe, normally it shouldn’t print any errors.

If you get an error dialog stating that MSVCR110.dll is missing on your system, you’ll need to install the Visual C++ Redistributable for Visual Studio 2012 – as always, when prompted, select the appropriate bit-version : vcredist_x86.exe for 32-Bit systems and vcredist_x64.exe for 64-Bit ones.

If you get an error saying that it can’t bind to port 80, check if another application uses that port – also Skype is known to use ports 80 and 443 by default; uncheck “Use port 80 and 443 as alternatives for incoming connections” in its advanced connection settings, restart Skype to apply the changes, and then you should be able to start Apache without issues.

A warning like Could not reliably determine the server's fully qualified domain name can be ignored for now.

Windows Firewall may prompt you to allow Apache to communicate on specific networks, I recommend you use the default settings : allow it on home and work networks, but not on public/untrusted networks.

Then, open a browser and browse to http://localhost, if you see a page saying It works ! then it means your Apache installation is working.

You can now stop the currently running Apache by pressing Ctrl+C in the command prompt.

If you got a warning about not being able to determine the system’s fully qualified domain name, fix it by editing C:\Apache24\conf\httpd.conf and editing the ServerName variable (it should be already there in a comment, just uncomment it and change it) :

ServerName <yourhostname>

Replace <yourhostname> with either the system’s host name or localhost.

Finally, if you want to run the server automatically when the system starts (even if nobody logs in), you’ll need to run it as a service – in a new elevated (as an administrator) command prompt, type :

httpd.exe -k install

That’s it, now you have a new service in Services (Windows+R then type “services.msc” then press Enter) named “Apache2.4” that you can control just like any other Windows service.

Restricting Apache access to localhost only – optional

If you’re setting this up for development purposes you want to make sure that no one except you can access it, your firewall should already take care of that but let’s add another layer of security to it by telling Apache to accept requests from the local machine only.

Open Apache’s configuration file C:\Apache24\conf\httpd.conf, search for the default directory block <Directory "c:/Apache24/htdocs">.

At the end if it, there should be a line Require all granted, this means that anyone can access this server. Let’s make that Require local which only allows access from the local machine.

Also, you can tell Apache to only bind to the loopback interface, that way even if both your firewall and the access control directives mentioned above fail, the server still won’t be open to the whole internet.

For this, locate the Listen directive (by default it’s set to 80) and change it to the following :

Listen 127.0.0.1:80
Listen [::1]:80

The first line is self explanatory, the second one is the first one’s IPv6 equivalent, the brackets are used in the IPv6 notation to separate the address and the port.

Save the file, if you’re already running the server then restart it in order to take our changes into account, and now only localhost has access, everyone else will get a 403 Forbidden.

PHP

I suggest you read the official PHP documentation about installing it on Windows systems.

Download the latest PHP binaries from the official PHP for Windows download page, choose the thread-safe version that matches your Apache installation’s bit-version (x86 for 32-Bit, x64 for 64-Bit).

The non thread-safe version is only when running as a CGI binary – more info here.

The version I used is this : PHP 5.6.2 VC11 x64 Thread Safe – it was the latest version when this answer was last updated (look at the edit date at the bottom of the post).

Create an empty PHP folder at the root of your hard drive, and extract the previously downloaded archive there, you should have a path like C:\PHP\ext, otherwise you did something wrong.

In C:\PHP, rename the php.ini-production or php.ini-development (depending on what you want) to php.ini.

Open that php.ini file, search for extension_dir = "ext" and uncomment that line (remove the first ;). This sets the default extension dir to ext (which resolves to C:\PHP\ext and avoids having to prepend ext/ to all extension’s paths manually like in previous versions of this post.

Now configure Apache to use that PHP, by editing C:\Apache24\conf\httpd.conf – after all the LoadModule lines, add the following :

LoadModule php5_module C:/PHP/php5apache2_4.dll

<IfModule php5_module>
    DirectoryIndex index.html index.php
    AddHandler application/x-httpd-php .php
    PHPIniDir "C:/PHP"
</IfModule>

Now try to start Apache manually by opening a command prompt in C:\Apache24\bin and running httpd.exe – if you see no errors, it means your configuration file is valid and PHP is most likely working.

You can test your PHP installation by creating a file like info.php with <?php phpinfo(); inside and going to http://localhost/info.php – you should see quite a bit of info about your system and your PHP installation and all its modules. If you get something else like an “Internal server error” that means something’s wrong.

You can now kill your current Apache process (Ctrl+C in the console) and start the service – the following part doesn’t interact with Apache and can be done with the server already started.

Composer – optional

Composer is a tool for dependency management in PHP, like a package manager. It allows to easily install PHP packages and even entire frameworks.

Composer requires the PHP OpenSSL extension to be enabled, so let’s enable it in C:\PHP\php.ini.

Use your text editor’s search function to search for php_openssl.dll, there should already be a commented line for it, just uncomment that line.

Now download Composer’s Windows installer from their download page – or just use this direct link.

Follow the instructions, when prompted for the path to PHP, browse to C:\PHP and select php.exe.

That’s it, Composer is now installed system-wide and can be used from anywhere – you can try it out, just open a new command prompt (you can’t use one that’s already open since it needs to read the new PATH variable set by Composer’s installer) and type composer.

You should get a nice ASCII-art logo and something like this :

Composer version e87bc894daf8d5f8e77a01dd7ae5f0446ae30b14 2014-05-01 15:40:28

PHP MySQL extensions – optional

If you want to access your MySQL database from PHP, you’ll need to enable extensions that allow you to do so, like php_mysqli or php_pdo_mysql – I recommend enabling them both.

Open PHP’s configuration file C:\PHP\php.ini in your text editor and search for php_mysqli or php_pdo_mysql – they should already be there, uncomment them.

Done, now you can access any MySQL database using either mysqli or PDO.

MySQL

On the MySQL Installer download page download the web installer mysql-installer-web-community-xxxxx.msi.

I used mysql-installer-web-community-5.6.21.1.msi – it was the latest version when this answer was last updated (look at the edit date at the bottom of the post).

The installer will automatically install the appropriate version (32-Bit or 64-Bit) depending on your system, even though MySQL’s bit version doesn’t have to match Apache’s and PHP’s one but it’s still beneficial to use the 64-bit version of your system supports it to take advantage of more than 3 GB of RAM, that’s quite important as database servers tend to use a lot of RAM.

Follow the steps in the installer, if you’re installing this for development then the Developer default will be your best option, it’ll also install MySQL Workbench which is a native GUI client, thus avoiding you having to install slow web-based tools such as PHPMyAdmin if you aren’t comfortable with using the command line client.

Once everything is installed the installer will ask your for some basic configuration values, I recommend disabling “Open firewall port for network access” unless you want to access the database from another machine on the network.

Set the root password – if it’s only for development purposes and your firewall blocks incoming connections from the network then a strong password isn’t necessary.

Finally, you can disable the useless MySQL Notifier by right-clicking the tray icon, going into Actions -> Options, then untick the Run at Windows Startup checkbox and apply. That’ll save you a few MBs of RAM and avoid slowing your machine down when it’s booting.

And that’s it, you now have a fully functional WAMP server that runs as a service and doesn’t depend on any user (accessible even if no one is logged in).

Note that I have no idea about the security of this, for development purposes I’d say this is pretty safe since your firewall should block incoming connections for both Apache (port 80 and or 443) and MySQL (port 3306).

This was tested on a Windows 7 installation, it should also work just fine on Windows 8, Windows 10 and Windows Server 2008/2012

Posted in Uncategorized | Leave a comment

Linux Terminal Command Reference – Linux Mint Community

Source: Linux Terminal Command Reference – Linux Mint Community

Posted in linux, Linux Mint, Ubuntu | Tagged , , , , , | Leave a comment

Monitorix 3.8.1 Released – A Lightweight System and Network Monitoring Tool for Linux

Monitorix 3.8.1 Released – A Lightweight System and Network Monitoring Tool for Linux

Source: Monitorix 3.8.1 Released – A Lightweight System and Network Monitoring Tool for Linux

Posted in Uncategorized | Leave a comment

Glances – An Advanced Real Time System Monitoring Tool for Linux

Glances is a cross-platform curses-based system monitoring tool written in Python language which use the psutil library to grab informations from the system.

Source: Glances – An Advanced Real Time System Monitoring Tool for Linux

Posted in Uncategorized | Leave a comment

A Shell Script to Monitor Network, Disk Usage, Uptime, Load Average and RAM Usage in Linux

This small shell script will help you to monitor your most of the Linux server information like Network, Users, Load, Ram, host, Internal IP, External IP, and more.

Source: A Shell Script to Monitor Network, Disk Usage, Uptime, Load Average and RAM Usage in Linux

Posted in Uncategorized | Leave a comment

Upgrading to an after market car stereo system – 2007 Chevrolet Impala

I upgraded to an after market car stereo for the 2007 Chevy Impala and this is how I did it.

This is primarily written for the 2007 Chevy Impala since they don’t have +12volt ignition wire located in the wire harness.

  1. Chevrolet Impala 07 Stereo Removal Instructions https://www.youtube.com/watch?v=Dv_poinoFTk
  2. Know what the wires do http://www.modifiedlife.com/2007-chevrolet-impala-car-radio-wiring-color-codes/
  3. Retained Accessory Power (RAP) source in a 2007 Impala

The RAP* fuse is the red horizontal fuse in the picture below. Just above the two silver   circuit breakers. You will want to tap this to use as your radio’s 12v accessory wire. It is located in the fuse box on the lower, right passengers side near the passenger doorDSC07017

4. You will need purchase the products listed below and then install per product instructions.

5. Go to step 1. and follow instructions in reverse order.

**NEW INFORMATION** Here is a device for chime retention and switched 12 volt accessory. For 2006-2007 Impala:

Metra Axxess GM LAN Data Bus Interface with Chime Retention http://www.amazon.com/gp/product/B0049MV2IY?psc=1&redirect=true&ref_=oh_aui_detailpage_o00_s00

Metra Axxess GM LAN-** http://www.crutchfield.com/shopsearch/Metra_Axxess_GM_LAN_Data_Bus_Interface.html

I hope this will help you guys out.

*Retained Accessory Power (RAP) Power Mode

Retained accessory power (RAP) is a power mode that permits the operation of some accessories for up to 10 minutes after the ignition switch is turned OFF. The RAP power mode is enabled by the body control module (BCM).

The BCM:

– Controls certain body functions.
– Sends out a class 2 message via the serial data link, which enables/disables other modules at the beginning/end of the RAP power mode.
Some BCM features, such as the interior courtesy lamps will function after the 10 minute RAP time limit has elapsed. This is normal, and does not mean the RAP power mode is malfunctioning. The BCM enables the following functions in the RAP Power Mode:

– The windshield wipers and washer through the RAP/adaptive cruise control (ACC) relay.
– The right and left power windows through the RAP/ACC relay.
– Any class 2 module that functions in RAP power mode and is not connected to the RAP/ACC relay, is controlled by the BCM via class 2 power mode messages. EXAMPLE: The radio works in RAP power mode because the BCM sends it a class 2 message telling it that the power mode is RAP.

RAP is disabled when:
– A door is opened.
– Low battery voltage is detected by the BCM.
– The ignition switch transitions from OFF to ON or ACC.
– 10 minutes have elapsed after the ignition was turned OFF.

The BCM monitors the ignition switch position, battery voltage and passenger compartment door status to determine whether RAP power mode should be enabled. If the ignition switch transitions from ON to OFF, the battery voltage is within the acceptable range, and the passenger compartment doors are closed, the BCM enables RAP power mode. After 10 minutes have elapsed, the BCM sends a class 2 message to the serial data network. This message commands the other modules that are power moded by the BCM to stop functioning.

RAP/ACC Relay
The BCM controls the RAP/ACC relay coil circuit using low side drive. The output of the relay is used to supply battery voltage to the windshield wipers and power windows. The RAP/ACC relay also provides voltage to the windshield wipers and power windows when the Accessory and Run power modes are selected.

Posted in car, Chevy, repair, upgrade | Leave a comment

Use your Raspberry Pi as an always-on BitTorrent box

In this tutorial we will turn our Raspberry Pi into an always-on BitTorrent box. This will let you have a small, power efficient, torrent server running around the clock.

Why is this a good idea?

A lot of companies offer to download their software and/or files using torrents, and when you downloaded the installer for your Raspberry Pi OS, you could also do this as a torrent.

If you are downloading and/or sharing a lot of files using torrents (legally of course), you might have a dedicated machine, or even your laptop, running for long periods of time solely for this purpose. This can be very power consuming, and that’s why the Raspberry Pi is perfect to use as a dedicated torrent box that can run 24/7. Compared to a laptop or stationary computer, the Pi is very power efficient.

 

Prerequisites

This tutorial uses a Raspberry Pi running RaspBMC as an example system, but you can also use Raspbian. In order proceed I assume that you:

  1. Have a Raspberry Pi running either Raspbian or RaspBMC.
  2. Are able to remotely access your Pi using SSH.
  3. Have some sort of storage connected where you can save files.

If you need help getting started with any of these, you can find more information here:

  1. Getting started with Raspberry Pi – Part 1
  2. Getting started with Raspberry Pi – Part 2 (SSH etc)
  3. Mount a network drive on your Raspberry Pi

 

Installation

Before we start, let’s make sure we have the latest repositories and that our system is up to date:

sudo apt-get update && sudo apt-get upgrade -y
Install and setup Deluge daemon and console
sudo apt-get install deluged
sudo apt-get install deluge-console

Once it is installed, we want to start Deluge and then stop it again. This will create the default configuration files we need.

deluged
sudo pkill deluged

Now we have the configuration files we need, and we will edit one of them. Open and edit the ~/.config/deluge/auth file and add the following to the end of the file:

echo "username:password:level" >> ~/.config/deluge/auth

Where user and password are the credentials you want to use for remote access to Deluge, and the level is the access level you want to give that user. You should put this to 10 (which is the full-access/admin level for the Deluge daemon). As an example, I use pi:raspberry:10.

Start the Deluge daemon again, and the Deluge console:

deluged
deluge-console

This will bring up the Deluge console window, where we will make some changes to the configuration. Inside the Deluge console, type the following:

config -s allow_remote True
config allow_remote
exit

On the first line we enable remote access to our Deluge daemon, and on the second line we simply double-check that the value is correctly set to True.

Now we have to restart the Deluge daemon again to make the new configurations take effect:

sudo pkill deluged
deluged

Now that the Deluge daemon is ready for remote connects, it’s time to install a client on our that we can connect to the daemon.

 

Install and setup Deluge client

In order to connect to the Deluge daemon running on the Pi, we need to install the Deluge client on our computer:

  • Ubuntu
  • Windows / Mac

If you’re running Ubuntu on your PC, you can install the Deluge client with the following command:

sudo apt-get install deluge

If you are running other Linux distros you can download the necessary package from the official Deluge download page.

Once you have installed the client, start it. The first time we run the client, we have to make a few quick changes. Go to Preferences -> Interface. Under the submenu Classic Mode there’s a checkbox named ‘Enable’. This is checked by default, we need to uncheck it.

Click OK, and restart the client.

Now that the client starts, you will be presented with the Connection Manager. This is where we need to create a connection to the Deluge daemon running on the Pi. Click Add in order to create a new connection, and input the IP of your Pi as well as the username and password that you set for the daemon in the previous section. Leave the port to 58846 as this is the default port.

Once you click add, you will get back to the connection manager and you should see your connection:

Select it and click Connect. Now you are connected to you Deluge daemon on the Pi! We don’t don’t have any torrents there yet, but we’ll get to that soon.

 

Configure Deluge to use a proxy

Although this section is optional, it is highly recommended that you use a proxy to protect your BitTorrent traffic. There are several reasons why you should use a proxy to shuttle your traffic, and even though you’re not downloading anything illegal it is still better to be safe than sorry. If you want to be anonymous on the Internet, a proxy will help keep eavesdroppers away. By default, Deluge also encrypts all traffic which is good if your ISP is throttling BitTorrent traffic.

If you are suspecting you ISP of throttling your BitTorrent traffic, this tool can help you detect if this is the case.

I am using Private Internet Access as a proxy, and it’s fairly cheap for what you get ($39.95/year). You are of course free to use any service you like, and it’s up to you if you trust using a free service.

Once you have a proxy that you can use, we have to configure Deluge to shuttle the traffic through this proxy. To do this, open Preferences -> Proxy. Set all sections to ‘Socks5 W/ Auth’ and input your credentials. If you are using Private Internet Access’ proxy, the host is proxy-nl.privateinternetaccess.com and the port 1080.

In order for the changes to take effect, we need to restart the Deluge daemon on the Pi:

sudo pkill deluged 
deluged

You will have to reconnect to the Daemon from the client as well.

Test it

Now it’s time to test that the proxy is setup correctly. We will do this by downloading a completely legal torrent from TorGuard.net. Download the torrent, add it to your queue, and select it to see the IP through which your client is connected. If everything is setup correctly you should see the IP of your proxy instead of your own IP (see the bottom of the picture below).

 

Configure download folders

Now it’s time to setup the folders where Deluge should download your files. By default, the files will be saved to /home/pi, and this will probably fill up your Pi’s SD card pretty quickly. Instead we are going to save our files to an external storage.

I am using a network drive that I have mounted to /media/network/, but you can use any storage device you like. Just make sure you have permissions to write to it. Mount an SMB network drive on Raspberry Pi will show you how to use a network drive with your Pi.

We are going to create three new folders that we’ll use for Deluge:

.downloading – this is where the active downloads will exist
.completed – once finished downloading, all files will be moved to this folder
.watch – Deluge will watch for newly added .torrent files in this folder, and automatically start them

Decide where you want to create the folders (I have chosen to create these in /media/network/Public/), and run:

sudo mkdir /media/network/Public/.downloading
sudo mkdir /media/network/Public/.completed
sudo mkdir /media/network/Public/.watch

Now open the Preferences -> Downloads section in the client and set the folders to the ones you just created.

You don’t have to restart anything this time.

Test everything

Now we can test that everything is working as it should. Let’s download a large enough file to make sure it runs smoothly, the latest release of Raspberry Pi NOOBS installer (roughly 1.3GB) should be sufficient: NOOBS Latest

Instead of adding it manually through the client, you can try saving the .torrent file to the .watch folder to make sure Deluge starts it automatically.

 

That’s it! Now you have your very own always-on BitTorrent box running on your Raspberry Pi.

Posted in Uncategorized | Leave a comment