LiteSpeed WebServer on Slicehost VPS
What is VPS ?
A virtual private server (VPS, also referred to as Virtual Dedicated Server or VDS) is a method of splitting a server. Each virtual server can run its own full-fledged operating system, and each server can be independently rebooted.
The practice of partitioning a single server so that it appears as multiple servers has long been common practice in mainframe computers, but has seen a resurgence lately with the development of virtualization software and technologies for other architectures.
What are the benefits of using VPS ?
It is faster that shared hosting, so putting this to simple words your websites will work & load faster with VPS. You will have full control of your system plus many other benefits.
My hosting history
I start with cheap shared hosting but after sometime I moved all my sites to VPS. I was testing many companies for long time but from almost 2 years I am using slicehost and I am pretty happy with them.
In this post I try to show you howto setup good VPS hosting server and use it for your websites. It was written by my friend Dru who helped me setup my VPS and I think it will be a good howto for all of you.
- VPS Hosting Company: Slicehost
- WebServer: LiteSpeed
When I am starting new project, website I need to create couple of things:
1. Create user
a.) create a user using webmin
- Click on System in the sidebar, then on users and groups
- Click on create new user
- for the username ALWAYS use the domain name for the name of the user. So in this case: example.org do the same for the group (choose new group and name it the same way – THIS IS VERY IMPORTANT)
- then click save
When you create the user in webmin there should be a field where you can set the group, that will let you pick the www-data group before you create the user.
b.) shell method (i prefered this method)
I use this one: adduser username –ingroup www-data –force-badname
where username = whatever you want the user to be called, ie
adduser example.org –ingroup www-data –force-badname
2. Create LiteSpeed folders
Now you need to FTP in (don’t use ssh or sftp it has to be ftp). (use the server ip, the username will be whatever you called the user and the password will be whatever you configured)
Once you’ve done that create the following folders: config public_html cgi-bin
3. New site in LiteSpeed
Login to litespeed http://your_IP/index.php (user: **** password: ****)
Go to configuration, then virtualhost templates.
Click on PHP_SuEXEC
Where it says Member Virtual Hosts click the add link to the right of it, then fill in the following:
- virtualhost name – should be the domain name (example.org)
- domain name – should be the same as the above
- aliases – should be the same as the above except with www. at the start (www.example.org)
- virtualhost root – Leave Blank
Save, and then go to actions and graceful restart to restart the webserver.
FTP your files into the public_html folder and you should be able to access them in your browser.
4. Importing Databases
when you move website between hostings
First create a blank database with phpmyadmin.
Then in the commandline, navigate to the folder where the sql file is. Then do this command:
mysql -u user -p user_dbname < file.sql
where dbname = name of the blank database
where file.sql = the SQL file you're importing.
It will ask you for the root password and then in a few seconds it'll be done.
5. BONUS TIPS & TRICKS
a.) How to move files when migrating to new server ?
On old server backup files with tar, you use one command line to backup all files to one tar or tar.gz file.
Put this file in public_html folder on this server. Next go to new server and:
Next untar the files to proper place and that is it.
b.) Problem with file permissions
Sometimes when i move files from one server to another i got problems with file permissions on new server. To fix I use this method:
and then do
chown -R example.org:www-data public_html
chmod 770 -R public_html.
c.) MySQL problem with coding, default charset
Sometimes i got problem (WordPress UTF-8 Charset Woes) with coding in sql base, there was strange coding problems in text and i need to fix that. I use this solution:
$ mysql –user=frog -p –execute=”DROP DATABASE dbname;
CREATE DATABASE dbname CHARACTER SET utf8 COLLATE utf8_general_ci;”
$ mysql –user=frog –max_allowed_packet=16M -p –default-character-set=utf8 dbname < dump_utf8.sql
and it works for me..
To find more about this one look here: Convert latin1 to UTF-8 in MySQL
So good luck with great hosting Slicehost and webserver LiteSpeed, for me it works really great for almost 2 years now!