Tuesday, April 24, 2007

How to install Apache, PHP, MySQL, and Zend Optimizer on OpenSUSE

References or rather sources: From which I have indiscriminately used the procedures.
Requirement:
  • OpenSUSE with Yast (Yet another Setup Tool) - This is where we will get latest Apache Web Server, MySQL, PHP modules and extensions.
  • phpMyAdmin Database Manager - An admin tool for MySQL databases.
    Download from http://www.phpmyadmin.net/home_page/downloads.php
    Save the download gzip version (with .tar.gz extension) in the /srv/www/htdocs/ directory.
  • Zend Optimizer - To optimize PHP web development.
    Download from http://www.zend.com/free_download/optimizer (Prior free registration is required)
    Download Linux x86 for 32bit server or Linux x86_64 for 64bit server.
Get started
  1. Power up OpenSUSE machine and login in as user.
  2. Start up YaST. (Do this by clicking the SUSE toolbar's "Start" button (that would be the green button with the smiling gecko) => "System" menu => "YaST"
  3. YaST dialog opens telling you that you need to enter root's password before you can continue.
  4. Enter the root password.
  5. In the YaST window that opens, click the "Software" icon in the left menu and then the "Install and Remove Software" or "Software Management icon to the right.
  6. YaST takes a moment to inventory what you already have installed and what you can install. Then it opens a window with a search dialog (and a few other options that I've yet to explore).
Install Apache

  1. Type "apache" in the search field and click the "Search" button.
  2. Select the modules you want to install. Required: apache2, apache2-mod_php5
  3. Check box before "Autocheck" and click the "Accept" button.
  4. Resolve "Dependency Conflict" and survey the suggested additions by following installation procedures. Yast has made the process very simple.
  5. Now you'll want to set Apache to start up when you boot. To do that, click the "System" icon in the left pane of the YaST window.
  6. Click the "System Services (Runlevel)" or "Runlevel Editor" in the right panel.
  7. Click the "Expert Mode" radio button at the top of the YaST window.
  8. Select "apache2" from the scrolling list.
  9. Under the "Set/Reset" dropdown in the lower-right corner, choose "Enable the Service". This should automatically select the appropriate runlevels that will be used when starting the service.
  10. Under the "Start/Stop/Refresh" dropdown, select "Start now ..."
  11. Click "Finish".
Enable Rewrite Module
Mod_Rewrite is a super cool module which allow you to manipulate URL, hence make your side more search-engine friendly. By default, SuSE doesn't enable the mod_rewrite rewrite module. It's installed, but not enabled. Follow these steps to install it.
  1. Edit the file /etc/sysconfig/apache2 as root (Open Terminal, type "su" and enter root password, type "kwrite /etc/sysconfig/apache2"):
    1. search for APACHE_MODULES, you should find a line like this
      APACHE_MODULES="actions alias auth_basic authn_file authz_host authz_groupfile authz_default authz_user authn_dbm autoindex cgi dir env expires include log_config mime negotiation setenvif ssl suexec userdir php5"
    2. Add "rewrite" to the content in the list between the "
    3. Save the changes and quit
  2. run SuSEconfig to update the apache configuration files
  3. run /etc/init.d/apache2 restart to restart the Apache server

Install PHP

  1. Type "php" in YaST's search field and click the "Search" button.
  2. Select php5 and extensions you want to install. Required or recommended: php5-mysql, php5-mbstring, php5-mcypt (required by phpmyadmin), php5-gd (for image manipulation).
  3. Check box before "Autocheck" and click the "Accept" button.
  4. Resolve "Dependency Conflict" and survey the suggested additions by following installation procedures.
Install MySQL
  1. Type "mysql" in YaST's search field and click the "Search" button.
  2. Add "mysql" and "mysql-client" to the list of previously installed components.
  3. Click "Accept".
Fixing Permissions for MySQL
  1. Open "File Manager - Super User Mode" (Do this by clicking the SUSE toolbar's "Start" button => "System" menu => "File Manager" => "File Manager - Super User Mode") and enter root's password. If you can not find the file manager, log out and log in as root and then open file manager.
  2. Browse to /var/lib/ and right-click the /mysql/ directory.
  3. Select "Properties"
  4. In the Properties window that opens, click the "Permissions" tab.
  5. Under "Access Permissions", select "Can View & Modify Content" from the "Group" dropdown menu.
  6. Under "Ownership", type "mysql" in the "Group" field.
  7. Click the "Apply changes to all sub folders and their contents" checkbox. This will apply these rights (that are set at the /var/lib/mysql/ level) to the files, folders (and databases) below.
  8. Click "OK".
Starting MySQL Service
  1. Open YaST.
  2. Click the "System" icon in the left pane of the YaST window.
  3. Click the "System Services (Runlevel)" or "Runlevel Editor" in the right panel.
  4. Click the "Expert Mode" radio button at the top of the YaST window.
  5. Select "mysql" from the scrolling list.
  6. Under the "Set/Reset" dropdown in the lower-right corner, choose "Enable the Service". This should automatically select the appropriate runlevels to use when starting the service.
  7. Under the "Start/Stop/Refresh" dropdown, select "Start now ..."
  8. Click "Finish".
Install phpmyadmin
  1. Assume that you have save and phpmyadmin gzip file in the /srv/www/htdocs/ directory.
  2. Open "File Manager - Super User Mode" (Do this by clicking the SUSE toolbar's "Start" button => "System" menu => "File Manager" => "File Manager - Super User Mode") and enter root's password. If you can not find the super user's file manager, log out and log in as root and then open file manager.
  3. Browse to /srv/www/htdocs/
  4. Right-click on the file and under the "Actions" menu selection, choose "Extract Here".
  5. Once the files are extracted, right click on the folder (probably something like phpMyAdmin-2.10.1-all-languages.tar.gz) and rename it to "phpMyAdmin". (Make it all lower case if you like).
  6. Open your favourite browser and type in the address bar:
    • http://localhost/phpMyAdmin/index.php
  7. You may see this error message:
    This error message means that our login or password to connect to mysql database is wrong. In order for phpMyAdmin could connect to mysql database, we must supply the login and password at phpMyAdmin configuration file.

    Almost all configurable data is placed in config.inc.php. This file only needs to contain the parameters you want to change from their corresponding default value in phpMyAdmin/libraries/config.default.php. If config.inc.php does not exist at the phpMyAdmin directory, just copy config.default.php from libraries directory to phpMyAdmin directory, and rename it to config.inc.php.

    Locate this string: $cfg['PmaAbsoluteUri'] = '';

    Inside the ' ' place the location of where phpMyAdmin is installed on the server. In this case we installed it within the root directory under its own folder name. So we’ll use “http://localhost/phpMyAdmin/” as our absolute URL location.

    There are 3 authentication methods that we can use to connect to phpMyAdmin:
    1. config method (the default method)
      This method is the least secure, as it requires storing your MySQL username and password in the file on the server. Anyone who would find the directory to your phpMyadmin installation would then be able to access your databases. This is the default method, however.

      If you use the 'config' authentication method, it is strongly recommended that you secure the directory in which phpMyAdmin is installed, such as adding password protect to phpMyAdmin directory. This extra step is not needed when using either the 'http' or 'cookie' authentication methods.

      Locate this string: $cfg['Servers'][$i]['auth_type'] = 'config';
      Locate this string: $cfg['Servers'][$i]['user'] = 'put your MySQL login here';
      Locate this string: $cfg['Servers'][$i]['password'] = 'put your MySQL password here'
    2. http method
      These methods are more secure, as your username and password are not stored on the server in your configuration file. The 'http' option uses the Apache http authentication method.

      Locate this string: $cfg['Servers'][$i]['auth_type'] = 'http';
      Locate this string: $cfg['Servers'][$i]['user'] = '';
      Locate this string: $cfg['Servers'][$i]['password'] = '';
    3. cookie method (recommended method)
      These methods are more secure, as your username and password are not stored on the server in your configuration file. The 'cookie' method uses cookies, and has the advantage that you can "Log Out" at the end of your session, deleting the cookie.

      Locate this string: $cfg['Servers'][$i]['auth_type'] = 'cookie';
      Locate this string: $cfg['Servers'][$i]['user'] = '';
      Locate this string: $cfg['Servers'][$i]['password'] = '';
      Locate this string: $cfg['blowfish_secret'] = 'fill anything here';

      For the blowish_secret values, you can fill any alphabets, in example you can use 716e3c0.88759346, but, keep in mind that the maximum length seems to be 46 characters. The passphrase is just used internally to encrypt the password - you will not be prompted for it later.
Install Zend Optimizer
  1. Assume that you have downloaded Zend Optimizer zipped file.
  2. Right-click on the file and under the "Actions" menu selection, choose "Extract To...".
  3. A dialog appears, asking where you wish to extract the files to. Type "/tmp/" and click "Ok".
  4. Open Terminal.
  5. Type "su" and enter root password.
  6. Type "cd /tmp/ZendOptimizer-[version]".
  7. Type "./install".
  8. The screen above appears. Press "Enter"
  9. License will appear, Choose "Exit".
  10. Accept the terms of the license by pressing "Enter".
  11. Choose "OK" unless you want to install Zend Optimizer in other location.
  12. Type the location of PHP configuration file, php.ini (/etc/php5/apache2) and press "Enter".
  13. Choose "Yes" to tell Zend Optimizer that you are using Apache Server.
  14. Confirm the location of apache2ctl and press "Enter".
  15. It will determine your PHP version. Press "Enter" after it tells you that some configurations have been made.
  16. Press "Enter" to restart Apache server.
  17. Press "Enter" and close the terminal.
Test your Server
  1. To test PHP, open your favourite editor. I use Kwrite.
  2. Type the following into a document:
  3. Save the file as info.php to the "/home/user/public_html/" directory. (Replace user with your username).
  4. Launch a web browser and access the info.php file using this URL:
    • http://localhost/~user/info.php
  5. You should see a web page that displays all the configuration details of your PHP installation.
  6. When you view this file with your browser, search for modules you have installed, for example, rewrite and gd - you should find at least one entry each.
  7. You can test your MySQL installation by going to http://localhost/phpMyAdmin/. With Linux, URLs are case sensitive so it is important to capitalize the "M" and the "A" in phpMyAdmin or you'll get an error.
  8. You should see the following screen if you have phpMyAdmin using Apache to communicate with MySQL.

Wednesday, April 18, 2007

How to recover lost partitions

My 200GB hard disk used to have 6 partitions. The first partition was where Windows system files located (NTFS), the second partition was formatted as Linux Swap, third as Linux Ext3 and the rest as NTFS again.
For some strange reasons, I lost all other than the first partition. I was in a state of panic, for I have about 100GB data in these lost partitions.

Fortunately, I found TestDisk, a powerful OpenSource free software.

  1. I downloaded the software from http://www.cgsecurity.org/wiki/TestDisk_Download and unzipped it.

  2. I opened the file executable file, testdisk_win.exe.

  3. I chose [ Append ] and I could see that my hard disk appeared in the menu. I pressed [ Proceed ] and then chose my partition table media [ Intel ].

  4. Then, I pressed [ Analyse ] and my current (wrong) partition table appeared.

  5. I pressed Enter to proceed. Then it showed "more correct" partition structure, for the program mistook my Linux partitions as a NTFS one.

  6. After I pressed Enter to continue I chose [Search! ]. At long last, the program did recognise that the partition might be Linux one.

  7. To resolve the conflict, I used Left/Right Arrow keys to Delete the NTFS one while select the Linux one as Logical drive.

  8. After that, I chose [Write ] and restart my computer.
And yes, all the partitions came back.

How to fix corrupted Registry keys in windows XP

I had a problem reinstalling Internet Explorer. Thus, I did the following as instructed by IE troubleshooting:
  • Start>Run, and type %windir%\ie7.log

I realised that several keys in HKEY_CLASSES_ROOT were corrupted, in the sense that I was unable to open nor delete the keys. This was problematic because IE7 installation need access to these keys.

But later I found this page, http://forum.aumha.org/viewtopic.php?t=8125 I followed the procedures and the problem was solved.

  1. Download and install subinacl from:

    http://www.microsoft.com/downloads/details.aspx?FamilyID=e8ba3e56-d8fe-4a91-93cf-ed6985e3927b&displaylang=en

  2. Create a file named reset.cmd (the "reset" can be any name you like) in C:\Program Files\Windows Resource
    Kits\Tools folder (the default folder for subinacl).

  3. Edit the reset.cmd file with the following content.

    subinacl /subkeyreg HKEY_LOCAL_MACHINE /grant=administrators=f
    subinacl /subkeyreg HKEY_CURRENT_USER /grant=administrators=f
    subinacl /subkeyreg HKEY_CLASSES_ROOT /grant=administrators=f
    subinacl /subdirectories %SystemDrive% /grant=administrators=f

    subinacl /subkeyreg HKEY_LOCAL_MACHINE /grant=system=f
    subinacl /subkeyreg HKEY_CURRENT_USER /grant=system=f
    subinacl /subkeyreg HKEY_CLASSES_ROOT /grant=system=f
    subinacl /subdirectories %SystemDrive% /grant=system=f

  4. Enter into CMD prompt by Start>Run, and type cmd.

  5. Enter the following commands one at a time and click Enter.

    cd\
    cd "C:\Program Files\Windows Resource Kits\Tools" (If you have installed subinacl in other folders, please enter the path of the folder where your subinacl installed instead.)
    reset.cmd
It took several minutes to process. I could see lines of the script being executed. After it was done, I reinstalled IE7. All the damaged keys were already unlocked!