Mail relay host in sendmail

I wanted sendmail on my Ubuntu server to relay all outgoing e-mails to one specific server, this is what i did.

Install sendmail
# sudo aptitude install sendmail -y

Confiure sendmail
# sudo nano /etc/mail/sendmail.cf

Edit the “Smart” relay host.
DSmyrelayserver.domain.com

Restart sendmail
# sudo /etc/init.d/sendmail restart

phpMyAdmin tracking problem

After installing phpMyAdmin 3.3.2deb1 on a Ubuntu 10.04 server with MySQL 5.1.41 I got this error massage when logging on to phpMyAdmin:
The additional features for working with linked tables have been deactivated. To find out why click here.

$cfg[‘Servers’][$i][‘tracking’] … not OK [ Documentation ] Tracking: Disabled

I sloved this by editing /etc/phpmyadmin/config.inc.php and added
$cfg[‘Servers’][$i][‘tracking’] = ‘pma_tracking’;
to the $cfg[‘Servers’][$i] section

Import database larger then 2mb via phpMyAdmin

To import databases larger then 2MB you need to edit /etc/php5/<flavour>/php.ini.

Edit the existing parameters in  php.ini, if they does not exists add them at the end of the file:
post_max_size = 50M
upload_max_filesize = 50M

Restart the webserver. If you are using Apache: sudo /etc/init.d/apache2 restart

www backup script

Here is a simple script that creates a RAR file of /var/www/

1. Create a script folder.
# sudo mkdir /script

2. Create a backup folder and a destnation folder for the www rar file.
# sudo mkdir /backup /backup/www

3. Create a script file.
# sudo nano /script/wwwbackup.sh

Add the following:
#!/bin/bash
/usr/bin/rar a -r /backup/www/www.rar /var/www/

This will will create a rar file of the www directory. The file patch will be /backup/www/www.rar

When done exit Nano and save he script file.

4. Verify that the script file is correct.
# sudo cat /script/wwwbackup.sh

5.  Give the script execution rights.
# sudo chmod +x /script/wwwbackup.sh

6. Instal Cron (Same as schedule tasks in Windows)
# sudo aptitude install cron

7. Edit crontab.
# crontab -e

Add the following t crontab:
15 23 * * * /script/wwwbackup.sh

This means that wwwbackup.sh will start every day 23.15.

8. Verify crontab.
# crontab -l

9. Verify the next day that the backup file exists in /backup/www/.

Run the wwwbackup script manually:
# /script/./wwwbackup.sh

MySQL backup script

1. Create a script folder.
# sudo mkdir /script

2. Create a backup folder and a destnation folder for the MySQL files.
# sudo mkdir /backup /backup/mysql

3. Create a script file.
# sudo nano /script/mysqlbackup.sh

At the start of the file add:
#!/bin/bash

On the next row write your script.

Here are a few script examples. In the examples the MySQL user is  root and the password is Qwerty12.

Example 1. Will backup alla databases into one single file.
#!/bin/bash
/usr/bin/mysqldump –u root pQwerty12 –all-databases > /backup/mysql/all-databases.sql

Example 2. Will backup the database named mysite.
#!/bin/bash
/usr/bin/mysqldump –u root pQwerty12 –databases mysite > /backup/mysql/mysite.sql

When done exit Nano and save he script file.

4. Verify that the script file is correct.
# sudo cat /script/mysqlbackup.sh

5. Give the script execution rights.
# sudo chmod +x /script/mysqlbackup.sh

6. Instal Cron (Same as schedule tasks in Windows)
# sudo aptitude install cron

7. Edit crontab.
# crontab -e

Add the following t crontab:
01 23 * * * /script/mysqlbackup.sh

This means that mysqlbackup.sh will start every day 23.01.

8. Verify crontab.
# crontab -l

9. Verify the next day that the backup file exists in /backup/mysql/.

Run the mysqlbackup script manually:
# /script/./mysqlbackup.sh

Installing a LAMP-server (LinuxApacheMysqlPHP)

Here are som useful things to install and config when running a LAMP-server under Ubuntu JeOS.

1. Install Ubuntu JeOS.

2. Update aptitudes packetlist.
# sudo aptitude update

3. Update/Upgrade the system.
# sudo aptitude full-upgrade -y

4. If the kernel was updated, restart the system.
# sudo reboot

5.  Install SSH
# sudo aptitude install openssh-server -y

6. Install firewall
# sudo aptitude install ufw  -y

7. Install the text editor Nano
# sudo aptitude install nano -y

8. Install LAMP (LinuxApacheMysqlPHP)
# sudo tasksel install lamp-server

9.  Instal PHPMyAdmin
# sudo aptitude install phpmyadmin -y

10. Install RAR and UNRAR (can be useful if your moving a site to this server)
# sudo aptitude install rar unrar -y

11. Install FTP (can be useful if your moving a site to this server)
# sudo aptitude install ftp -y

12. Install Sendmail (I use sendmail when using Joomla)
# sudo aptitude install sendmail -y

13. Configurate the firewall
# sudo ufw enable && sudo ufw allow 22
# sudo ufw default deny
# sudo ufw allow 80

14. Configurate Apache

Virtual host config

15. Configurate the network interface

Configurate the network interface

16. Configurate LAMP-server backup script
MySQL backup script: https://headadmin.net/?p=14
WWW backup script: https://headadmin.net/?p=19

Virtual host config

Virtual hosts in Apache are the same thing as host headers in Windows IIS, allowing the admin to have multiple websites on one webserver with one IP-address.

1. Create a folder for the new virtual host.
# sudo mkdir /var/www/www.mysite.com

2. Change owner on the virtual host folder. www-data is the same as IUSR under Windows.
# sudo chown -R www-data /var/www/www.mysite.com

3. Edit the Apache configuration file.
# sudo vi /etc/apache2/sites-enabled/000-defualt

4. Add the following text at the end of the file.
<VirtualHost *>
DocumentRoot /var/www/www.mysite.com
ServerName www.mysite.com
ServerAlias mysite.com
</VirtualHost>

5. Restart Apache to use the new configuration.
# sudo /etc/init.d/apache2 restart

http://httpd.apache.org/docs/1.3/vhosts/