Archive

Posts Tagged ‘Debian’

Debian vs. Red Hat: How to transfer your package list and install them

October 7th, 2011 No comments

Some time ago I came across a problem with Debian I have always solved in a matter of seconds with Red Hat I’ve had to think a little ‘…

In Debian, I often make two identical machines in a cluster for HA, and after I configured the other prepare and pass the list of packages and install them, how?

Here, the first extracts a list of Debian packages with “dpkg” and put on a file:

    root@debian1:~# dpkg –get-selections > debian1-pkgs

then you have to copy the list on the secondary machine, usually use scp:

    root@debian1:~# scp debian1-pkgs root@debian2:/root/.

now that we have the list on the secondary, the load always using “dpkg

    root@debian2:~# dpkg –set-selections < debian1-pkgs

Now we just have him install the packages using "apt":

    root@debian2:~# apt-get dselect-upgrade

And voila! You're done!

And Red Hat?!?

first retrieve all packages installed on a file, using "yum" (the Red Hat package manager and so on), and copy it to the other node:

[root@redhat1 ~]# yum list installed > redhat1-pkg
[root@redhat1 ~]# scp redhat1-pkg root@redhat2:/root/.

now we should say "yum" to install the list, but unfortunately it has more of the entries that do not serve us, this is the example that follows shows how the file:

Loaded plugins: rhnplugin, security
Installed Packages
Deployment_Guide-en-US.noarch             5.2-11                       installed
GConf2.i386                               2.14.0-9.el5                 installed
GConf2.x86_64                             2.14.0-9.el5                 installed
GConf2-devel.x86_64                       2.14.0-9.el5                 installed
MAKEDEV.x86_64                            3.23-1.2                     installed
NetworkManager.i386                       1:0.7.0-10.el5_5.2           installed
NetworkManager.x86_64                     1:0.7.0-10.el5_5.2           installed
NetworkManager-glib.i386                  1:0.7.0-10.el5_5.2           installed
NetworkManager-glib.x86_64                1:0.7.0-10.el5_5.2           installed
NetworkManager-gnome.x86_64               1:0.7.0-10.el5_5.2           installed

we clean everything with the command "cut" and take the first part of each line, so the only name of the package, and we feed it to "yum" directly

    [root@phbe2pr ~]# yum -y install $(cut -f 1 -d” ” < redhat1-pkg)

Now start the download and installation of all.
I hope that was helpfu.

Install WordPress on a Debian 6.x Squeeze and 5.x Lenny

October 5th, 2011 7 comments

Wordpress Logo Configurations on debian linux

How to install WordPress on Debian Server 6.x Squeeze in 10 steps.

For installation you will use ssh and w3m. The installation should be identical with Debian Lenny 5.x.
The multisite configuration is that it is also good for those who have only one blog/site on your server.

In this guide, the blog will URL http://www.example.com, the configuration can also be used on a test machine. In this case, use a URL like http://www.example.invalid to avoid having problems.

Have you ever tried to install WordPress on Debian?

I did a little ‘of times and I struggled a lot, setting the directory to upload media files and multi-configuration gave me several headaches. Eventually I managed to find a way.
This procedure uses the Debian package WordPress and manages the multi-second Debian style so you do not have problems with apt updates.

1. Prepare and install the necessary tools

Access to the server:

$ ssh user@name_server

Install the programs utility:

$ sudo apt-get install pwgen vim w3m

Install the WordPress Package:

$ sudo apt-get install WordPress WordPress-l10n
   WordPress-xrds-simple WordPress-openid

If not already installed, install mysql-server

$ sudo apt-get install mysql-server

2. Create a database for WordPress

The user will create the database that WordPress will use to create and use tables. Here I used: for example the database name, user name WordPress_agent for WordPress. Use pwgen to generate a secure password, in this case is: mooNoaZ3. I highly recommend you create your password. Do not use this for no reason!

Write down why you need this information back to step 4.

$ pwgen
 aTh6Ohbe Eipho7ie maiPa8pu ech6Aebo shoh8Cie iu7haiD7 Ao1Fiem8 chae6Ui9
 cheiy4Ei YeiB1ohy beRoh5id bie5ooBi ieQuoo4l ahShaa1i eeK1ri5k Oe2seesh
 AiY4ud5e Ooboath4 ohz2eu4X eer9Gi3u Aijeuk3a wia8Kemu xeDohx1o aegie1iM
 Queil4oo ohme4Air OoH0aa1m ieShae2a phahde5V Taimah7b Diziec1e ohP2ooSo
 Eem5oich aoBae0ie ya8Vaipe AuWo8ieK YaiD5uba ohK2bahW iQuohgh7 ooSh7wo0
 eki4sheX iu5Thaoy phee9EKu ongu2Fee eeQuosh8 Wa8Poth9 kaenai5S eiCeem3e
 eyaYai1a ioCie2ed Tae5hae6 Sha9Vohs Eng6ix2J shee0aiK Ugha5bad seiV8pa2
 Tu2izahg aise8Eid me5Hiloh pah5aeW9 AiNo9lae jei6Daed Ocie7Iey Ahwipa9i
 Oochu8le ohFae5ja aotaiT2m peTu7tho joh6iGie Pha2eiTh requ9Oyo Yaifi4ah
 vohD1ogh chieth6F oora8ATh yogaiSh1 Vof4aich iaJ8chai Mo0nef0d Oow3Xeiz
 eo5jieNg kieYu4Do mooNoaZ3 koV4piex Phae5Peb thisohR0 ookohZ6o Ieth5ooh
 Fiemias4 eig2Aeph ohr9IeQu ooBa9ohj eiRoo9gu maTah4uu thee9Ool dieZoo6a
 aenov1Ch Apaexee8 YeiM2ulo Oocex7Ie Lem3phoo Ahtohk8i Vaegai7m chat8UQu
 Coongae5 Vieb1dep ujeeH3oo ai9ieXik Fee8fav5 voe0Eifo chohRah3 Xae9Aeph
 Udae1yoo oPhoogh9 eec0aeSh feida8aH vuM4icum Eeloh5bo OF1jaes6 oox7eeMe
 xeikuoX8 Chahle1l aiThais2 aicuZ3ae izooJ0ch fieyai5A Ru0to5er sha4Wain
 ongie4In eeM9zohd zieg2ooJ Iudahc0c seeQuai9 Sohyoo6z Bongoo3k pha9Aech
 chio2uTh uuJee9oh HaeC7eib xeiY7quo ohtaTu1H Phaiph7M yi8Eisei ohLai2oh
 ehai7soK ve0der4L Aisen2ze eicuX4Ah Faer6Doh OoVah8ah Seith4ae ung7ohPa
 ea0oeGho Loo1lo6c apoht9Wa kei2Iet0 Yoat2eud eeThie8n ieCh7aiw caip1uZa

 $ mysql -uroot -p
 mysql> CREATE DATABASE example;
 mysql> GRANT ALL ON example.* TO 'WordPress_agent'@'localhost'
 IDENTIFIED BY 'mooNoaZ3';
 mysql> quit;

Check that everything is working properly by accessing the database.

$ mysql -uWordPress_agent -p example
 mysql> show databases;
 +--------------------+
 | Database           |
 +--------------------+
 | information_schema |
 | example            |
 +--------------------+
 2 rows in set (0.00 sec)
 mysql> quit;

3. Add aliases for the server.

Make a backup copy of the hosts file and then edit it with vim. Enter an alias for the server name at ip adress….

$ cd /etc
 $ sudo cp -p hosts hosts.bak
 $ sudo vim hosts

The file must be as follows:…

 127.0.0.1       localhost
 127.0.1.1       my_server

 # The following lines are desirable for IPv6 capable hosts
 ::1     ip6-localhost ip6-loopback
 fe00::0 ip6-localnet
 ff00::0 ip6-mcastprefix
 ff02::1 ip6-allnodes
 ff02::2 ip6-allrouters

 192.168.0.101 my_server example.com

4. Create a directory to upload photos and other multimedia files.

The files will be saved in the directory /srv/www/example/

 $ cd /srv
 $ sudo mkdir www www/example
 $ sudo chown -R www-data:www-data www
 $ ls -l www
 totale 4
 drwxr-xr-x 3 www-data www-data 4096  4 mar 21.55 example

5. Prepare the configuration file of WordPress.

In the file config-example.com.php, you must put the data you used to create the database and that you noted in step 2. Now copy the file wp-config-sample.php in the directory with the configuration of WordPress, and rename it as config-.php.

 $ cd /etc/WordPress
 $ sudo cp /usr/share/WordPress/wp-config-sample.php
 ./config-example.com.php

Now edit the file and edit it with vim. Enter the information you wrote down when you’ve modified the database. Enter the language to use. Enter the secret keys that are at https://api.WordPress.org/secret-key/1.1/salt/

$ sudo vim config-example.com.php

The file must be amended as follows:

O0o2XYY?;52-qD|wMa1+a_EAyGibqf]H+#A8');
 define('NONCE_KEY',        '..-ywRGH``H{,YoEaYvDh;0gA-ggMj Gb=?:lPp=(N.');
 define('AUTH_SALT',        'BpFN):ebeKC|rA=IL&ocV,?+aEQj/ANv({k|xfMqM%kZH`?-7oYm`Lz5[2Mlon|]');
 define('SECURE_AUTH_SALT', 'U8=rPc#hm}@.ZJ|@d,MR]?=Uh@K-k,R[W+euPd|+{-tO-ME8j`|h+qTL;I(TFG7S');
 define('LOGGED_IN_SALT',   '~ {hD`b#+Q[hatf&;(^3P=.>/:DUn;9sn%E|4>gK^&Hzu&i-Y(+B@,Z*K-xgs}=:');
 define('NONCE_SALT',       '5+H@Sa[:bxJTa|R*Lg>%7UQo-aaI|w{| F4no#P!IsOi.?T^5-<%(-jpj:Ph0.k}');

 /**
 * WordPress Database Table prefix.
 *
 * You can have multiple installations in one database if you give each a unique
 * prefix. Only numbers, letters, and underscores please!
 */
 $table_prefix  = 'wp_';

 /**
 * WordPress Localized Language, defaults to English.
 *
 * Change this to localize WordPress.  A corresponding MO file for the chosen
 * language must be installed to wp-content/languages. For example, install
 * de.mo to wp-content/languages and set WPLANG to 'de' to enable German
 * language support.
 */
 define ('WPLANG', 'it_IT');

 /**
 * For developers: WordPress debugging mode.
 *
 * Change this to true to enable the display of notices during development.
 * It is strongly recommended that plugin and theme developers use WP_DEBUG
 * in their development environments.
 */
 define('WP_DEBUG', false);

 /* That's all, stop editing! Happy blogging. */

 /** Absolute path to the WordPress directory. */
 if ( !defined('ABSPATH') )
 define('ABSPATH', dirname(__FILE__) . '/');

 /** Sets up WordPress vars and included files. */
 require_once(ABSPATH . 'wp-settings.php');

6. Remove the comments in the htaccess file in the directory /etc/WordPress.

You have to uncomment the section "Configuration for multi-site installation by WordPress using subdomains"

 $ cd /etc/WordPress
 $ sudo vim htaccess

The file must be changed to this:

# For rewrite rules needed for making WordPress URL friendly
 # See Options -> Permalinks for details and please use the defaults,
 # especially in mind when hosting several blogs on one machine!

 ##
 ## Configuration for a single blog hosted on / (root of the website)
 ##
 #
 #RewriteEngine On
 #RewriteBase /
 #RewriteCond %{REQUEST_FILENAME} !-f
 #RewriteCond %{REQUEST_FILENAME} !-d
 #RewriteRule . /index.php [L]
 #

 ##
 ## Configuration for a multi-site WordPress installation using subdomains
 ##

 RewriteEngine On
 RewriteBase /
 RewriteRule ^index\.php$ - [L]
 # uploaded files
 RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]
 # real files dealt directly
 RewriteCond %{REQUEST_FILENAME} -f [OR]
 RewriteCond %{REQUEST_FILENAME} -d
 RewriteRule ^ - [L]
 # other go through index.php
 RewriteRule . index.php [L]

7. Create the configuration file for apache2 Blog

Now you must create the file to configure apache2 to show the blog when you enter the URL example.com. Copy the sample files found in the documentation of WordPress. Edit the file and post the rules for mod_rewrite….

 $ cd /etc/apache2/sites-available
 $ sudo cp /usr/share/doc/WordPress/examples/apache.conf ./example.com
 $ sudo vim example.com

The file must be as follows:

 
 ServerAdmin myself@localhost
 #We want to be able to access the web site using www.example.com or example.com
 ServerName example.com
 ServerAlias www.example.com
 DocumentRoot /usr/share/WordPress

 # Log levels: debug, info, notice, warn, error, crit, alert, emerg
 LogLevel warn

 #we want specific log file for this server
 ErrorLog /var/log/apache2/example.error.log
 TransferLog /var/log/apache2/example.access.log

 # Store uploads in /srv/www/example
 RewriteEngine On
 RewriteRule ^/wp-uploads/(.*)$ /srv/www/example/$1

8. Enable rewrite modules and enables the site and vhost_alias

 $ sudo a2enmod rewrite
 $ sudo a2enmod vhost_alias
 $ sudo a2ensite example.com
 $ sudo /etc/init.d/apache2 reload

9. Create your account for WordPress.

Now you have to use w3m to launch the installation process and create your own WordPress user. The user will have administrator rights. Use pwgen to generate a secure password for your user.

$ pwgen
 Riiz0oon foh2Ail5 Sisii3Be Toosh5oB Ohngiok2 oSeen8th UJ1baeca Agee5sho
 taht1Ahb ohb2eiF3 iqua3ahX iet1laGu toaZa1Ei se6Sheif ohhei9Ei zaiGh2ph
 aiDaeF9l utahX6yo ooghie5G nooy4Ohc ahSae3na nu4Yeu7j iePhu7tu ieB3ahsh
 ohaoL1sh Aichohy7 jaiTh7xe Ua5quooy gous4Cho Ahr0giem deiJie7y Kekahh8m
 iboosa9I eelei9Uu Phoey3Ai phaF5dah eew6aeNi Jie1augh eFie3ga5 aesh2Shu
 thee5aiM Iequ5aim Oxies6ee aiji5uGu uNg5chai Ohcae0Th dae9foeK Rae5cei1
 Oibei9ee ahNoh1oh rook2ohF Zoe6ieci uH2ra0ip vieb2Loh Eejie4ee thaiGhu5
 deikie3R Ahk3OiY7 ooPae4Ah jahp1Yoh aih1Oth8 akeJ3Ahp kap4Icie nooN1iad
 ohme1Toh air4Cha8 Choh5vie Oogi3gay Uyaepie2 peeZai3K im2IeGuV ooH1po8P
 Ieth3aen pheoNge0 bei0ea0A Iewo0foh reiThu8v uiNg7boh foo0aFoo uu5chiaY
 Oo5iesho uw4UmiGi ohfeeP0a ooL6jiwo ahdaiN0o ith1Koht aeG1la7i quee1Ooy
 Aighah4A Pheecuu1 iR7ooloo eeCea8ae nahqua2E Hie4foo8 iDaeH1ae Teex2ooS
 soo1aeR3 Ri2ojoof aquau3En eiNguw8i um4Ye5ie Ishe2Dai oogh7Phi eeki1Oce
 yo3Aehu9 wiH6geeB eebeeP3g aiF6vuu7 ahthae7B eijeeGh3 eeg1ZuXe Oosoo9ee
 Kae9coov Ronei2zi aifo6Ieh la7ohTae Aiqu9xu3 ThoNei5o xohDin2d Quai8aiP
 yoht4aFo Aig9jail Aipav5oh lahYoh7a AeX0caph cuxei4Oh Xeilej9g jo7aiG4u
 ohThi8ee Pie6aexo No1xoham Ahsae0fu EeB4Aez8 esh5Booh OoSi8bie OoriN8oe
 eeN6Tho5 remao7EX riH8pooj quie2OoP ku8mua2U Wo4eingi Co6vaoke IeQuoo9X
 Wah1Quoo aejie4Ee aeghae9V Cah1bieD jainae3D Of9eeshi cu3thi3O AeBay3ph
 iis2dahD HoS0daiv ieghee3M phied9Lo euhuLoo8 ey7eiCh2 er8EiN2h phoo9Vig

Write down the password you typed: aquau3En. Launch your browser w3m at http://example.com/wp-admin/install.php

Proceed carefully: you must use the tab key to move forward between links.
When you finish on a text field (highlighted in red) press enterand write the text. Press enter again to enter the text you typed. I suggest you do a test on google.com before beginning to practice.

$ w3m http://example.com/wp-admin/install.php

Enter your username, your email address and password, confirm and you’re done.

10. Configure WordPress.

Now the blog should be active (hopefully). Access the blog at http://example.com/wp-admin/. You must set the values ​​in the file upload.

Store uploads in this folder: /srv/www/example.
Full URL path to files: /wp-uploads.

Edit the settings as in the image below:
wordpress configurations on debian squeeze and lenny

That’s it! Now you have to configure your blog as you want and start posting. Congratulations.

Credits:
By WordPress WordPress-logo.png [GPL (www.gnu.org/licenses/gpl.html) or GPL (www.gnu.org/licenses/gpl.html)], via Wikimedia Commons

Debian server backup with Dropbox

October 1st, 2011 No comments

Dropbox Debian

Yes, this evening I’m in the mood for nerds, so I dabbled in a thing I thought of doing for some time: to use my space on my server Dropbox backup game.

For those interested, the article is valid for all debian-based distributions (I used Debian Lenny), but should not vary much for other distros.

Installing Dropbox CLI (Command Line Interface)

The installation, without GUI, is the most monotonous, but it is also very fast, so let’s see how:

wget -O dropbox.tar.gz https://www.dropbox.com/download?plat=lnx.x86
tar xzf dropbox.tar.gz
./.dropbox-dist/dropbox

Ok, a new link will be provided to link to the server to Dropbox, run it in Firefox.

Debian Server - Dropbox
Now, open another console, you kill the first and go from here.
We download, now, the script to automate the process of starting Dropbox:

wget -O /etc/init.d/dropbox http://dl.dropbox.com/u/2169702/dropbox
nano -w /etc/init.d/dropbox e cambiamo: DROPBOX_USERS="user1 user2"
chmod +x /etc/init.d/dropbox
update-rc.d dropbox defaults
/etc/init.d/dropbox start

Backup

Well, now we are ready to use rsync, but first we must create:

echo "[mysqldump]" > ~/.my.cnf
echo "user = root" >> ~/.my.cnf
echo "password = vorstrapassword" >> ~/.my.cnf
chmod 600 ~/.my.cnf

Instead of following my configuration as an example:

root@saturn:~$ cat devel/rsync-backup.sh
#!/bin/bash
rsync -au --delete --exclude='phpmyadmin' --exclude='phpsysinfo' --exclude='img' /home/www/partenza1 /root/Dropbox/destinazione1
rsync -au --delete /home/www/partenza2 /root/Dropbox/destinazione2
root@saturn:~$ cat devel/mysqldump-backup.sh
#!/bin/bash
mysqldump --opt -u root DATABASE | gzip -9 > /root/Dropbox/DW/db/db1-`date +%F`.sql.gz
mysqldump --opt -u root DATABASE | gzip -9 > /root/Dropbox/DW/db/db2-`date +%F`.sql.gz
mysqldump --opt -u root DATABASE | gzip -9 > /root/Dropbox/DW/db/db3-`date +%F`.sql.gz
root@saturn:~$

Periodically, then, the crontab will run these two scripts automatically (they must have execute permissions, so chmod+xnomefile.sh):

30 04 * * * /root/devel/rsync-backup.sh > /dev/null 2> /var/log/rsync-backup-error.log
0 04 * * 1,3,5 /root/devel/mysqldump-backup.sh > /dev/null 2> /var/log/mysqldump-backup-error.log

All done, the first time we put a little ‘, but do not worry, thanks to the power of incremental backups the other times will be much faster.

With Linux being Guake drop-down terminal

September 29th, 2011 No comments

The terminal is the key instrument in each of its various Linux distributions available today. It is therefore very important to use it as convenient as possible.

Guake is a new way to bring up the terminal, allowing not only a convenient use of the same, even integration within a more pleasant workspace.

With Linux being Guake terminal drop-down

Once started, Guake can recall the terminal keyboard – using the F12 key by default – which is presented differently from how we used to. It is not the classic open window, but sort of semi-transparent layer that is placed on top of all windows that are open on the workspace, which is instantiated inside the terminal. In short, it is a sort of drop-down terminal that plugs from the top of the screen. In addition to providing support for tabs, Guake also has a series of pre-configured keyboard shortcuts that allow you to use it.

The application is widely configurable. First, you can choose the shell interpreter that you prefer to take lending itself well to different uses. In addition, you can manage other parameters like autoscroll, hotkeys and appearances including fonts used in graphics, color and background. Guake is available for several Linux distributions including Ubuntu, Debian, Fedora, Gentoo. To install under Ubuntu Guake the following command:

     sudo apt-get install Guake

The configuration of the new Debian server

September 24th, 2011 No comments

A little ‘are coming to me once all components of the new server. Now only lacks a hard drive and then I can install the operating system (Debian GNU / Linux). On this occasion also arranged for a piece of my workstation since I added the last album, last year, I never had the opportunity to configure the best partitions.

The CPU I chose for the server supports Intel® VT and this is making me look into the option to virtualize some service.

This server will have to perform several tasks:

  • IMAP Mail Server
  • Web server for development
  • Backup servers

 

Dovecot: IMAP mail server with Debian

To manage electronic correspondence will continue to rely on Dovecot. This is an open source IMAP and POP3 servers by high standards of security, very fast and fully compliant IMAP (source), in contrast to many other IMAP servers such as Courier-IMAP and Cyrus (both open source) or Zimbra, Gmail or MS Exchange that are not completely standard and does not fully meet my needs.

Dovecot, finally, in addition to the excellent technical features is also easy to configure.

Debian Server Installation


How to install and configure Dovecot with Debian

The installation is very fast, as most of the software on Debian. Just the classic:

apt-get install dovecot-imapd

to have the program installed on your system (less than ten megabytes if I remember correctly).

The next step is to configure the IMAP server by changing a few lines in the configuration file /etc/dovecot/dovecot.conf to specify the protocol that you want to use and the path to, in my case:

protocols = imap imaps

and

mail_location = maildir:~/Maildir

At this point, if you do not need special configurations, the IMAP server will be configured.

How do I send and receive mail with Debian server?

However there are two more pieces to complete the setup of email on the server: we also need an MTA (mail transfer agent) and a service to retrieve email from various accounts I have.

I chose Postfix as MTA for many years: it is a stable, secure and efficient. The configuration in the case of a small server is pretty straightforward, although at first glance it might seem otherwise.

To download the emails using fetchmail instead (along with SpamAssassin). Here too a classic and functional solution.

Web server with Debian development

The server, in addition to managing email, also serves to build web applications, to implement and test the products without having to install software “server” on the workstation and, especially, not to be bound to a single machine for development.

Apache and MySQL are therefore the logical choice for this type of activity.

The process of installing and configuring Apache and MySQL on Debian is very easy. With apt-get the packages are installed in minutes and very few are enough to set up operations: MySQL is configured via a wizard during installation and Apache only needs some things in the configuration files.

Backup servers, Debian and Rsync.

The third and last task of the server is to make copies of data storage, document and archive projects. As far as the backups are very demanding and, thanks to the new server, the data will be even more secure thanks to an additional backup made with a small RAID.

The disks in the RAID will be used to back up the backup, although I consider the current backup of RAID as a backup system ...

To make backups using rsync. Although I chose this software because it combines ease of use with high performance. Rsync the data through the workstation and server are periodically copied to disks dedicated to backups.

Virtualize or not to virtualize?

With the new server I would get a more reliable and safer than the old one, which however is still doing its job nicely. Virtualize some services could be very useful to separate the functions related to the development of mail handling.

The host system may look to make backups and allow the execution of the two guest systems, the mail server and web server for personal development. Before making the final setup I will still make a little ‘test to monitor the performance of this configuration.