How to Setup a FreeBSD 6 Webserver - FAMP Server

Posted on February 2nd, 2008 in Computers, Servers/Hosting, Unix/Linux, Web | 6 Comments »

Here it is, the meat and potatoes of setting up a FAMP server (FreeBSD 6.3, Apache, MySQL, PHP/Perl). Keep in mind these instructions are exactly what I do step by step to setup a FreeBSD webserver. Originally when I started with FreeBSD I couldn’t find a solid source of reliable information on how to set all this up. Every time I would ask someone for some good instruction I was always directed to www.freebsd.org. I have to tell you it is extremely overwhelming for me at that time to even understand anything off of that site’s directions - as well written as it is.
Over the last few years I have come across some decent walkthroughs and tutorials but 90% of them were still either out dated or lacking 1 or 2 steps that can really jack things up. I have really tried to make this tutorial as straight forward as possible, no BS and no info that’s going to waste your time.

Before I install anything I always make sure I have the latest release of FreeBSD installed with the Developer distribution. Many tutorials out there tell you to install the bare minimum of FreeBSD with the “Minimum” distro, I recommend Developer. If you need a good step by step on how to install FreeBSD (6.2 & 6.3) then click here. Remember, instead of selecting the minimal option on the Distributions screen, choose Developer.

Once you have FreeBSD installed the steps below will show you how to setup and configure a full FAMP server. Good luck!

# cd /usr/ports/lang/php5
# make config
select: Apache
# make install

# cd /usr/ports/lang/php5-extensions
# make config
select: bcmath, bz2, ctype, curl, dom, ftp, gd, gettext, mbstring, mysql, pcre, posix, pdo, session, simplexml, sqlite, xml, zlib (also by default there are many options pre-selected including some of the ones listed here, make sure to leave those checked).
# make install

Usually after everything is done you will notice a few mysql errors appear, run this command:

# pkg_add -r mysql50-server

Now before editing any file on my system I always make a backup of it:
# cp /usr/local/etc/apache/httpd.conf /usr/local/etc/apache/httpd.conf.orig

Now let’s edit your Apache config file to get everything configured properly:
# edit /usr/local/etc/apache/httpd.conf

Change the default listen address to the IP address of your webserver.

#Listen 12.34.56.78:80
To:
#Listen 192.168.1.10:80 (example, use your machines IP Address)

Change the email address of the ServerAdmin to your email address or the address of the person in charge on this server:

#ServerAdmin you@your.address (use your email address)

Change the ServerName option, if you don’t have a fully qualified domain name please change this to the servers IP address:

#ServerName www.example.com
To:
#ServerName 192.168.1.10 (example, use your machines IP Address - for internal, intranet implementations)
Or:
#ServerName www.peter-v.com (example, use your domain name if you have one and your going to point DNS to that machine)

# Add a DirectoryIndex option:
DirectoryIndex index.php index.html index.htm index.php3 index.php4

# In the AddType section add the following for PHP:
AddType application/x-httpd-php .php .htm .html
AddType application/x-httpd-php-source .phps

Now exit and save, your all done with Apache.

# echo ‘/usr/local/sbin/apachectl start’ >> /etc/rc.local

Now let’s configure MySQL:

# cp /usr/local/share/mysql/my-medium.cnf /etc/my.cnf
# echo ‘mysql_enable=”YES”‘ >> /etc/rc.conf

# /usr/local/bin/mysql_install_db
# chown -R mysql:mysql /var/db/mysql
# /usr/local/share/mysql/mysql.server start

If the command: # /usr/local/share/mysql/mysql.server start doesn’t work or fails, try this command:
# /usr/local/etc/rc.d/mysql-server.sh start

# /usr/local/bin/mysqladmin -u root -h Hostname.domainname.tld password ‘YourPassword’
# /usr/local/bin/mysqladmin -u root password ‘YourPassword’

Example:

# /usr/local/bin/mysqladmin -u root -h webserver.peter-v.com password ’secret’
# /usr/local/bin/mysqladmin -u root password ’secret’

Now let’s install Perl DBI and DBD Support (which many apps need that run using Apache and MySQL):

# cd /usr/ports/databases/p5-DBI && make install && make clean
# cd /usr/ports/databases/p5-DBD-mysql50 && make install && make clean

Reboot.

That’s it, your all done and now you’ve got yourself a FAMP Webserver.

Tips:

If at anytime in this tutorial a command doesn’t work, try rebooting first. Sometimes after installing certain applications or components it is required to reboot before being able to utilize it. After a quick reboot it always works.

I would love to hear your comments and if you have any suggestions or issues with this tutorial please leave a comment, thanks!

FreeBSD

Unlock Secret “root” Administrator Account in Windows Vista

Posted on October 11th, 2007 in Computers | No Comments »

Much like the root “super user” of Unix, Microsoft’s Windows Vista has a secret “master” administrator account which is disabled by default. The “master” administrator account in Vista gives all rights/permissions or total control over your OS; this is great for a Systems Administrator but not for the normal user or power user.

Just like in Unix, it is highly recommended that you run applications, services, and general interactions with Unix as a regular user. When your interactions within Unix require a raised level of authority you can run the command: #sudo su followed by your password. Vista has followed this almost exactly and I am sure you’ve seen this several times like when you install an application, run certain programs, or change system settings windows will display a UAC popup requiring you to accept your actions before you can continue. This “master” administrator account is the equivilant root or super user of Unix.

To unlock the secret administrator account in Windows Vista, follow these steps:

Start> type cmd in the search box> right-click on cmd.exe> select Run as Administrator> type: Net user administrator /active:yes then press enter. Now the next time you log in you will see the ”master” administrator account, which BTW is unprotected so I strongly suggest you set a password (click here for a great password generator). Now if you want to disable the administrator account just follow the same steps above but change the active:yes to active:no (Net user administrator /active:no).

Computers and Me

Posted on October 8th, 2007 in Computers, Personal | 2 Comments »

I have been into computers for over 14 years and professionally for over 8 years. Back when I was 8 years old I got my first computer which was an Intel 286 running Microsoft DOS and came with a few games. This computer weighed like 30 lbs. and was the bad ass of computers when it came out, probably costing upwards of $2k. Ever since that early Christmas morning I was glued to that computer, playing games, navigating through MS DOS, and secretly opening the case to see what was inside.

It wasn’t to long after that when I screwed something up and my parents had to call out a computer guy to fix it. Every time I broke the computer (which was quite often) the tech would come out to fix it and I would watch him like a hawk to see what he did to troubleshoot the problem and how he ended up resolving the issues. As time passed and it was time to upgrade I would watch the computer guy open the box, pull out old drives and throw in new ones. I was so fascinated by this that I started doing it by myself. I actually remember one night I completely disassembled the computer and timed myself to see how long it would take me to put it all together and install DOS on the freshly formatted drives.

My next computer was an Acer 386 laptop, the computer I installed Windows 3.1 on! The computer guy was at our place regularly now, not only was I doing the same stuff before (I can’t believe I was taking apart laptops) but now I was totally digging into the very unstable Microsoft Windows 3.1! This is where I (and the rest of the computer enthusiast world) learn all the cool things you could do with Windows like opening a program being presented with a bluescreen, just because it felt like it. I think this is where I started acquiring a temper and a thing for punching my monitor. I was so used to being the cause of all my computer problems that I think I was getting a bit jealous, my futuristic computer can screw itself up and I won’t know what the cause was!!

At the age of 11, now living in Athens, Greece, my brother sends me one of his brand new computers from his office… a 486SX!! Holy crap was this thing fast; it had 2MB ram, a big 100MB hard drive, a sound card, and a frickin TURBO BUTTON! This is where I really got into both hardware and software, I remember visiting my brothers office in Phoenix, AZ, taking RAM chips out of a few other office computers and popping them into mine. At one point that computer had a whopping 8MB RAM and a LAN card.

At this time I became fascinated with networks, programming in Q-Basic, and the internet. When I was 13 we had moved back to the United States and I stumbled on this internet program called Imagination (INN). This thing was the coolest online community I had ever seen! It was a 3D world, basically a graphical map of a imaginary town that you could click on to go to different parts of the internet. One building would take you to chat rooms, another for games, and one even to meet people to have sex with, LOL.

Imagination

After Imagination came AOL which for me came hacking. Back when AOL was just a baby I used to make free accounts, spam chat rooms, kick people, ban people, and hit their servers so hard that it would shut them down for short periods of time. I ended up writing a piece of software that people could use to generate free accounts for AOL, which at that time sold for $30 and only lasted a few weeks, until my parents caught me.

I became very bored with AOL at this point and I moved on to mIRC chat rooms, hosting my own warez channels and using my computer (a pentium III) as a warez database. As illegal as this was I also learned a lot about more advanced applications from companies like Adobe, Macromedia, Microsoft, and etc… I also learned a ton about the internet and networking, more on the hosting side using DNS and Unix. At one point my parents got me my own phone line which I used specifically to host my own IRC server running a flavor of Unix, just for warez and the power of kicking and banning people when I felt like it.

I guess I got really tired of stealing applications and trading them and more interested in networking and the advancements Microsoft was making with Windows NT 3.51. Fortunately for me my brother’s company was growing fast and at that point had a ton of computers and servers running Windows NT, Microsoft Back Office and Microsoft Octopus. He also has a computer guy who was awesome and always open to have me hovering over him when he built and configured these massive servers and desktops. I am not sure if he still owns his own company, which at this point was from home, but his name was Tom Stone and his company was called Hard and Soft Answers. I owe a ton of my knowledge to Tom and his employees.

A year or two passes and my brother acquires a very large title company in Arizona. This time I get to work for the company and learn from a guy named Ron. Ron planned and built out the entire network, both computers and servers. I learn a lot about troubleshooting desktops and servers running Windows NT4.0; this was also the first time I ever saw a mini server which I thought was pretty huge. I learned in-depth about networking and server configurations and the new active directory (which back then I think was called something else). Another year passes and my brother sells the company to Continental Homes which is a huge company with tons of computer techs run by a MIS.

The MIS took me under his wing for a few days in their NOC and showed me the ropes. Here I learned a lot about TCP/IP, load balancing, disaster recovery, server configuration and implementation, and much more. The information I learn in this short amount of time was overwhelming but has stuck with me forever. I was pulling and terminating CAT3, configuring routers and switches, and learning about what all of this meant.

After leaving my brother’s company I went off into the real world and started working for companies like Discount Tire Corporate, a real estate company, a couple financial firms, and a telecommunication company. I have been blessed with an real life education and experiences that cannot be beat, above all they were all free!

I guess the part that gets me when I think back to my life with computers and networking is that I never stepped into a classroom to learn about this stuff, I learned it by doing it on my own and having people help me along the way. I have always had a drive to learn new things and especially new technologies and all of this now puts food in my child’s mouth and lights the house for my wife to relax in. Now I spend my time doing what I love for a living and giving my son the same opportunities I had to learn and grow.

My son is 3 now and for the last 7 months he has been turning on the computer, opening the internet browser, going to his favorite website (The Little Einsteins) to play his favorite games and watch his favorite movies. Niko (my son) is doing now what I did when I was around 13 or 14 years old (minus the illegal junk), I can’t imagine what he will be doing with computers and the internet when he is 13, or when he is my age…

I owe a lot to my brother John for providing me with my first computer and the experiences of working for his companies, placing me with the cream of the crop computer guys who were willing (or forced) to teach me. I owe a lot to my parents for spending way to much money to have computer guys come out weekly (sometimes daily) to fix my computer. I owe a lot to my wife and my son for allowing me the time to continue with my passion and my need for higher learning, it takes a very loving and understanding wife to go to sleep alone many nights so I can learn new things and expand my horizons.

I thank my current employer for paying a kid with just a high school education as much as they do.

;)