How to install postfix to relay mail through gmail in Ubuntu

Recommended Ubuntu book

Once I got my svnmanager working on Ubuntu, I still had problems sending mail. I pointed the domain mx record to the right direction, but for some reason my port 25 was refusing connections. So I decided to relay the mail through my gmail account.

First, install postfix if you haven’t already:


sudo apt-get install postfix

Now, to set up postfix, make sure that you have these files:

/etc/postfix/main.cf

/etc/postfix/generic

/etc/postfix/generic.db

/etc/postfix/sasl/passwd

/etc/postfix/sasl/passwd.db

which you can create via touch command like:

 

cd /etc/postfix
sudo touch generic

Next, edit /etc/postfix/main.cf (via command: sudo gedit /etc/postfix/main.cf), here is mine

# See /usr/share/postfix/main.cf.dist for a commented, more complete version


# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

#readme_directory = no

# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

myhostname = localhost
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
#myorigin = /etc/mailname
mydestination = my-ubuntu, localhost.localdomain, localhost
relayhost = [smtp.gmail.com]:587
mynetworks = 127.0.0.0/8
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = loopback-only
inet_protocols = all

##########################################
##### non debconf entries start here #####

##### client TLS parameters #####
smtp_tls_loglevel=1
smtp_tls_security_level=encrypt
smtp_sasl_auth_enable=yes
smtp_sasl_password_maps=hash:/etc/postfix/sasl/passwd
smtp_sasl_security_options = noanonymous

##### map username@localhost to username@gmail.com #####
smtp_generic_maps=hash:/etc/postfix/generic

Next, edit /etc/postfix/generic


sudo gedit /etc/postfix/generic

and have replace user_name and email_address with your credentials, add all users that may send email through gmail:


user_name@localhost email_address@gmail.com
root@localhost email_address@gmail.com
svnmanager@192.168.1.5 email_address@gmail.com

Now lets generate generic.db from this file:


cd /etc/postfix
sudo postmap generic

Next, lets add your gmail credentials to password file:


cd /etc/postfix/sasl
sudo gedit passwd

Copy this, replace email_address with your gmail email username and gmail_password with your gmail password:


[smtp.gmail.com]:587 email_address@gmail.com:gmail_password

Save the file, lets generate passwd.db now:


cd /etc/postfix/sasl
sudo postmap passwd
chown root.root passwd passwd.db
chmod 600 passwd passwd.db

Restast postfix:


/etc/init.d/postfix restart

Test (replace user_name with your user name):


echo 'test email' | mail -s 'just a test' email_address@gmail.com
sudo sendmail -bv user_name
sudo sendmail -bv email_address@gmail.com

You should receive the email now, sent from your localhost.

If there are any problems, check you /var/log/mail.log

How to install svn for apache and svnmanager on Ubuntu

Recommended Ubuntu book

This tutorial will guide through installation of subversion on Ubuntu to work with apache, and then installing svnmanager. Svnmanager is a handy tool that lets you manage the users and repositories through the web interface. Before we begin, make sure you have a lamp server setup on Ubuntu.

First, lets install subversion and apache library:


sudo apt-get install subversion libapache2-svn

Lets create the directories in which svn repositories and configurations will reside and give apache access to them:


cd /srv
sudo mkdir svn
sudo mkdir svnconfig
cd svn
sudo mkdir repos
sudo chown -R www-data.www-data /srv/svnconfig /srv/svn

Next, we need to set up apache and allow access to subversion repository:


sudo gedit /etc/apache2/mods-enabled/dav_svn.conf

Uncomment the lines like below, file names will be created at a later stage by svnmanager:

 

<location /svn>
# Uncomment this to enable the repository
DAV svn

# Alternatively, use SVNParentPath if you have multiple repositories under
# under a single directory (/var/lib/svn/repo1, /var/lib/svn/repo2, ...).
# You need either SVNPath and SVNParentPath, but not both.
SVNParentPath /srv/svn/repos

# Basic Authentication is repository-wide. It is not secure unless
# you are using https. See the 'htpasswd' command to create and
# manage the password file - and the documentation for the
# 'auth_basic' and 'authn_file' modules, which you will need for this
# (enable them with 'a2enmod').
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /srv/svn/htpasswd

# The following three lines allow anonymous read, but make
# committers authenticate themselves. It requires the 'authz_user'
# module (enable it with 'a2enmod').
Require valid-user

# To enable authorization via mod_authz_svn
AuthzSVNAccessFile /srv/svn/accessfile

</location>

 

Lets restart Apache:


sudo /etc/init.d/apache2 restart

Now lets create a new user in MySql for svnmanager. Get to mysql client using this command:


sudo mysql -u root -p

Type in your password and execute this mysql command:


CREATE DATABASE svnmanager;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER on svnmanager.* to svnmanager identified by 'password';
FLUSH PRIVILEGES;

Where password should be replaced by your password.

Next, if you followed my tutorial on installing lamp, you may need to add php-pear as it was not added previously. Got to the terminal and type:


sudo apt-get install php-pear

Next, lets install the pear VersionControl_SVN module, type:


sudo pear install -f -o VersionControl_SVN

Now we are ready to install SVNManager. Download the latest package, I’ll get mine from http://svnmanager.org, at the time of writing the latest is 1.08. The file itself is at http://prdownloads.sourceforge.net/svnmanager/svnmanager-1.08.tar.gz I am going to download the tar.gz one in my Apache web directory which is /var/www/ :


cd /var/www/
sudo wget http://prdownloads.sourceforge.net/svnmanager/svnmanager-1.08.tar.gz

Now lets untar (Ubuntu tar tutorial) it:


sudo tar xzf svnmanager-1.08.tar.gz

I will rename the folder for convenience:


sudo mv svnmanager-1.08 svnmanager

Now the fun part, lets copy and open the configuration file:


cd svnmanager
sudo cp config.php.linux config.php
sudo gedit config.php

Here you can start changing the language and htpasswd locations if you need. Since I have default installation and everything seems correct, I move to the next lines for svn locations:


$svn_config_dir = "/srv/svnconfig";
$svn_repos_loc = "/srv/svn/repos";
$svn_passwd_file = "/srv/svn/htpasswd";
$svn_access_file = "/srv/svn/accessfile";
$svn_trash_loc = "/srv/svn/trash";

Now if you have smtp server, you need to specify it in order for email notifications to function, which is a pretty nice feature in svnmanger. To intall smtp server just for the sake of experiment, you can just type ‘sudo apt-get install postfix’ and leave it with no configuration option. You can reconfigure it later with ‘sudo dpkg-reconfigure postfix’.


$smtp_server = "yoursmatpserverurl";

Next, database configuration, replace ‘yourpassword’ with password you made for svnmanager user:


$dsn = "mysqli://svnmanager:yourpassword@localhost/svnmanager";

Now save the file and restart Apache:


sudo /etc/init.d/apache2 restart

Go to http://localhost/svnmanager/ and you should see the message that the tables have been created. Reload the page and login with ‘admin’ ‘admin’, which we left untouched in the configuration file. Don’t worry, once you login and create admin user, config credentials will not work. Go to create your new user, set him as admin and type ‘admin’ in the lowest ‘password’ box, which is your current default password.

You are now set with SVNManager, which, I believe, significantly helps to manage multiple users and repositories.

Phew, took me forever to write this post as I was installing svn and svnmanager at the same time. Please let me know how it works for you. 🙂

Update: once you create a repository, try to access it in browser at http://localhost/svn/your_repository_name/ . If it shows 500 Internal Server Error, you may have to go back and edit /etc/apache2/mods-available/dav_svn.conf and change the line AuthUserFile to:

AuthUserFile /srv/svn/passwdfile

since the file htpasswd may not exist and cause this error to happen. Just checked my apache logs and this was the problem.

 

Another update: I did a postfix install on Ubuntu to send mail and updates to repositories to the needed users (handy feature). However, I had problems with svnmanager sending the mail. I checked my /var/log/mail.log and was getting:

Aug 26 13:02:00 my-ubuntu postfix/smtpd[13809]: connect from localhost[127.0.0.1]
Aug 26 13:02:00 my-ubuntu postfix/smtpd[13809]: warning: Illegal address syntax from localhost[127.0.0.1] in MAIL command: 
Aug 26 13:02:00 my-ubuntu postfix/smtpd[13809]: lost connection after RSET from localhost[127.0.0.1]
Aug 26 13:02:00 my-ubuntu postfix/smtpd[13809]: disconnect from localhost[127.0.0.1]

The problem seemed to be that my hostname was an ip address, which needs to be in square brackets like svnmanager@[192.168.1.5]. Then I edited the mail functionality:

/var/www/svnmanager/svnmanager/UserModule$ sudo gedit InvitePage.php

where you can edit $mail->From = “svnmanager@[$servername]”; by adding those square brackets. Also, you can edit the $message if needed.
Also, may need to edit InviteManagePage.php in the same folder to suit your needs.

How to install apache, php, mysql and phpmyadmin in Ubuntu

Recommended Ubuntu book

Installing LAMP (Linux, Apache, Mysql, Php) in Ubuntu is pretty easy. Follow the following steps.

 

Open the terminal window and type:


sudo apt-get install apache2

This would install apache, which you could test by typing http://localhost/ in the browser. It will give you a successful message if it works.


sudo apt-get install php5 libapache2-mod-php5

This would install the latest stable version of php5 and apache mod. Now lets create a sample php file to see if it works:


sudo gedit /var/www/phpinfo.php

Once the new gedit window opens, type:


<?php phpinfo(); ?>

Save the file and restart apache for php to kick in:


sudo /etc/init.d/apache2 restart

Now go to http://localhost/phpinfo.php in the browser and it should show all the php settings.

We still need mysql, these commands will install it:


sudo apt-get install mysql-server

Next, we need apache mode, php5-mysql and phpmyadmin (if you want, it gets pretty handy):


sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin

Next, enable mysql in for php by editing php.ini file:


sudo gedit /etc/php5/apache2/php.ini

and uncomment the line


;extension=msql.so

by removing ‘;’ symbol in the beginning. Save the file and restart apache again:


sudo /etc/init.d/apache2 restart

Now navigate to http://localhost/phpmyadmin in your browser to start setting up the databases.

That’s it.

Using tar in Ubuntu

Recommended Ubuntu book

tar is pretty common command for archiving the files in Linux. It is pretty much the same across the distributions. You can type in the commands listed below in the Ubuntu terminal window.

Of course you can do:
man tar

and see all the flags and how to use, but hopefully this post will save you the effort.

To create an archive I usually do:
tar czf directory_name.tar.gz directory_name/

where “c” means create, “z” for gzip compression and “f” for file.

You can also do:
tar cjf directory_name.tar.bz2 directory_name/

for bzip compression or just:
tar cf directory_name.tar directory_name/

for a regular .tar

Basically, we specify the command with flags, type a file name that we want to create and pick a directory or file that we want to add to archive. These commands create an archive leaving the directory untouched.

 

Similarly, we extract these types of files using the “x” flag like this:
tar xf directory_name.tar
tar xzf directory_name.tar.gz
tar xjf directory_name.tar.bz2

That’s it.

How to use windows key to open Start menu in Ubuntu

Recommended Ubuntu book

The default short cut to open the “Start” panel in Ubuntu is “Alt+F1”, however you may wish to change it to the windows key. If you want to change it to something other than windows key, a combination of keys for instance, you would go to System > Preferences > Keyboard Shortcuts and click on “Show the panel’s main menu”, then, once selected just press they keys you want to use.

However, it doesn’t seem to do anything when you press the windows special key. In order to use it, you would have to open the terminal window or Run Application window (Alt+F2 by default) and execute this command:


gconftool-2 --set /apps/metacity/global_keybindings/panel_main_menu --type string "Super_L"

where Super L is the left “Super” key, which is left windows key.

How to open .rar files in Ubuntu

Recommended Ubuntu book

You need to install unrar to open .rar files in Ubuntu. It’s pretty easy, just open a terminal and type:


sudo apt-get install unrar

Now either double click the .rar file in GUI or right click -> Extract here. You can also type the following command in terminal:


unrar x /path_to_file/file_name.rar

How to update ati drivers on Ubuntu

Recommended Ubuntu book

Yes, you can go to hardware center and just pick the drivers ubuntu finds for you. I just tend to like manually installing Catalyst from ati. To do so, go to http://support.amd.com/us/gpudownload/Pages/index.aspx and download the drivers for your graphic card. Then save it, go to the folder in terminal and type:

sudo sh ati<tab>

<tab> meaning press the tab key to autocomplete the file name since I am not sure which version you got. 🙂 Now you should have the latest version of Catalyst and drivers running on your system. Got to love ATI for Ubuntu. Worked perfectly for my radeon hd 4870.

Now if you want to configure it, open terminal window and type:

aticonfig

Good luck.

 

 

 

 

Unable to successfully install Ubuntu on nvidia geforce 8200

Recommended Ubuntu book

So, just an update to previous post regarding ubuntu screen flickering, I was not able to completely get rid of flickering after 5 hours of trying. I tried a dozen of solutions after searching all over Ubuntu forums and none of them resolved it for me. I gave up.

In the end I just plugged in my ati radeon hd 4870 and it worked like a charm from start. I ended up updating the drivers manually from ATI and it works even better now.

How to use apt-get

Recommended Ubuntu book

apt-get (apt stands for advanced packaging tool) is used to install the packages on your system.

To install a package use (in terminal):

sudo apt-get install <packagename>

To remove:

sudo apt-get remove <packagename>

where <packagename> is the name of the package you need to install.

Once I install the new Ubuntu, I usually do:

sudo apt-get update

and

sudo apt-get upgrade

which updates the local package list and upgrades to the latest versions from Ubuntu repositories.

You can also upgrade the entire distribution of your Ubuntu by typing:

sudo apt-get dist-upgrade

if you need more information, type

sudo apt-get help

 

Ubuntu 11.04 Screen Flickering During Installation

Recommended Ubuntu book

Tried to install Ubuntu 11.04 on my other computer today and ran into a ton of problems.  Once I inserted a CD and started to install, I couldn’t even get to the main menu. The purple screen just kept on flickering so much that I couldn’t see anything. I am still battling with it, but I got it to install. Right now I am trying to update the drivers for nvidia geforce 8200 which seem to be the problem.

Anyway,I was able to get the flickering down to the extent where I could at least see the installation screen and progress. It still flickered a little, but not as much. Here is what I had to do:

1) Press “Shift button” while it loads from the cd – it should give you configuration screen.

2) Press F6 for additional options and select “nomodeset” option.

3) Pick Install Ubuntu and you should be good to go.

As far as I can tell, your graphic card drivers are not supported if you run into this problem. Hope this will help you to install Ubuntu and get into the next phase of configuration. 🙂