Nginx newest version on Ubuntu Lucid 10.04 LTS
Ubuntu November 14th, 2011
Some time ago I wrote a post regarding this same topic (installing an updated version of Nginx instead of the one that is on the official Ubuntu repositories) but for Hardy (8.04).
Now, it is the turn of the latest Long-Term-Support version of this Linux distribution.
In this case, we need to use this repository:
deb http://ppa.launchpad.net/nginx/stable/ubuntu lucid main
You can create a file like /etc/apt/sources.list.d/nginx-stable.list, and put that line inside.
We also need to add the key of this repository so Ubuntu won’t complain.
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 00A6F0A3C300EE8C
and finally, run:
apt-get upgrade && apt-get install nginx
Tags: Apache, Linux, Nginx, Ubuntu 10.04, Web Server
Install updated version of nginx on Ubuntu Hardy 8.04LTS
Ubuntu May 26th, 2011
Nginx is a great web server to handle tons of traffic with relative low resources, it beats Apache big time.
I have started using it as a Reverse Proxy, Load Balancer, Web Cache and static files web server (like images, javascript and CSS) in front of Apache (for PHP processing). I’m more than amazed with the results.
The problem is that Ubuntu Hardy 8.04 comes with Nginx version 0.5 (version 1.0 has been recently released), and lacks of some features as Cache. An easy way to update the version to a more recent one (currently, to 0.8) without upgrading the whole Ubuntu version is using the following PPA repository: https://launchpad.net/~meto/+archive/nconfig
To add this repository to your system, you need to create a file inside /etc/apt/sources.list.d/ (for instance, nginx-stable.list) with the following content:
deb http://ppa.launchpad.net/meto/nconfig/ubuntu hardy main deb-src http://ppa.launchpad.net/meto/nconfig/ubuntu hardy main
Then, you need to add the key of the repository to your system:
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ED283389
Finally, run:
apt-get update && apt-get upgrade
You should be prompted about a newer version of nginx, say yes, and that’s it, enjoy
.
Tags: Apache, Load Balancer, Nginx, Reverse Proxy, Ubuntu 8.04, Ubuntu Hardy, Web Server
Debian/Ubuntu’s apt behind a proxy
Linux, Ubuntu January 27th, 2011
To allow the Advanced Packaging Tool, or just APT for friends to do its job when the box is behind a proxy, we can use one of the following options.
From the command line (this will only work for the session we are working on):
export http_proxy=http://username:password@server:port
Or if the proxy does not require a username:
export http_proxy=http://server:port
Another option is to add the following line into the file /etc/apt/apt.conf (note the semicolon at the end):
Acquire::http::Proxy "http://username:password@server:port";
Disable cron log on syslog and enable cron.log
Linux, Ubuntu October 17th, 2010
By default, Ubuntu logs all cron activity directly to syslog (/var/log/syslog), instead to a dedicated file like /var/log/cron.log.
In my opinion, it is best to keep them separate if you have several cron jobs running on your server.
To enable this behavior, what we must do is edit the syslog configuration file /etc/syslog.conf, and modify the following lines:
- Change
*.*;auth,authpriv.nonewith*.*;auth,authpriv,cron.none, this will avoid the messages to be recorded on the syslog file. - Uncomment (removing the # character) the line starting
cron.*, this will record the messages to the specified file on that line.
Then, we need to restart the syslog service, doing the following:
$ sudo /etc/init.d/sysklogd restart
And maybe, restarting the cron service also:
$ sudo /etc/init.d/cron restart
Install Munin on Ubuntu Server
Linux, Ubuntu April 6th, 2010
Munin is a small tool for monitoring resources on servers. I think it is very useful, specially on small VPS, that needs to save resources. Reports are written as HTML files, so we will need a Web Server like Apache to see this reports.
First, we install it and add some extra plugins:
$ sudo apt-get install munin munin-plugins-extra
Now, we can make some changes to the default configuration, located at /etc/munin/munin.conf. For example, we can change any of the paths where Munin works:
dbdir /var/lib/munin htmldir /var/www/munin logdir /var/log/munin rundir /var/run/munin
Specially, the htmldir path, where all the reports are written to see through Apache or the one you are using. Remember to move the directory /var/www/munin to where you wanted if you change that configuration line. We can protect this directory with an htaccess file to only give access to some users.
We can configure email notifications if a change occur (like from a OK situation to a WARNING). To do this, we just need to uncomment or add the following line:
contact.someuser.command mail -s "Munin notification" your@email.com
By default, Munin will monitor localhost, but we can add other boxes (clients), these machines will only need to install munin-node package.
Then, we can enable some plugins (more plugins can be found here and here). To do this, we need to create a symbolic link per each plugin we want to activate. I’m going to enable apache and mysql modules, but you are free to enable the modules you need:
$ cd /etc/munin/plugins $ sudo ln -s /usr/share/munin/plugins/apache_* . $ sudo ln -s /usr/share/munin/plugins/mysql_* .
Each time a module is enable or disable, we need to restart the service, so we can do the following:
$ sudo /etc/init.d/munin-node restart
Also, it is recommended to reassign all files on the htmldir to munin user and group by doing:
$ sudo chown munin.munin -R /var/www/munin
And then, to avoid waiting 5 minutes until munin cron runs again, we force it by:
$ sudo /usr/bin/munin-cron --force-root
If we are not completely satisfied with the default template, we can modify it, they are HTML files (with some minor special template tags). Anyone with some knowledge of HTML and CSS can do that. We can even download other already created templates (I have found some errors on that template’s JavaScript, I hope I’ll get some time to post the modified template, in the meanwhile, if anyone need it, please drop me a line to send you the files).
Finally, as this post is not as complete as I would like, I leave some links that may help:
- Munin on Ubuntu Documentation
- Monitor Servers and Clients using Munin in Ubuntu
- Munin on Debian Help
Install VirtualBox Guest Additions on Ubuntu Server
Linux, Ubuntu April 5th, 2010
On my work, I have a box with WinXP, running Virtual Box as a host, and a Ubuntu Server 9.10 box as a guest. My problem is that the firewall on the corporate network does not allow Ubuntu to update the date and time against any NTP server (like pool.ntp.org or ntp.ubuntu.com). So, I need a way to keep the hour updated on the guest. Fortunately, VirtualBox has the ability to synchronize it from the host, the only thing I need to do was to install the Guest Additions package.
To do this, first, we need to click on Devices/Install Guest Additions (from the VirtualBox menu).
Then, on the Ubuntu Server, we install some pre-requisites:
$ aptitude install build-essential linux-headers-$(uname -r) -y
Now, we will mount the virtual CD-ROM (where the Guest Additions are):
$ mount /dev/cdrom /mnt/
And then, run the installer script (there is a 32-bit and 64-bit versions). For 32-bit (which is the most probable, as VirtualBox Open Source only supports 32-bit guests):
$ /mnt/VBoxLinuxAdditions-x86.run
Or for 64-bit guest:
$ /mnt/VBoxLinuxAdditions-amd64.run
It should install the available modules (like timesync), and drop a fail message saying that X server
was not found, which is OK as we are working with a server without GUI.
Finally, we umount the CD-ROM:
$ umount /mnt/
Now, the guest box time should be sync with the host, so we have one less thing to worry about.
Tags: NTP, Ubuntu 9.10, VirtualBox, Windows XP
Configuring a Linux Server – Part 1: Sudoer user and SSH
Linux, Ubuntu March 29th, 2010
This will be a series of posts about configuring a Linux server (I’m working with Ubuntu, but should work with minor changes with other distributions), mainly because I have done this several times now by reviewing different websites and blogs, so I wanted to do a guide that works for me (and maybe for others too).
First, we create a user to avoid the use of root (in case you are not using the default Ubuntu installation, that asks you to create a user):
$ adduser myuser Adding user 'myuser' ... Adding new group 'myuser' (1000) ... Adding new user 'myuser' (1000) with group 'myuser' ... Creating home directory '/home/myuser' ... Copying files from '/etc/skel' ... Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully Changing the user information for myuser Enter the new value, or press ENTER for the default Full Name []: Room Number []: Work Phone []: Home Phone []: Other []: Is the information correct? [Y/n] y
It is also possible to use the command useradd (that is a linux command itself, not that user-friendly) instead of useradd (this one is a perl script that makes a little more easy user creation).
We need to assign add this user to the sudoers (users that are able to use the sudo command to make changes to the system).
$ visudo
And add the following line:
myuser ALL=(ALL) ALL
Then, we need to hardening SSH server (be very careful about this modifications because if SSH is the only way you have to configure your server, any error may left you lock out of your box).
Before making any change, we better make a backup of our original config file:
$ cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bk
Then, we need to change the following parameters on /etc/ssh/sshd_config:
- Port Number: Change it to any random port number, try to use one that any known service uses, see the list of services in here.
- Listen Address: Instead of listen to every interface on your server, just listen to the main IP address.
- Protocol: Make sure that this parameter is set to 2 (instead of 2, 1).
- If possible, avoid root login by disabling PermitRootLogin. All root operations can be done using sudo command (at least on Debian/Ubuntu based distributions). Make sure you have created other users on your box, and add them to the allow list of users to log through SSH (AllowUsers [username1] [username2] parameter).
- Disable X11Forwarding.
- Replace password authentication with Public/Private Keys. To do this, make sure your users have their Private Keys and the Public Keys are configured on the server. Then, disable PasswordAuthentication and UsePAM parameters. Make sure that RSAAuthentication and Pubkeyauthentication parameters are enabled.
- If you have noticed that OpenSSH server may take a while from the moment you enter your username and the password prompt, it is because it tries to make some DNS resolves. You can avoid this by disabling UseDNS parameter.
You should end with a file like this:
Port XXXX ListenAddress XXX.XXX.XXX.XXX [...] PermitRootLogin no [...] RSAAuthentication yes PubkeyAuthentication yes [...] PasswordAuthentication no [...] X11Forwarding no [...] UsePAM no UseDNS no AllowUsers myuser user2
Then, we need to restart the SSH server by doing:
$ /etc/init.d/ssh restart
Do not close your current session, just open another to your box using the new port, this way we make sure we are not locked out of it.
On the next post I will be configuring IPTables as a firewall for our box.
UPDATE 17/Apr/2010: Parameter PasswordAuthentication included for disabling keyboard-interactive authentication.
In this link you can find a very good explanation about the main options on SSH config file.
Nullmailer keeps trying to send unsuccessful mails on Ubuntu
Linux, Ubuntu February 26th, 2010
I have noticed that my Ubuntu box is lately always trying to reach a SMTP server (detected through Wireshark tool). After reviewing the list of running processes that contains the word mail (running ps aux | grep mail on console), I found a couple of them called Nullmailer that seems the responsible of that and indeed, it was.
So a Google search led me to this thread, where in that case, Nullmailer registered entries on Syslog (which possible happened on my computer also). The messages that Nullmailer was trying to send were related to Cron jobs output. So, the solution was to delete the queue of messages of this program, located on /var/spool/nullmailer/queue/.
Tags: Mail, SMTP, Ubuntu 9.10, Wireshark
Instalar nuevos locales en Ubuntu
Linux, Ubuntu February 14th, 2010
Durante la migración de la web de DeChalaca desde el servicio Grid-Service de MediaTemple hacia un nuevo VPS, el último punto que quedó por resolver fue que las fechas en la web se mostraban en inglés (aunque el Joomla estaba configurado para que lo hagan en español). El problema era que el servidor, un flamante Ubuntu 8.04, no tenía instalado las locales del español. La solución fue muy sencilla (como root):
$ cd /usr/share/locales $ ./install-language-pack es_ES $ ./install-language-pack es_PE
Para ver la lista de locales que están instalados en el sistema, se utiliza el siguiente comando:
$ locale -a
Tags: Joomla, Locales, Ubuntu 8.04
Reinstalar Grub luego de instalar Windows
Linux, Ubuntu, Windows December 29th, 2009
Luego de haber instalado Windows 7 hace algunos meses, en un equipo donde tenía tanto el Windows XP como Ubuntu 9.04, quedó inaccesible este último. Esto debido a que el instalador de Windows no reconoce otro sistema operativo que no sea propio de Microsoft (a diferencia de Linux).
Se debe tomar en cuenta NO utilizar el Live CD de Ubuntu 9.10 para restaurar el Grub de las versiones anteriores de Ubuntu. Esto debido a que Ubuntu 9.10 y posteriores utilizan Grub2, que difiere mucho de la primera versión.
Lo primero que se debe hacer es iniciar la máquina con algún Live CD de Linux (como el de Ubuntu, que es el que utilicé en el proceso).
Una vez que está funcionando, abrimos un terminal. Vamos a necesitar los privilegios del root, por lo que lo más práctico sería ir al shell respectivo:
sudo -i
Luego, creamos un punto de montaje para la partición de Ubuntu:
mkdir /mnt/linux
Después, montamos la partición:
mount /dev/sda2 /mnt/linux
Donde sda2 (sd porque es un disco SATA, a por ser el primer disco duro, y 2 por ser el número de la partición) es la partición donde se encuentra Ubuntu. Si no estamos seguros de cual es la partición, podemos usar el programa GParted (visual) o el comando:
fdisk -lUna vez que está montada la partición, podemos corroborar que sea la partición listando los archivos en ella:
ls -la /mnt/linux
ls -la /mnt/linux/boot
Luego de que estamos seguros que es la partición correcta, pasamos a reinstalar el Grub mediante el siguiente comando:
grub-install --root-directory=/mnt/linux /dev/sda
En caso aparezca algún error o advertencia, podemos probar el siguiente comando:
grub-install --root-directory=/mnt/linux /dev/sda --recheck
Donde sda hace referencia al disco (usualmente el primario) cuyo MBR será utilizado para instalar el Grub (ojo que NO incluye el número de partición).
Reiniciamos y deberíamos ver ya el menú de booteo del Grub.
Vía: Ubuntu Documentation
Tags: Grub, Grub2, Ubuntu 9.04, Ubuntu 9.10, Windows 7
About