cf.Objective

Speaking at cf.Objective

Recommended Books

Blog

Beginning Adventures in CentOS: Installing Apache and MySQL

Here it is, the first of the promised "Beginning Adventures with CentOS" blog posts...

I started a new project yesterday. This particular client is running CentOS 5.5 32-bit, Tomcat 5.7, Apache, and a combination of MySQL and SQL Server. One of my first tasks is to build a VMWare image that mirrors that (or gets as close as possible without losing a lot of time) so we have a playground for some development work. I've installed Ubuntu on a desktop once or twice, but that was at least a year ago, and the Ubuntu installer did all the work for me really (which I greatly appreciated). So let's see how different installing CentOS in VMWare is from that experience...

I downloaded the DVD ISOs (2 discs total) for CentOS

Making a new guest in VMWare is easy enough. And with that "express install" option, VMWare automagically installed CentOS for me! Wow, that was even easier than the Unbuntu install I did last year! :) Firefox comes pre-installed too, so it's easy to tell if I have a working internet connection inside this new VM -- Firefox pop up and sees Google.com, so that's taken care of too.

So now we need to move onto the "real" stuff -- installing Apache, MySQL, and Tomcat...

Let's open Firefox again and go to "http://localhost"....instead of the default "Apache is running" web page, I get "Problem loading page". So either Apache isn't installed, or it's just not running. Fortunately CentOS has some similarities to Windows, and there is a "Services" screen in CentOS, just like in Windows. The Apache service is actually named "httpd" (which kind of baffles me, but that's a separate discussion), and we do indeed have a service called "httpd" there, so we just need to check it, and click "start". Now let's go back to Firefox and do "http://localhost" again. Success! We now have the "Apache is running" web page.

Next up, MySQL and Tomcat. Since I'm more familiar with MySQL, let's start with that one...

After checking the Services control panel, it doesn't seem that MySQL came pre-installed with CentOS (I was only half-suspecting it might be). I could use the "Add / Remove Programs" menu, but since the whole point of this is to learn something, let's try to install it from the Linux command line instead. On my Ubuntu machine, you install things with the "apt-get" command, so let's try that on CentOS and see what happens:

>apt-get mysql

...and "Command not found". Okay so it's not "apt-get". After a bit of thinking/Googling..."yum" is the command we're looking for, so let's try this again:

>yum install mysql

And that comes back with "You need to be root to perform this command".

Delving back into my "just enough to get in trouble" pile of knowledge, I remember that sometimes you can use this "sudo" command to bypass not having enough permission to do certain tasks. So let's try...

>sudo yum install mysql

"nolan is not in the sudoers file. This incident will be reported."

Hmm....well, I just built this box few hours ago, and "nolan" was the account I used to do everything else. Maybe this is where I should have typed "sudo su" instead of "sudo"? Nope, that also doesn't work. Though this one does:

> su -
> yum install mysql

Success! Admittedly this is one of those areas where I just sort of "brute force" my way through variations on the "sudo" and "su" command until I find one that works. Like I said, I'm not a Linux guy, and I've never fully understood the detailed specifics of what "sudo" does. (That alone could probably be its own blog post...I could certainly use something to reference in the future when I forget...again...)

MySQL should now be installed, let's double-check...a quick look at the Services control panel, I do indeed see a process called "mysqld", which is MySQL (though again, why it's not called "mysql" is somewhat puzzling...there's probably a really long geeky answer as to why, if I wanted to look it up.) Let's test that MySQL is indeed working:

>mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

Ah...forgot to start the MySQL service. I could go back to the Services GUI and do that, but just for practice, let's try it from a command line:

>service mysqld start
Starting MySQL: [ OK ]

>mysql
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.0.77 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

Success again! We're on a roll! We still have to install Tomcat, not to mention configuring everything, setting up user accounts, etc, but this is a pretty good stopping point. We'll work on that in a different blog entry....

(If there are any experienced Linux guys reading this far, feel free to chime in with feedback on what I did wrong. I'd appreciate any tips you feel like sharing.)

-nolan

Beginning Adventures with CentOS

I'm a full time freelance consultant, and as such I deal with lots of development teams with varying skill sets. One recurring event I've run into is, senior developers that (for whatever reason) don't want to post their questions on a forum or email list. I suspect its because of...

a) laziness (but I don't wanna open another window!) b) stubbornness (I'll fix it myself if it's the last thing i do!) or c) I don't want people "out there" to see me asking such a basic question on the internet, they'll think I don't know anything...which really is ridiculous.

We were ALL junior developers at one point. If you search the BACFUG archives you'll find me asking all kinds of introductory questions. Ask any of the C++ programmers I worked with at my first job and you'll hear several of them say "yeah Nolan had about 100 questions about how pointers and linked lists worked". The same is true of any other senior developers. Besides, nobody knows EVERYthing.

Having been guilty of all 3 myself, I can definitely relate. So in the interest of a) blogging more (one of my resolutions for 2012), and b) eating my own dog food, I'll just come out and say it:

I'm not a Linux guy.

As of a year ago, my Linux experience was about like so:

* I had installed Ubuntu on a desktop at home, to try and wane myself off Windows, and learn something new. It didn't really work -- I still use that Windows box, though mostly for iTunes and gaming. But I have started using the Ubuntu machine as my "main internet surfing" computer.

* I can FTP and Telnet from a Linux terminal and get what I need.

* I took an "Intro to Unix" class in college where we went over vi, bash and korn shell, cron jobs, and a few other odds and ends, some of which I've had to revisit since then, but only sporadically.

* Though I'm quite comfortable with a DOS command line, I've never had to do THAT much at a Linux command prompt.

...there are probably other points I could add to that list, but basically you get the idea. I'm the first to describe my Linux skills as "just enough to get myself in trouble". :)

Over the last 18 months, I've been thrown onto several CentOS projects for clients. And while I'm definitely learning more "Linux stuff", I'd still put myself in that "knows just enough to get in trouble" category. But if I'm in that category, there are probably other people that feel the same way. So why not blog about it?!

Starting today, I'm going to blog my "beginning adventures with CentOS". If you're a mid to senior level Linux guy, these will all bore you to tears. If you're like me, and still trying to make Linux stuff "click", then maybe you'll find these posts of interest.

And away we go....

-nolan

Search

Recent Comments

Naming conventions for database columns
Leeward said: Naming conventions and organization of fields and tables are... [More]

Naming conventions for database columns
Nolan Erck said: @Eden -- I should clarify that part of my post. I don't &quo... [More]

Naming conventions for database columns
Steve W said: I guess I have never had that situation, but I would attempt... [More]

Naming conventions for database columns
Leeward said: Naming conventions and organization of fields and tables are... [More]

Naming conventions for database columns
Nolan Erck said: @Eden -- I should clarify that part of my post. I don't &quo... [More]

Naming conventions for database columns
Steve W said: I guess I have never had that situation, but I would attempt... [More]



BlogCFC was created by Raymond Camden. This blog is running version 5.9.7. Contact Blog Owner