May 10, 2008

Instaling Linux AMP

Lately I’ve been using ubuntu 7.10 for all my projects/daily work.
As a web developer i should have LAMP on my machine and now i would guide you through installing it on yours.

This guide is divided into 3 steps: installing/tesing Apache, PHP and finally MySQL.

Lets start with Apache:
1. Open the terminal (we will be using it through most of my guide) from Applications > Accessories > Terminal
2. Install apache2 using apt-get by typing the following

sudo apt-get install apache2

Note that you should know the root password.
Now everything should be downloaded and installed automatically.
To start/stop apache2 write:

sudo /etc/init.d/apache2 start
sudo /etc/init.d/apache2 stop

Your www folder should be in: /var/www/

If everything is OK you should see an ordinary HTML page when you type: http://localhost in your firefox browser

Finished with Apache ?

lets conquer PHP:
1. Also in terminal write:

sudo apt-get install php5 libapache2-mod-php5

or any php version you like
2. restart apache

sudo /etc/init.d/apache2 restart

This is it for PHP

Wanna test it ? Just create an ordinary PHP page in /var/www/ and run it.
Example:

sudo gedit /var/www/test.php

and write in it: < ?php echo "Hello World"; ?>

Now run it by typing http://localhost/test.php in firefox… You should see your ” Hello World ”

66 % is over, lets continue to installing MySQL:
1. Again and again in terminal execute:

sudo apt-get install mysql-server

2. (optional) If you are running a server you should probably bind your address by editing bind-address in /etc/mysql/my.cnf and replacing its value (127.0.0.1) by your IP address
3. set your root password (although mysql should ask you about that when installing)

mysql> SET PASSWORD FOR ‘root’@'localhost’ = PASSWORD(’xxxxxx’);

4. Try running it

mysql -uroot -pxxx

where xxx is your password.
Note: You can install PHPMyAdmin for a graphical user interface of MySQL by executing

sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin

5. restart apache for the last time

sudo /etc/init.d/apache2 restart

Congratulions your LAMP system is installed and running

Happy Coding


About installing/running phpmyadmin.
Do the following:

sudo apt-get install phpmyadmin

The phpmyadmin configuration file will be installed in: /etc/phpmyadmin
Now you will have to edit the apache config file by typing

sudo vi /etc/apache2/apache2.conf

and include the following line:

Include /etc/phpmyadmin/apache.conf

Restart Apache

sudo /etc/init.d/apache2 restart

Another issue was making mysql run with php5

First install these packages:

sudo apt-get install php5-mysql mysql-client

then edit php.ini and add to it this line : ” extensions=mysql.so” if it isnt already there

sudo vi /etc/php5/apache2/php.ini

Restart Apache

sudo /etc/init.d/apache2 restart

How to Install phpMyAdmin on Your Windows PC

  1. If you haven't done so already, download the phpMyAdmin Database Manager - You can download the software from the phpMyAdmin website. Be sure to download the phpMyAdmin-x.y.z.zip file. Save the file on your Windows Desktop.
  2. Double click the phpMyAdmin Zip file you have saved on your desktop. Extract all the files in the archive into the directory "C:\Server\Apache2\htdocs\phpmyadmin" (which is the default DocumentRoot of Apache). The folder "phpmyadmin" should be all lower case. Make sure the files get extracted right into this directory, and not into "C:\Server\Apache2\htdocs\phpmyadmin\phpMyAdmin-x.y.z". (the phpMyAdmin-x.y.z part might be a little different on your computer)
    1. If this happens, using "My Computer", browse to "C:\Server\Apache2\htdocs\phpmyadmin\phpMyAdmin-x.y.z". From the browse window, click "Edit">"Select All". Now click "Edit">"Cut". Browse back one directory (to "C:\Server\Apache2\htdocs\phpmyadmin") and click "Edit">"Paste". Now right-click the phpMyAdmin-x.y.z directory and click "Delete". Then "Yes" when the confirm delete dialog comes up.
  3. Open your favorite browser and in the address bar type "http://localhost/phpmyadmin/index.php".
  4. If PHP was installed correctly, you should see the phpMyAdmin login page, BUT with an error.
  5. This is OK, we are going to fix that. Start Notepad and open the file "C:\Server\Apache2\htdocs\phpmyadmin\config.inc.php". (If your machine does not have this file just create it) On some computers, this file might look like a real mess. Just lines and lines of of "junk". If this happens to you, close Notepad and open Wordpad (usually found in "Start">"All Programs">"Accessories">"WordPad") and open the "config.inc.php" file. Now everything should look like readable text. Click "File">"Save" to save this better looking version of the file. Now reopen the "config.inc.php" with Notepad.
  6. Find the line that looks like this: cfg['Servers'][$i]['auth_type'] = 'config'; And change the line so that it reads: $cfg['Servers'][$i]['auth_type'] = 'cookie';
  7. Find the line that looks like this: $cfg['blowfish_secret'] = ''; Inside '' put any word you want, like "holla". Its up to you. So after doing that, the line should look like: $cfg['blowfish_secret'] = 'holla';
  8. In Notepad click "File">"Save" to save this file. You can now close Notepad.
  9. Reload the page "http://localhost/phpmyadmin/index.php", and you should get a login page with no errors. To login to phpMyAdmin, use "root" as the Username, and for the password, use the root password you chose when installing MySQL.
  10. Click "Login" and you should see a screen like this:
  11. phpMyAdminphpMyAdmin
  12. If you see that page, you're done!


Install PHP under Apache and Vista

After fighting this for a couple of hours, I ended up installing manually anyway. I used this procedure to get PHP 5 running under Vista:

  1. Install the Apache webserver.
  2. Get the current version of PHP 5 from http://www.php.net/downloads.php#v5. (It’s 5.2.3 at this time). Get both the zip file and the PECL zip file (which includes extensions).
  3. Uninstall any previous installations of PHP 5 (Start > Control Panel > Programs and Features). You may have to reboot your machine.
  4. Disconnect from the Internet. Turn off your firewall. Turn off your virus checker.
  5. Turn off User Account Control (UAC).
  6. Get an administrator prompt by going to All Programs > Accessories. Right-Click “Command Prompt” and choose “Run as Administrator”

  7. Go to the directory where you’ve downloaded the PHP5 and PECL zipfiles. Extract the PHP zipfile. Rename the extracted php directory (which has a name something like php-5.2.3-Win32) to c:\php. Extract the PECL zipfile into c:\php\ext.
  8. In the command prompt, type:
    cd c:\php
    mkdir upload
    mkdir session
    copy php.ini-recommended php.ini
  9. Open php.ini in Notepad:
    1. There are many variables… the following are important. Notice that starting a line with a semicolon in the ini file comments it out.
      upload_tmp_dir="C:\php\upload"
      session.save_path="C:\php\session"
      cgi.force_redirect=0
      extension_dir ="C:\php\ext"
      display_errors = Off
      log_errors = On
      error_log = "C:\php\error_log"
    2. You might want to look at upload_max_filesize. I’ve set mine to 16M. I also set post_max_size = 16M.
    3. Enable the extensions you need by deleting the semicolon at the beginning of the line. These will depend on your application… I’m going to be using MySQL (which I’ve already installed) and Moodle (which I’ll install later). My list looks like the following:
      extension=php_bz2.dll
      extension=php_curl.dll
      extension=php_dba.dll
      extension=php_dbase.dll
      ;extension=php_exif.dll
      extension=php_fdf.dll
      extension=php_gd2.dll
      extension=php_gettext.dll
      ;extension=php_gmp.dll
      ;extension=php_ifx.dll
      ;extension=php_imap.dll
      ;extension=php_interbase.dll
      extension=php_ldap.dll
      extension=php_mbstring.dll
      extension=php_mcrypt.dll
      extension=php_mhash.dll
      extension=php_mime_magic.dll
      ;extension=php_ming.dll
      ;extension=php_msql.dll
      ;extension=php_mssql.dll
      extension=php_mysql.dll
      extension=php_mysqli.dll
      ;extension=php_oci8.dll
      extension=php_openssl.dll
      ;extension=php_pdo.dll
      ;extension=php_pdo_firebird.dll
      ;extension=php_pdo_mssql.dll
      ;extension=php_pdo_mysql.dll
      ;extension=php_pdo_oci.dll
      ;extension=php_pdo_oci8.dll
      ;extension=php_pdo_odbc.dll
      ;extension=php_pdo_pgsql.dll
      ;extension=php_pdo_sqlite.dll
      ;extension=php_pgsql.dll
      ;extension=php_pspell.dll
      extension=php_shmop.dll
      ;extension=php_snmp.dll
      extension=php_soap.dll
      extension=php_sockets.dll
      ;extension=php_sqlite.dll
      ;extension=php_sybase_ct.dll
      extension=php_tidy.dll
      extension=php_xmlrpc.dll
      extension=php_xsl.dll
      extension=php_zip.dll
  10. Right-Click on Start > Computer. Choose “Properties”, then “Advanced”. Click on “Environment Variables”. Click on PATH, then Edit… and add “;C:\php;c:\php\ext” (without quotes) to the end of the variable.
  11. Open your Apache configuration file (All Programs > Apache HTTP Server 2.2.x > Configure Apache Server > Edit the Apache httpd.conf Configuration File). Add the following lines:
    LoadModule php5_module "C:\php\php5apache2_2.dll"
    AddType application/x-httpd-php .php
    AcceptPathInfo on
    PHPIniDir "C:\php"

    Look for the DirectoryIndex line. Add ” index.php” (no quotes) to the end of that line.

    Save the file.

  12. Create a file named test.php in your Apache htdocs directory, containing this text:
  13. Reboot your machine.
  14. Browse to http://localhost/test.php. You should see tabulated information about your working PHP installation.

Install Apache on Windows Vista

Installing Apache under Windows XP was trivial. Not so, under Vista.

Creation of the Apache service fails. The conf directory can’t be set up by the installer,

probably due to permission problems.

I finally got it working with the following procedure. I used the latest version of Apache (2.2.4) and Windows Vista Home Premium.

  1. (most imp )Uninstall any previous installations of Apache Web server (Start > Control Panel > Programs and Features).
  2. Stop any other services (like IIS) that use port 80 (if you still want to use IIS, give it another port). If you’re running Skype you have to uncheck Advanced Options > Connection: Use Port 80 and 443 as alternatives (Thanks Jacob!)
  3. Stop User Account Control (UAC). (This isn’t absolutely necessary, but there will be less nagging if you do.)

  4. Get the most recent version of the apache Win32 binaries from http://httpd.apache.org/download.cgi and put it on your desktop. Rename it to apache (without changing the .msi extension, if that’s showing).
  5. Start > All Programs > Accessories
  6. Right-Click “Command Prompt” and choose “Run as Administrator”
  7. Manually remove directories containing previous apache installations (like C:\Program Files\Apache Software Foundation…)
  8. Change to your desktop folder directory (At the prompt type: cd desktop)
  9. At the prompt, type: msiexec /i apache.msi
  10. Run through the Apache installer. I’m running a development server, so I left the domain and computer name blank. You must specify an email address, though. Choose the default server on port 80 for all users option. Change the installation directory to c:\apache.
  11. Reboot.
  12. Browse to http://localhost. It should say “It works!” If it doesn’t, check your httpd.conf file by going to All Programs > Apache HTTP Server 2.2.x > Configure Apache Server > Test Configuration. Follow the directions for fixing the configuration file.
  13. You can turn UAC back on, if you like that sort of thing. To each his own!

installing Wamp under vista

installing Lamp
1)Install apache
2)then php
3)then my sql
4)phpmyadmin( it will help u to create and manage database)