Post subject: Linux Server Help?
Former player
Joined: 3/13/2004
Posts: 1118
Location: Kansai, JAPAN
Hey, I know a lot of the forum users run their own websites (like the one we're all using right now), and I was wondering if anybody out there knew some stuff about setting up a LAMP server. I've been working on this thing for a while and after some initial success (hosting and FTP seem to work) my mail settings are not right and MySQL went from OK to errors. Any advice would be appreciated. For the record, I installed Ubuntu 6.06 from a CD and I'm not using any GUI. Of course, I am frequently reconsidering that latter decision.
Do Not Talk About Feitclub http://www.feitclub.com
Joined: 5/29/2006
Posts: 138
I've set up a few in my time :p What exactly is going wrong?
Former player
Joined: 3/13/2004
Posts: 1118
Location: Kansai, JAPAN
First let me mention that I've been following the step-by-step instructions over at: https://help.ubuntu.com/ubuntu/serverguide/C/index.html The initial setup worked fine - no errors or warning at startup. When I got to the mail settings (specifically Dovecot) things didn't work as the instructions indicated. I couldn't telnet to test the installation, the connection was rejected. Ever since then I've been receiving notices that I have "new mail" although I don't know how to check it. Making matters worse, I now get MySQL errors and I can't use any username/password combo to use mysql or mysqladmin. I took someone's advice to replace 'root' with another user for security reasons but now I can't do anything. I suspect the two problems are related.
Do Not Talk About Feitclub http://www.feitclub.com
Joined: 5/29/2006
Posts: 138
I'm assuming that your probably doing this work on your own private computer? Do you have some sort of firewall/router set up that could be blocking connections on certain ports? For the mysql errors - they are most likely related to the changes you made, although that is good advice to replace root(although good choice of a password makes it less needed). Do you still have the specific commands you used to set everything up (through your shell history or whatever else)? You can * out all the sensitive information. Notices for new mail are probably just linux system mail. Type 'mail' at the command line, and you will probably see the mail there (which may or may not give you any information about why things aren't working).
Emulator Coder, Site Developer, Former player
Joined: 11/6/2004
Posts: 833
The mysqld server has a parameter '--skip-grant-tables' which will start the database server without loading the permission tables. Any user can login with full root access. Good for repairs, so long as you're off the internet. As anubis said, root gets mail from a lot of system resources. Some systems regularly send root mail with select login history logs (ie. trying to become root). Cron the scheduler sends mail for any application that outputs anything when it's run. It's annoying sometimes.
Former player
Joined: 3/13/2004
Posts: 1118
Location: Kansai, JAPAN
Small bit of good news - this afternoon I discovered that the MySQL username/password combo I set up for Wordpress works. However, it does not have root privileges. Let me show you guys all the errors/warnings I get when I start the server.
*Starting kernel log...				[ok]
Starting MTA: exim4.
Starting MySQL database server: mysqld.
/user/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'debian-sys-maint'@'localhost' (using password:YES)'
Starting SASL Authentication Daemon: /usr/bin/mysqladmin: connet to server at 'localhost' failed
error: 'Access denied for user 'debian-sys-maint'@'localhost' (using password:YES)'
saslauthd.
*Starting FTP server: vsftpd			[ok]
Starting mail-server: dovecotWarning: Fixing permissions of /var/run/dovecot to be world-readable
Warning: Corrected permissions for login directory /var/run/dovecot/login.
*Starting RAID monitoring services...		[ok]
I don't even know what that 'debian-sys-maint' user is all about, it's certainly no user I created. Frankly, I'm still a little fuzzy about how to create new users, especially for FTP access. And no, this isn't for my home computer.
Do Not Talk About Feitclub http://www.feitclub.com
Joined: 5/29/2006
Posts: 138
debian-sys-maint would be a username set up by the installer you used that is used to do maintenance stuff. From the looks of it, your whole mysql permissions may be messed up. I would recommend doing what dehacked said. Shut down your mysql server and start it back up with the '--skip-grant-tables' option. Then use mysqladmin to set up everything how you want it. Double-check the debian-sys-maint information and see if you can figure out what it is supposed to be set to. As far as mail server - that warning doesn't seem to be a problem if you only see it once, and the next time you restart the server they go away: http://www.dovecot.org/list/dovecot/2006-August/015063.html . If they stick around, you may need to do some manual permission changing.
Former player
Joined: 3/13/2004
Posts: 1118
Location: Kansai, JAPAN
First of all, thanks for the quick and well-thought out replies. This is a stark contrast to the people at the Ubuntu forums where my request for help in the "Beginner Talk" went unanswered for days on end! I've heard about the '--skip-grant-tables' option but I don't know how to stop mysql in order to restart it. Can any user stop it? Do I need to login to MySQL first, or can I stop it from the shell command prompt? Once I stop and restart, can I recreate the 'root' user? The Dovecot error is consistent, it occurs after every restart. And typing 'mail' (or 'mbox' or 'maildir') returns a 'command not found' error. Yet again, I see I have new mail.
Do Not Talk About Feitclub http://www.feitclub.com
Joined: 5/29/2006
Posts: 138
First I'd make sure that mysqld is running. You can check that by typing
ps ax | grep mysql
You should get some output - if not then your mysql server isn't running. If it is running, then you can restart it by editing the [mysqld] section of /etc/my.cnf (may be /etc/mysql/my.cnf or something else similar) and add the line:
skip-grant-tables
Then restart the mysql daemon:
/etc/init.d/mysqld restart
You should now be able to login without a username or password to perform maintenance. Make sure you remove the skip-grant-tables line from my.cnf when you are finished. Login to mysql and to the database mysql. The following should do it:
 mysql mysql
Now check your user table to see what it does look like:
SELECT * FROM user
You should get a few results back - each with a hostname (or %), a username, and an encrypted password. You can then permissions and whatnot like you see on: http://dev.mysql.com/doc/refman/5.0/en/default-privileges.html As far as system mail is concerned - some research seems to say that new versions of ubuntu (Breezy) don't install the mailx package by default. You can install it yourself(and I would recommend it as it can give you useful information when stuff goes bad). For dovecot, can you give the output of:
ls -ld /var/run/dovecot
Former player
Joined: 3/13/2004
Posts: 1118
Location: Kansai, JAPAN
MySQL is definitely running and your test confirmed that. I edited the my.cnf but when I tried to restart I got this -
$ /etc/init.d/mysqld restart
-bash: /etc/init.d/mysqld: No such file or directory
Your dovecot suggestion returned this -
drwxr-xr-x 3 root root 120 2006-08-16 16:14 /var/run/dovecot
EDIT: Big news - I'm retarded. The user I created in place of root still exists and works, I just had the wrong goddamn password. Anyway, I can get into MySQL now and use your 'select * from users' but it returns a very long, nearly illegible string of information. In the meantime I'll try to read more documentation about this. 2ND EDIT: Getting closer, I hope! I had read a stored password for user 'debian-sys-maint' in a file somewhere and so I decided to try and (re)establish that password in mysql. I entered this command:
mysql>GRANT USAGE ON *.* TO 'debian-sys-maint'@'%' IDENTIFIED BY 'supersecretpassword';
That seems to have solved my startup errors, because I rebooted (only way I know how to restart mysql) and the errors were gone! Let's hope the dovecot situation falls into place as easily.
Do Not Talk About Feitclub http://www.feitclub.com
Joined: 5/29/2006
Posts: 138
Make sure that the skip-grant-tables is out of my.cnf and make sure that everything still works when you restart. If it does, then you should have mysql set up now - w00t. For dovecot, the problem might be that the owner is root although I don't think it would be set up as that if dovecot needed permissions. What I found online seemed to say that the owner/user should be dovecot/dovecot, although I couldn't find too many references to this specific issue. I would recommend trying the following as root:
chown dovecot:dovecot /var/run/dovecot
and see if that fixes anything. If you still get errors switch it back to root using
chown root:root /var/run/dovecot
Former player
Joined: 3/13/2004
Posts: 1118
Location: Kansai, JAPAN
Already removed the 'skip-grant-tables' item, everything seems to work now as far as MySQL is concerned. Mail is another story. I figured I would just start over and reinstall the items one at a time as indicated here: https://help.ubuntu.com/ubuntu/serverguide/C/email-services.html Part of the reason for that was I had neglected to set my mail server at 'mail.mydomain.com', it was actually just 'mydomain.com'. That seemed like a problem worth correcting. After setting up Postfix and SMTP authentication and configuring Saslauthd, everything looked good. Then I tried to test it using telnet (as the page recommends) but I received a 'Name or service not known' error. However, this may be my fault because I didn't previously configure the MX settings at our online registry. If I telnet to 'mydomain.com' I get a response.
Do Not Talk About Feitclub http://www.feitclub.com
Former player
Joined: 3/13/2004
Posts: 1118
Location: Kansai, JAPAN
OK, here's the latest status: mySQL seems good, but mail setup is not going well. I have configured the MX settings and 'mail.mydomain.com' now resolves to my machine. However, the instructions recommend using telnet to test the installation. When I try to telnet to my machine, either by IP address or domain name, I don't get much of a response -
Trying my-ip...
Connected to my-ip.
Escape character is '^]'.
After that it just hangs there, waiting. I can press CTRL+] to get a 'telnet>' prompt, but I can't seem to do anything else. The instructions recommend typing 'ehlo mail.mydomain.com' but 'ehlo' gets an '?Invalid command' error.
Do Not Talk About Feitclub http://www.feitclub.com
Joined: 5/29/2006
Posts: 138
That's because it should be 'helo' not 'ehlo' :p
Former player
Joined: 3/13/2004
Posts: 1118
Location: Kansai, JAPAN
HA...oh, only 'helo' doesn't work either. I tried to install 'telnetd' but that didn't affect anything. Shit, what if the rest of these instructions have typos too?
Do Not Talk About Feitclub http://www.feitclub.com
Joined: 5/29/2006
Posts: 138
I'm thinking that you shouldn't hit ctrl-], but I'm not that sure - haven't used telnet much. If that doesn't work, try using the following:
telnet [your domain ie. domainname.com] 110
HELO [your domain name again ie. DOMAINNAME.COM
And try the above using mail.domainname.com as well. EDIT: http://www.yuki-onna.co.uk/email/smtp.html - look at this too - might help.
Former player
Joined: 3/13/2004
Posts: 1118
Location: Kansai, JAPAN
Like a headless chicken, I am proceeding. I went ahead and reinstalled exim4 and dovecot, and now telnet works. My only guess is that by installing dovecot ealier and then uninstalling it, telnet was somehow left hanging. I now get responses when I telnet my IP address or my domain name, although the responses do not exactly mirror the ones in the guide. Then again, I don't get errors either. As I begin to configure dovecot, can you tell me if I have to choose one format (imap, pop3, etc) in configuration or can I choose them all? The instructions aren't clear at all on this point. EDIT: I just went with the pop3 to be safe, and so far the instructions match. Telnet produced the '+OK Dovecot' response. However, as mentioned the other day, I still get those warnings about dovecot permissions. At this point the next big question is how do I check the mail?
Do Not Talk About Feitclub http://www.feitclub.com
Joined: 5/29/2006
Posts: 138
For the startup problems I would try doing the following, although I'm not sure it will fix it (must be done as root):
chown dovecot:dovecot /var/run/dovecot
If that doesn't get rid of the startup errors, then change it back using:
chown root:root /var/run/dovecot
There are several ways to check your mail. Assuming that your mail server is working correctly, you should be able to connect to it from outlook, evolution, thunderbird, whatever as you would for any other mail account. Just set up your information - in the account settings and test it out - try sending a message to an account that you set up with the mail program, etc. etc. You can also do it the down and dirty way using telnet: http://www.yuki-onna.co.uk/email/pop.html I would only do that if you are having problems with a normal mail program as you can see where things are going wrong if this doesn't work. There are also webmail things you can host on your server (not sure if dovecot comes with a default one or not), that you can configure.
Former player
Joined: 3/13/2004
Posts: 1118
Location: Kansai, JAPAN
I tried your "chown" suggestion but nothing changed - identical warnings occur at startup. Maybe it's no big deal? I was able to send a message and if I go to /var/mail I can view a text file containing mail - various server bulletins along with the test message. This is a good sign. However, the link you mentioned is apparently bad news, because if I telnet in and type 'MAIL FROM whatever' I get a '500 Unrecognized command' error. EDIT: Using Thunderbird I cannot see any mail on the server, although I get no errors. That is, it seems to connect to the mail server and login but it tells me there are no messages there.
Do Not Talk About Feitclub http://www.feitclub.com
Joined: 5/29/2006
Posts: 138
I would suggest installing mailx - that way you can run the command 'mail' from the command line to view your mail. For thunderbird - what happens if you try sending yourself a message using thunderbird, and then checking your mail?
Former player
Joined: 3/13/2004
Posts: 1118
Location: Kansai, JAPAN
Using Thunderbird, I can set 'mail.mydomain.com' as the incoming/outgoing mail server. If I check for new messages, I don't see any. If I mail something to myself from myself, it goes through but I don't see it in Thunderbird. If I try to mail to somebody else, I get an error: 'relay not permitted'. Installed mailx, used it to read/cleanup mail. Tried to reconfig exim4 to solve relay problem, didn't work. Mail from other systems seems to take an unusually long time. Can send messages to others though!
Do Not Talk About Feitclub http://www.feitclub.com
Joined: 5/29/2006
Posts: 138
Gonna have to get some help from someone else - I haven't done too much with mail servers so I'm reaching the end of my knowledge there ;p