This is part of an x10hosting directed series of tutorials that I am writing because I have way too much free time.
This tutorial will teach the Linux newbie to set up a basic LAMP (Linux, Apache, MySQL, PHP) server to start hosting their site on their x10 VPS. At the end of the tutorial the user will have:
- Been familiarized with adding a user
- Shown how to add a user to the sudoers
- Been made aware of yum package manager and how to use it
- Been informed of troubleshooting techniques and getting help from the command line.
- Installed apache, mysql, php, and BIND DNS daemon
- Provided with lots of links for more information on everything that's being discussed :P
Also, this tutorial assumes that you:
- Have no prior experience with the Linux command line.
- Have a VPS account.
- Have installed CentOS 5.5 64 or 32 bit OS template without the Kloxo panel or cPanel.
So after you've installed a fresh copy of CentOS through your control panel you need to log in to the shell using PuTTY, or another shell client, but I recommend PuTTY.
If you're running Linux on your computer, you can run it from the shell there and you would probably already know how to do most of this stuff in this tutorial.
In PuTTY, you'll want to connect to your server, using your server's IP address on port 22.
Log in as root. Enter your root password.
First thing you should do is run:
and let it upgrade any needed packages.
Now that we're updated first thing to do is add a user because logging in as root can be a security flaw and should be avoided. For this example I'm going to be adding and using the user 'joe'.
To add the user type:
This will add the user, joe. Next we need to make sure that we can gain rights to install and update software and make changes to files. To make sure joe can have rights we need to add joe to the sudoers file. To do this, we type:
and this will open up the sudoers file. Now, using the arrow keys to scroll you need to find the line:
Press 'i' to start making changes and underneath that line, add:
press 'esc' and type ':x' to exit vim.
Now that we've added joe to the sudoers file, we need to give him a password to allow him to SSH into the server. To do this we'll use the command, passwd.
And you should see something like this:
Type the password of your choice, if it is a weak password it will let you know. Remember this password, we need it to log into the server as joe. On successfully changing the password, it will tell you. That's all we need to be logged into root for , you can now log out of root by typing 'exit' and log back into your server as joe, using your new password.
Changing password for user joe.
New UNIX password:
Now that we are logged in as joe, we will start adding some programs needed to setup your webserver. Programs are installed using yum. If you want to know more about yum, you can type:
To view the commands and arguments for yum, or:
To view the manual page for yum.
One important thing to note as a new Linux user is that a lot of your answers can be answered by using --help, -h, as an argument for most programs, or by using the man command. Any significant program you'll use has a man page along with it. Reading documentation is very important and it saves you a lot of trouble trying to find out how to use things. You can also use this VERY useful tool to answer a lot of your other questions, and if no answer is found then would be a good time to ask. For Linux related issues, personally I like to use this site. You can either find your answers there, or get your questions answered fairly quickly.
Back to the tutorial...
Now we will install PHP, Apache, and MySQL. To do this we type:
This installs the needed programs to have your basic PHP and MySQL set up. I will go into more detail about configuring these programs in another post.
sudo yum -y install php php-cli php-mysql mysql mysql-server httpd httpd-manual bind
Now we've got our software for hosting installed but our server won't answer and DNS requests made to the server. To solve this problem, we need to configure BIND to answer these requests. Another option (and a good one for the beginner, I might add) is TinyDNS.
If you want to check that everything installed properly, you can visit your VPS's IP in your favorite browser. What should come up is something like this:
Since configuring software is relatively similar for most flavors of Linux I will be writing how to configure these in separate articles. If you find anything in error or false or have anything to add, please message me and let me know and I will make the necessary changes. I will also post the links to those articles when I have written them.