17 Jan 2005
SUSE Linux 9.1 Professional KDE 3.2.1
Here's the deal. I've been a Windows user for the better part of my career.
So, any way you go about it, I'm a Linux neophyte. I hope to get over that.
Sooner would be better than later. I really like what I've seen others doing
with Linux and I would love to take part in the rebellion.
For the past three weeks I've been working to install MySQL on my SUSE Pro
9.1 box. It's been quite an adventure. Maybe it was me and my lack of
experience. Maybe it wasn't. Nonetheless, in an effort to make the trip shorter
for the next guy or gal trying the same task, I've taken the time to outline the
steps I took -- once I figured out where it was safe to step. I hope it helps
someone.
Pouring the Foundation One of the reasons I embarked on this
adventure is so I could have a Linux web server in my lab. (Well, okay, in the
laundry room.) I've done a lot of Cool Solutions work lately with a number of
hosting providers and they're all running ... Linux. So it makes sense for me to
have a development and/or test environment that runs the same.
The Main Ingredients My end goal was to have a server running
Apache web server software, the PHP scripting language, and the MySQL database
engine. Few will argue that this combination is one of the most popular on the
web today.
Before I start listing the steps, let me apologize in advance. The initial
installation was actually quite easy, thanks to SuSE's YaST ("Yet another Setup
Tool"). But, as is most often the case, the devil was in the details. And to
complicate things, as I pointed out earlier, I'm terribly new at this. If I've
made a mistake, please send in your
suggestions and set me straight. That way we can all learn (and I can patch
up my configuration). Here's where I started:
- Power up the server.
- Log in as user (not root).
- 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"
- YaST dialog opens telling you that you need to enter root's password
before you can continue.
- Enter the root password.
- In the YaST window that opens, click the "Software" icon in the left menu
and then the "Install and Remove Software" icon to the right.
- 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
- Type "apache" in the search field and click the "Search" button.
- Select the modules you want to install. I wanted to start out with the
basics so I selected "apache2", "apache2-mod_php4".
- Click the "Accept" button.
- This is where YaST gets cool. Like a good guardian angel, YaST evaluates
your selections, tells you what's missing, and gives you some ideas about
resolution. In my case, YaST suggested a few other modules that were required
to make the install successful. It took a few minutes to evaluate the
suggestions and (sometimes) choose between the options, but I was happy to
have the help and used every bit of the YaST information to complete the
installation.
This screen informed me that there was a conflict and
gave me a few logical choices that would need to be made in order to resolve
the conflict.
I clicked the radio button next to "install
apache2-prefork" and pressed the "OK - Try Again" button.
- YaST notified me that not that I had resolved the pending conflicts, and
that two other packages were being installed to "resolve
dependencies".
- As I said, I was happy for the direction and clicked the "Continue" button
without hesitation.
- 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.
- Click the "Runlevel Editor" in the right pane.
- Click the "Expert Mode" radio button at the top of the YaST window.
- Select "apache2" from the scrolling list.
- 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.
- Under the "Start/Stop/Refresh" dropdown, select "Start now ..."
- The Apache service should start and the runlevel editor screen will look
like this:
- Click "Finish".
- Save the changes.
Install PHP
- Type "php" in YaST's search field and click the "Search" button.
- This time, YaST shows that I've already installed "apache2-mod_php4" and
"php4".
- Since I know I'll be working with MySQL, I select "php4-mysql" and
"phpmyadmin" (a browser-based admin tool for MySQL databases).
- Click "Accept".
- Survey the suggested additions.
- Click "Continue".
Test our Progress Let's take a minute to test what we've just
installed before we dig ourselves a hole that's too deep to get out of. We can
test both Apache and PHP by dropping a .php file in the server directory and
seeing if Apache will serve it up.
- Open a text editor. (Remember, I'm a Windows guy. I just want to create a
text file, not learn a new paradigm for editing.) "Start" menu =>
"Utilities" => "Editor" opened up the perfect text editor (Kate) for a guy
like me. She was graphical and familiar and knew what to do with a mouse. What
more could a guy want?
- Type the following into a document:
- Save the file as info.php to the "/home/kmillecam/public_html/" directory.
(You'll want to replace "kmillecam" with your username, not mine).
- One of the neat features of Linux and Apache, is that every user has their
own personal directory that they can use to host their content.
- Launch a web browser and access the info.php file using this URL:
http://localhost/~kmillecam/info.php
- You should see a web page that displays all the configuration details of
your PHP installation. WooHaa! Apache is running. PHP is running. Two down,
one to go.
Install MySQL
- Type "mysql" in YaST's search field and click the "Search" button.
- Add "mysql" and "mysql-client" to the list of previously installed
components.
- Click "Accept".
- Survey the suggested additions.
- Click "Continue".
We There Yet? If you're still with
me, thanks. YaST stops a little short of fully installing MySQL. So, the best is
yet to come. The following was not easy fare and came only after much pizza and
many a caffeine-charged cola. I found the following in various and sundry
support databases, list servers, and documentation pages.
I immediately (actually, it took me a week to figure out this one) checked
the /var/lib/mysql/ directory only to find it empty! This directory is supposed
to include the MySQL foundation files that are necessary to make it all
work.
Feedback
from reader Jim Pye:
The /bin directory is in your path so the need to
change to this directory first is not needed. As the script is located in the
/bin dir you can invoke it from anywhere in the file system eg. your home dir
(the prompt with the ~) by typing:
mysql_install_db
--user=mysql
If you want to run a command that is in a directory not in
your path then there are 2 options; Change to the directory and run the command
with special syntax or use the full path to the command.
If your current
directory is the one that contains the command then you must use the following
syntax to run the command:
./mysql_install_db --user=mysql
The
leading dot and forward slash are required because the shell (bash in this case)
does not automatically look in the current directory for files to execute, this
is unlike DOS. The ./ syntax tells the shell to look in the current directory
for the command to run.
The other way to run a command is to specify the
full path to the command.
/bin/mysql_install_db --user=mysql
would
work from anywhere as it uniquely specifies the file to run.
I found the following in the MySQL documentation:
- Log in as the root user. ("Start" => "Switch User")
- Open a terminal window (the icon that looks like a monitor behind a
clamshell).
- Type "cd /bin" enter (no quotes).
- Type "mysql_install_db --user=mysql
- If you typed carefully, after a few seconds of processing, you'll be
reading a screen of kudos and congratulations.
Adding the MySQL Group In order for the mysql, the root, and the
daemon user accounts to be able to startup and work with the databases you've
just created, you'll need to create a group for these members.
- Open YaST.
- Click "Security and Users" in the left pane.
- Click "edit and create groups" in the right pane.
- Click "Add" from the bottom of the "User and Group Administration"
window.
- Type "mysql" in the "Group Name" field.
- Check the checkboxes next to the "daemon", "mysql", and "root" names in
the "Members of this Group" window.
- Click "Next".
Fixing the Permissions Don't pat yourself on the back, quite yet.
I'm not sure why, but the new directories, databases, and files that were just
created in the /var/lib/mysql/ directory do not have enough rights and
permissions to allow the MySQL service to start up.
So, before you log out of the root account, you'll need to grant the
appropriate rights. Here's how I went about it.
- Open the Konqueror file browser by clicking on the "House" icon in the
toolbar.
- Browse to /var/lib/ and right-click the /mysql/ directory.
- Select "Properties"
- In the Properties window that opens, click the "Permissions"
tab.
- Under "Access Permissions", select "Can View & Modify Content" from
the "Group" dropdown menu.
- Under "Ownership", type "mysql" in the "Group" field.
- 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.
- Click "OK"
- Log out of the Root account.
Starting the MySQL Service
- Open YaST.
- Click the "System" icon in the left pane of the YaST window.
- Click the "Runlevel Editor" in the right pane.
- Click the "Expert Mode" radio button at the top of the YaST window.
- Select "mysql" from the scrolling list.
- 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.
- Under the "Start/Stop/Refresh" dropdown, select "Start now ..."
- If we haven't' made any missteps, the MySQL service will start.
- Click "Finish".
- Save the changes.
Testing MySQL If you installed phpMyAdmin, 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.
WooHoo! You should see the following screen if you have phpMyAdmin using
Apache to communicate with MySQL. (We'll take care of the warnings -- the ones
in BOLD RED type -- next.
Taking Care of Warning #1
- Log into the root account.
- Use Konqueror to browse to /srv/www/htdocs/phpMyAdmin/
- Right-click on config.inc.php
- From the menu that opens, select "Open With ..."
- Select "Utilities" => "Editor" => "Kate"
- Click "OK"
- Change line 39 from "$cfg['PmaAbsoluteUri'] = ''" to
"$cfg['PmaAbsoluteUri'] = 'http://localhost/phpMyAdmin/'"
I've
discovered that this string works if you plan to use phpMyAdmin from the
server machine but if you want to access it from another computer, you'll want
to use the fully qualified domain name, like this:
http://www.example.com/phpMyAdmin/
- While you're in the configuration file, enter 'localhost' between the
quotes on line 69.
- Enter the username 'root' on line 83.
- Enter the root password 'password' on line 84.
- Save the file and close the editor.
- Log out of the root account.
- Reboot your server.
I've
learned that this is a gaping security hole. Since you've hard coded the root
username and password into the configuration file, anyone can access (and toy
with) your databases if they know the URL to phpMyAdmin =-)
Yikes!
Avoid this by 1) removing the user and password info from the
config.inc.php file and 2) either a) changing the 'auth_type' to 'http' which
asks whomever is accessing the site for the appropriate username and password
(Keep in mind that the password travels in plain text, unless you are using
the HTTPS protocol.) or b) Changing the 'auth_type' to 'cookie', where the
password is stored, encrypted with the blowfish algorithm, in a temporary
cookie.
Taking Care of Warning #2 MySQL is
initially installed without passwords. You should follow the steps in the MySQL
documentation ([url]http://dev.mysql.com/doc/mysql/en/Default_privileges.html)
to add passwords to all accounts.
Here are the steps I took:
- From my user account, open a terminal window.
- Type "cd /bin" (no quotes)
- Type "mysql -u root" [enter] to log into the "MySQL monitor" tool as the
root user.
- Type "UPDATE mysql.user SET Password = PASSWORD('rock0n') WHERE User =
'root';
- Enter.
- This will secure your database with a password.
|