Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to try to setting up a headless (terminal-only) Ubuntu Linux server, and am trying to find resources to get started. I've been a GUI Linux/Windows user for a while now, and have run through a tutorial to setup a server on an Ubuntu desktop (with the GUI), but the biggest hurtle I found was when I tried to only use the terminal. Ultimately I want to try to setup a web server and host personal content (personal website, or possibly a personal Confluence site). On the server I'd also like to setup a database (postgres / mysql), I wouldn't shy away from some experience with Samba as well. I've gone far enough to enable ssh on a server so I can ssh in, but am pretty much a beginner from there.

Problems I encountered with my only attempt at running a headless server: I think I installed mysql (with apt-get), but didn't grasp almost anything after that, such as how to get the database service to start with the server on server restart, how to check that it did install correctly, or even how to make sure it was running without access to a visual process manager.

Is there a tutorial someone would recommend specifically aimed at people with discomfort with a Linux server, and particularly using a terminal-only interface?

share|improve this question
    
I'm aware of some of the basic linux commands, can CD around, make/delete files/folders, can do basic greps. I am aware of ps and top, but dont know how to use them very effectively. Am mystified with how to check ports. –  Brian Aug 19 '11 at 17:28
    
You are aware that if you have an X11 server running on your own computer, you can use ssh X11-forwarding to let graphic programs display on your own computer? –  Thorbjørn Ravn Andersen Aug 19 '11 at 17:32
    
Also have some knowledge of sudo for super user rights. Somewhat aware of the apt repository (apt-get update, upgrade, install). –  Brian Aug 19 '11 at 17:38
1  
@Thorbjørn Ravn Andersen I've heard about X11 but only the name. That would be excellent!! Is that standard practice for people to use when interfacing with headless servers? I'd like to become slightly better at terminal-interface, but if people just install X11 (same as X-Windows?), I'd like to learn to do that too! –  Brian Aug 19 '11 at 17:42
1  
@Brian, about your comment on using ps effectively, I usually do ps -ef | grep name where name is a process I want info on. –  MaxMackie Aug 19 '11 at 18:05
show 2 more comments

migrated from programmers.stackexchange.com Aug 19 '11 at 17:38

This question came from our site for professional programmers interested in conceptual questions about software development.

3 Answers

up vote 2 down vote accepted

First, I'm going to define some things for you so you get a feel for what application is doing what when it comes to web servers.

Apache is an HTTP web server and allows you to serve static HTML and text files "like the Internet". Your web server will take care of inbound requests and all the other stuff you don't really want to have to take care of. Usually, once it is installed, you can go into the htdocs directory and place some files. These files will be available to you if you point your browser to localhost (assuming you've used Apache defaults for which port to run off of, default is 80). This is all you need for a basic website.

You might also want to consider building Apache with support for PHP. PHP is a scripting language used heavily in websites to deliver dynamic content and "spice" up otherwise static html files.

Once you have PHP and Apache working together, consider using a database (MySQL for example) to help store your data. Databases are required by most web software (Wordpress and forums come to mind) and isn't too hard to set up. MySQL has a nice interface called PHPMyAdmin which can be installed on your server and allow you to browse your database from your browser (don't worry, there is a login). The only time you will probably have to interface with MySQL using the command line, is if you want to restart it using kill.

Put all this on a Linux box, and you've created a LAMP server (Linux, Apache, MySQL, PHP).

Forgive me if you already knew all this stuff, I just figured I'd lay down a good foundation of terms for you seeing as you seem new to a Linux/server stuff.


To answer you actual question, I see two possible options.

1- Stream X11 to your workstation. If you're on Windows, you'll need something like Exceed and on your server you'll need to set your DISPLAY environment variable to your computer's hostname like this:

export DISPLAY=you_host_name_here:0.0

This way you'll be able to open up GUI applications on your server but have the windows display on your workstation. However, I don't think this is what you'll benefit from most.

2- Get comfortable with the terminal. This is something you will have to do in a Linux world whether you like it or not :) It's good that you know your way around the filesystem (cd, ls, mkdir, etc). But for serving web content (.html or .php files), you'll need to be comfortable with a terminal based text editor. I use vi, which has a steep learning curve but is very powerful. Alternatives are nano, emacs and pico (there are of course others). Being able to use an editor will allow you to make changes to files without needed to deal with X forwarded GUIs and stuff like that.

One final note, you've installed a lot of applications using a package manager. Have you ever tried building an application from source? I tend to build things myself because I feel I have more control on where things are installed and with what compatibilities. In Apache's case, you'll need to compile with support for PHP and MySQL. This may seem like a lot to chew, but I assure you it's really quite simple and it's a great tool to have when working with Linux or UNIX.

share|improve this answer
    
Agh, thanks Max! You knew what I meant (I am familiar with LAMP, though have only ever worked mostly on Windows's XAMPP). I am familiar with PHP, and have programmed a few smaller scale web applications with it. I have used VIM a bit, but cringe at it the same way I cringe at using the terminal, and probably for the same reason (unfamiliarity). –  Brian Aug 19 '11 at 19:58
    
Any tutorials you would recommend for downloading/building each component of the Apache/MySql/PHP stack? Speaking of which, how do you download things from the terminal w/o a GUI/web browser? I pretty much just downloaded things on my client computer and dropped them in a shared directory and ran from there. –  Brian Aug 19 '11 at 20:00
    
Glad to know you have a good brace on web server stuff. I know of two tools to download files from the net using a terminal: wget and curl. Google those, chances are they are installed on your box. I'm currently looking for some good tutorials for someone new to the terminal (you are using bash right?). –  MaxMackie Aug 19 '11 at 20:31
add comment

Read the book Nginx HTTP Server

It is a particularly good text for beginners -- first chapters explain everything you need to know to get started with Linux, and more.

Plus you'll learn setting up a very good server Nginx -- which is catching on these days.

share|improve this answer
    
Neat-o, I'll check it out. What sets Nginx apart from other distros? –  Brian Aug 19 '11 at 17:40
2  
@Brian: From what I can see, Nginx is not a distro in itself. It is a websever platform (like Apache, which I'm assuming is what you're trying to run now). –  MaxMackie Aug 19 '11 at 18:07
add comment

Your question is composed of tons of subquestions that probably should be asked individually. However, for your specific question of how to know if mysql is running:

I'd suggest htop (sudo apt-get install htop) to monitor processes/RAM usage/kill tasks, in the generic case. Its like top but much better.

For the specific case of seeing if your server is running, look at sudo /etc/init.d/service_name command, where service is mysql/apache2/nginx/postgresql/ssh/ufw. (type ls /etc/init.d to see a more complete list) and command is one of start/stop/restart/status. Some other services should be monitored via sudo service service_name command. So in this case sudo service mysql status should tell you if mysql is running.

To setup/configure your database, read various tutorials online, buy a book. Personally, if you do not need a very advanced database, I'd suggest a simpler db like sqlite. It's much simpler to set up and use then a full fledged database suite like postgresql/mysql/oracle. Remember properly tuned databases are not trivial to setup and administer; that's why DB administrator is often a full time job. See: http://www.sqlite.org/whentouse.html to decide if sqlite isn't powerful enough.

share|improve this answer
2  
HTOP! Amazing!!! I'll try the rest of these suggestions out soon! I cant wait to get started. :) –  Brian Aug 19 '11 at 20:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.