Archive

Archive for the ‘Linux’ Category

Apache virtual host script in perl

May 27th, 2010 Ivan Villareal 1 comment

This is a very short post about a little script I did to create remove virtual hosts easily.

I’ve found a couple of scripts (http://patrickgibson.com/utilities/virtualhost/, http://www.tamdenholm.com/portfolio/apache)  to do this but they didn’t worked right, I’m using Ubuntu Karmic, maybe thats why. However instead of fixing those scripts I went to my vim editor and started typing this, I’ve spent about 2 hours writing this while I was watching a crappy tv program, but in the end it worked, it surely contains some bugs, or it is unsafe to run it, I just wanted to share this.

#!/usr/bin/perl -w
use strict;
use File::Path qw(mkpath rmtree);
use Getopt::Long;
 
 
our $ipAddress        = '127.0.0.1';
our $apacheConfigFile = 'apache2.conf';
our $apacheConfigDir  = '/etc/apache2';
our $sitesAvailable   = 'sites-available';
 
our $docRootPrefix = '/home/ivan/www';
our $docRoot = 'public_html';
our $logsDir  = 'logs';
 
 
my $del = '';
my $add = '';
my $domain = '';
 
unless (GetOptions ('del' => \$del, 'add' => \$add, 'domain=s' => \$domain) or usage()) {
    usage();
}
 
#print $paramResults;
if ($add || $del) {
    if ($domain) {
        if ($add) {
            createVhost($domain);
        } elsif ($del) {
            deleteVhost($domain);
        }
    } else {
        usage();
    }
   #print 'add aqui';
} else {
    usage();
}
 
sub usage {
    print < <USAGE
This program will add or remove
apache virtual hosts on ubuntu karmic 9.10
 
usage: vhost-updater.pl [--add | --del] --domain newhost.tld 
USAGE
}
 
sub returnVhostPaths
{
    my $vhost = shift;
    my @dir = split(/\//, $docRootPrefix);
    my %res;
 
    push(@dir, $vhost);
 
    my $hostDir = join('/', @dir);
    $res{'docRoot'} = $hostDir . '/' . $docRoot;
    $res{'logsDir'} = $hostDir . '/' . $logsDir;
 
    #todo dir validation
    @dir = split(/\//, $apacheConfigDir);
    push(@dir, $sitesAvailable);
    push(@dir, $vhost);
    $res{'apacheConfig'} = join('/', @dir);
 
    return %res;   
}
 
sub createVhost {
    my $vhost = shift;
    #first create the docRoot
    my %vhostInfo = returnVhostPaths($vhost);
 
    informOut("Creating docroot dir: $vhostInfo{'docRoot'}");
    informOut("Creating log dir: $vhostInfo{'logsDir'}");
    mkpath($vhostInfo{'docRoot'}, $vhostInfo{'logsDir'});
 
 
    informOut("Site File: $vhostInfo{'apacheConfig'}");
 
    my $vhostContent = << "EOF";
<VirtualHost *:80>
    ServerName $vhost
    DocumentRoot $vhostInfo{'docRoot'}
    <directory $vhostInfo{'docRoot'}>
        Options Indexes FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </directory>
        ErrorLog $vhostInfo{'logsDir'}/error_log
        CustomLog $vhostInfo{'logsDir'}/access_log "%h %l %u %t \\"%r\\" %>s %b \\"%{Referer}i\\" \\"%{User-agent}i\\""
        LogLevel debug
 
 
EOF
    informOut("Creating Vhost...");
    open FILE, ">", $vhostInfo{'apacheConfig'} or die $!;
    print FILE $vhostContent;
    close FILE;
 
    informOut("Adding host $vhost");
    open FILE, ">>", '/etc/hosts' or die $!;
    print FILE $ipAddress ."\t". $vhost ."\n";
    close FILE;
 
    my $output = `/usr/sbin/a2ensite $vhost`;
    print $output;
 
    restartApache();
    #print $vhostConten t;
}
 
sub restartApache
{
    informOut("Restarting apache");
    my $output = `/etc/init.d/apache2 restart`;
    print $output; 
}
 
sub deleteVhost
{
    my $vhost = shift;
     my %vhostInfo = returnVhostPaths($vhost);
 
    informOut("Removing $vhost from hosts file");
    open IN, '< ', '/etc/hosts' or die $!;
    my @hostsFile = <IN>;
    close IN;
 
    my @contents = grep(!/^127.0.0.1\t$vhost/, @hostsFile);
 
    open FILE, ">", '/etc/hosts' or die $!;
    print FILE @contents;
    close FILE;
 
    my $output = `/usr/sbin/a2dissite $vhost`;
    print $output;
 
    informOut("Removing  $vhostInfo{'apacheConfig'} file");
    unlink($vhostInfo{'apacheConfig'});
 
    restartApache();
 
    print " manually remove $vhostInfo{'docRoot'}... \n";
 
}
 
sub informOut {
    my $message = shift;
    print "$message \n";
}

Here is a screenshot of the program running

vhost creator Screenshot

Categories: Linux, Perl, configuration Tags:

Upgrading php5.1 to php5.3 on CENTOS 4

April 22nd, 2010 Ivan Villareal 4 comments

I needed to update the php version of a centos 4 box, so this is what I did:

I’ve decided to go for the easy way, using the remi repo, so first I’ve Downloaded the Extra Packages for Enterprise Linux (EPEL)

[root@box php5.3]# wget http://download.fedora.redhat.com/pub/epel/4/i386/epel-release-4-9.noarch.rpm
--13:08:07--  http://download.fedora.redhat.com/pub/epel/4/i386/epel-release-4-9.noarch.rpm
           => `epel-release-4-9.noarch.rpm'
Resolving download.fedora.redhat.com... 209.132.183.67
Connecting to download.fedora.redhat.com|209.132.183.67|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 13,686 (13K) [application/x-rpm]
 
100%[=================================================================================>] 13,686        --.--K/s            
 
13:08:08 (405.60 KB/s) - `epel-release-4-9.noarch.rpm' saved [13686/13686]

Then the remi repo:

[root@box php5.3]# wget http://rpms.famillecollet.com/enterprise/remi-release-4.rpm
--13:08:21--  http://rpms.famillecollet.com/enterprise/remi-release-4.rpm
           => `remi-release-4.rpm'
Resolving rpms.famillecollet.com... 88.191.60.189
Connecting to rpms.famillecollet.com|88.191.60.189|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5,120 (5.0K) [application/x-rpm]
 
100%[=================================================================================>] 5,120         32.45K/s            
 
13:08:22 (32.41 KB/s) - `remi-release-4.rpm' saved [5120/5120]

Then I’ve upgraded both repos:

[root@box php5.3]# rpm -Uvh remi-release-4*.rpm epel-release-4*.rpm
warning: remi-release-4.rpm: V3 DSA signature: NOKEY, key ID 00f97f56
warning: epel-release-4-9.noarch.rpm: V3 DSA signature: NOKEY, key ID 217521f6
Preparing...                ########################################### [100%]
   1:epel-release           ########################################### [ 50%]
   2:remi-release           ########################################### [100%]

and after that I downloaded the remi repo file for Yum:

[root@box php5.3]# cd /etc/yum.repos.d/
[root@box yum.repos.d]# wget http://rpms.famillecollet.com/remi-enterprise.repo
--13:09:28--  http://rpms.famillecollet.com/remi-enterprise.repo
           => `remi-enterprise.repo'
Resolving rpms.famillecollet.com... 88.191.60.189
Connecting to rpms.famillecollet.com|88.191.60.189|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 793 [text/plain]
 
100%[=================================================================================>] 793           --.--K/s            
 
13:09:28 (50.42 MB/s) - `remi-enterprise.repo' saved [793/793]

After that I just told yum to upgrade php:

[root@box yum.repos.d]# yum --enable remi update php
Repository remi is listed more than once in the configuration
Repository remi-test is listed more than once in the configuration
Setting up Update Process
Setting up repositories
epel                      100% |=========================| 3.4 kB    00:00    
remi                      100% |=========================| 2.6 kB    00:00    
Reading repository metadata in from local files
357f538e0bf37d10983cd3b22 100% |=========================| 732 kB    00:06    
epel      : ################################################## 2267/2267
e849a85ae6e8f1b8e5e71c08b 100% |=========================| 128 kB    00:03    
remi      : ################################################## 444/444
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for php to pack into transaction set.
php-5.3.2-1.el4.remi.x86_ 100% |=========================|  19 kB    00:00    
---> Package php.x86_64 0:5.3.2-1.el4.remi set to be updated
--> Running transaction check
--> Processing Dependency: php-common = 5.3.2-1.el4.remi for package: php
--> Processing Dependency: php-cli = 5.3.2-1.el4.remi for package: php
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for php-common to pack into transaction set.
php-common-5.3.2-1.el4.re 100% |=========================|  25 kB    00:01    
---> Package php-common.x86_64 0:5.3.2-1.el4.remi set to be updated
---> Downloading header for php-cli to pack into transaction set.
php-cli-5.3.2-1.el4.remi. 100% |=========================|  19 kB    00:01    
---> Package php-cli.x86_64 0:5.3.2-1.el4.remi set to be updated
--> Running transaction check
--> Processing Dependency: php-common = 5.1.6-3.el4s1.10 for package: php-mysql
--> Processing Dependency: php-common = 5.1.6-3.el4s1.10 for package: php-xml
--> Processing Dependency: php-common = 5.1.6-3.el4s1.10 for package: php-pdo
--> Processing Dependency: libedit.so.0()(64bit) for package: php-cli
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for php-xml to pack into transaction set.
php-xml-5.3.2-1.el4.remi. 100% |=========================|  20 kB    00:00    
---> Package php-xml.x86_64 0:5.3.2-1.el4.remi set to be updated
---> Downloading header for libedit to pack into transaction set.
libedit-20090923-3.0_1.el 100% |=========================| 5.8 kB    00:00    
---> Package libedit.x86_64 0:20090923-3.0_1.el4.rf set to be updated
---> Downloading header for php-pdo to pack into transaction set.
php-pdo-5.3.2-1.el4.remi. 100% |=========================|  19 kB    00:00    
---> Package php-pdo.x86_64 0:5.3.2-1.el4.remi set to be updated
---> Downloading header for php-mysql to pack into transaction set.
php-mysql-5.3.2-1.el4.rem 100% |=========================|  19 kB    00:00    
---> Package php-mysql.x86_64 0:5.3.2-1.el4.remi set to be updated
--> Running transaction check
--> Processing Dependency: libsqlite.so.0()(64bit) for package: php-pdo
--> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16)(64bit) for package: php-mysql
--> Processing Dependency: libmysqlclient.so.16()(64bit) for package: php-mysql
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for sqlite2 to pack into transaction set.
sqlite2-2.8.17-2.el4.remi 100% |=========================| 5.2 kB    00:00    
---> Package sqlite2.x86_64 0:2.8.17-2.el4.remi set to be updated
---> Downloading header for mysql-libs to pack into transaction set.
mysql-libs-5.1.45-1.el4.r 100% |=========================|  24 kB    00:00    
---> Package mysql-libs.x86_64 0:5.1.45-1.el4.remi set to be updated
--> Running transaction check
--> Processing Dependency: libmysqlclient.so.15()(64bit) for package: perl-DBD-MySQL
--> Processing Dependency: libmysqlclient.so.15(libmysqlclient_15)(64bit) for package: mysql-server
--> Processing Dependency: libmysqlclient_r.so.15(libmysqlclient_15)(64bit) for package: mysql-server
--> Processing Dependency: libmysqlclient.so.15()(64bit) for package: mysql-server
--> Processing Dependency: libmysqlclient.so.15(libmysqlclient_15)(64bit) for package: perl-DBD-MySQL
--> Processing Dependency: mysql-libs = 5.0.82sp1-1.el4_8 for package: mysql
--> Processing Dependency: libmysqlclient.so.15(libmysqlclient_15)(64bit) for package: mysql
--> Processing Dependency: libmysqlclient.so.15()(64bit) for package: mysql
--> Processing Dependency: libmysqlclient_r.so.15()(64bit) for package: mysql-server
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for mysqlclient15 to pack into transaction set.
mysqlclient15-5.0.67-1.el 100% |=========================| 3.9 kB    00:00    
---> Package mysqlclient15.x86_64 0:5.0.67-1.el4.remi set to be updated
---> Package perl-DBD-mysql.x86_64 0:4.013-1.el4.rf set to be updated
---> Downloading header for mysql to pack into transaction set.
mysql-5.1.45-1.el4.remi.x 100% |=========================|  19 kB    00:00    
---> Package mysql.x86_64 0:5.1.45-1.el4.remi set to be updated
---> Downloading header for mysql-server to pack into transaction set.
mysql-server-5.1.45-1.el4 100% |=========================|  27 kB    00:00    
---> Package mysql-server.x86_64 0:5.1.45-1.el4.remi set to be updated
--> Running transaction check
--> Processing Dependency: libmysqlclient.so.14(libmysqlclient_14)(64bit) for package: perl-DBD-mysql
--> Processing Dependency: libmysqlclient.so.14()(64bit) for package: perl-DBD-mysql
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for mysqlclient14 to pack into transaction set.
mysqlclient14-4.1.22-1.el 100% |=========================| 5.5 kB    00:00    
---> Package mysqlclient14.x86_64 0:4.1.22-1.el4.remi set to be updated
--> Running transaction check
 
Dependencies Resolved
 
=============================================================================
Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
perl-DBD-mysql          x86_64     4.013-1.el4.rf   rpmforge          228 k
     replacing  perl-DBD-MySQL.x86_64 4.008-1.el4s1
 
Updating:
php                     x86_64     5.3.2-1.el4.remi  remi              1.4 M
Installing for dependencies:
libedit                 x86_64     20090923-3.0_1.el4.rf  rpmforge          265 k
mysqlclient14           x86_64     4.1.22-1.el4.remi  remi              1.2 M
mysqlclient15           x86_64     5.0.67-1.el4.remi  remi              1.3 M
sqlite2                 x86_64     2.8.17-2.el4.remi  remi              161 k
Updating for dependencies:
mysql                   x86_64     5.1.45-1.el4.remi  remi              1.0 M
mysql-libs              x86_64     5.1.45-1.el4.remi  remi              1.7 M
mysql-server            x86_64     5.1.45-1.el4.remi  remi               11 M
php-cli                 x86_64     5.3.2-1.el4.remi  remi              2.6 M
php-common              x86_64     5.3.2-1.el4.remi  remi              963 k
php-mysql               x86_64     5.3.2-1.el4.remi  remi              155 k
php-pdo                 x86_64     5.3.2-1.el4.remi  remi              177 k
php-xml                 x86_64     5.3.2-1.el4.remi  remi              232 k
 
Transaction Summary
=============================================================================
Install      5 Package(s)        
Update       9 Package(s)        
Remove       0 Package(s)        
Total download size: 22 M
Is this ok [y/N]: y
Downloading Packages:
(1/14): php-xml-5.3.2-1.e 100% |=========================| 232 kB    00:04    
(2/14): libedit-20090923- 100% |=========================| 265 kB    00:04    
(3/14): php-common-5.3.2- 100% |=========================| 963 kB    00:15    
(4/14): mysqlclient15-5.0 100% |=========================| 1.3 MB    00:23    
(5/14): php-cli-5.3.2-1.e 100% |=========================| 2.6 MB    00:35    
(6/14): perl-DBD-mysql-4. 100% |=========================| 228 kB    00:04    
(7/14): php-pdo-5.3.2-1.e 100% |=========================| 177 kB    00:05    
(8/14): mysql-5.1.45-1.el 100% |=========================| 1.0 MB    00:15    
(9/14): sqlite2-2.8.17-2. 100% |=========================| 161 kB    00:05    
(10/14): mysqlclient14-4. 100% |=========================| 1.2 MB    00:15    
(11/14): mysql-server-5.1 100% |=========================|  11 MB    01:59    
(12/14): php-5.3.2-1.el4. 100% |=========================| 1.4 MB    00:23    
(13/14): mysql-libs-5.1.4 100% |=========================| 1.7 MB    00:23    
(14/14): php-mysql-5.3.2- 100% |=========================| 155 kB    00:04    
warning: rpmts_HdrFromFdno: V3 DSA signature: NOKEY, key ID 00f97f56
Public key for php-xml-5.3.2-1.el4.remi.x86_64.rpm is not installed
Retrieving GPG key from http://rpms.famillecollet.com/RPM-GPG-KEY-remi
Importing GPG key 0x00F97F56 "Remi Collet "
Is this ok [y/N]:
 
Key imported successfully
warning: only V3 signatures can be verified, skipping V4 signature
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
 
WARNING : This php-* RPM are not official Fedora build and
overrides the official ones. Don't file bugs on Fedora Project.
 
Use dedicated forums http://forums.famillecollet.com/
 
  Updating  : php-common                                           [ 1/24]warning: /etc/php.ini created as /etc/php.ini.rpmnew
  Updating  : php-common                   ####################### [ 1/24]
  Installing: mysqlclient15                ####################### [ 2/24]
warning: only V3 signatures can be verified, skipping V4 signature
 
WARNING : This MySQL RPM is not an official Fedora build and it
overrides the official one. Don't file bugs on Fedora Project.
Use dedicated forums http://forums.famillecollet.com/
 
  Updating  : mysql-libs                                           [ 3/24]warning: /etc/my.cnf created as /etc/my.cnf.rpmnew
  Updating  : mysql-libs                   ####################### [ 3/24]
  Updating  : mysql                        ####################### [ 4/24]
  Installing: mysqlclient14                ####################### [ 5/24]
  Installing: sqlite2                      ####################### [ 6/24]
  Updating  : php-pdo                      ####################### [ 7/24]
  Installing: libedit                      ####################### [ 8/24]
  Updating  : php-cli                      ####################### [ 9/24]
  Updating  : php                          ####################### [10/24]
  Updating  : php-mysql                    ####################### [11/24]
  Updating  : php-xml                      ####################### [12/24]
  Installing: perl-DBD-mysql               ####################### [13/24]
  Updating  : mysql-server                 ####################### [14/24]
  Cleanup   : php-xml                      ####################### [15/24]
  Cleanup   : php-common                   ####################### [16/24]
  Cleanup   : php-cli                      ####################### [17/24]
  Removing  : perl-DBD-MySQL               ####################### [18/24]
  Cleanup   : php-pdo                      ####################### [19/24]
  Cleanup   : mysql                        ####################### [20/24]
  Cleanup   : mysql-server                 ####################### [21/24]
  Cleanup   : php                          ####################### [22/24]
  Cleanup   : mysql-libs                   ####################### [23/24]
  Cleanup   : php-mysql                    ####################### [24/24]
 
Installed: perl-DBD-mysql.x86_64 0:4.013-1.el4.rf
Dependency Installed: libedit.x86_64 0:20090923-3.0_1.el4.rf mysqlclient14.x86_64 0:4.1.22-1.el4.remi mysqlclient15.x86_64 0:5.0.67-1.el4.remi sqlite2.x86_64 0:2.8.17-2.el4.remi
Updated: php.x86_64 0:5.3.2-1.el4.remi
Dependency Updated: mysql.x86_64 0:5.1.45-1.el4.remi mysql-libs.x86_64 0:5.1.45-1.el4.remi mysql-server.x86_64 0:5.1.45-1.el4.remi php-cli.x86_64 0:5.3.2-1.el4.remi php-common.x86_64 0:5.3.2-1.el4.remi php-mysql.x86_64 0:5.3.2-1.el4.remi php-pdo.x86_64 0:5.3.2-1.el4.remi php-xml.x86_64 0:5.3.2-1.el4.remi
Replaced: perl-DBD-MySQL.x86_64 0:4.008-1.el4s1
Complete!

When this was done, I just synced /etc/php.ini with the new one /etc/php.ini.rpmnew and /etc/my.cnf with /etc/my.cnf.rpmnew when this was done I just restarted mysql and apache and I php5.3 was now available.

Categories: Linux, configuration Tags:

Compressing/Decompressing mysql dumps on the fly

February 17th, 2010 Ivan Villareal No comments

Using pipes and redirection in the shell we can do backups or restore them, performing compression or decompression on the fly, this are the commands I frequently use:

Create a backup with mysqldump and compress the stream with bzip2

ivan@mini:~$ mysqldump –h dbHost –u dbUser –pdbPass –add-drop-database –databases <dbname> | bzip2 > dbName-02-17-2010.sql.bz2</dbname>

If I want to restore the backup I use:

ivan@mini:~$ bunzip2 < dbName-02-17-2010.sql.bz2 | mysql –h dbHost –u dbUser –pdbPass

I can switch bzip2 compression by changing only the program name for example gzip/gunzip lzma/unlzma

Categories: Linux Tags: , , , , , ,

Setting up a new centos VPS server from console

February 15th, 2010 Ivan Villareal 3 comments

I just got a couple of vps servers, that I have to configure to run some apps, this are the tasks I did to have them ready for production use:

 

This servers didn’t came with a control panel (better for me), so the first thing I did was to login:

ivan@mini:~$ ssh root@23.45.12.56

After this I checked the OS, version and architecture

[root@V100205C4HB9V-1 ~]# cat /etc/*release*
CentOS release 5.4 (Final)
[root@V100205C4HB9V-1 ~]# uname -a
Linux V100205C4HB9V-1 2.6.18-028stab064.7 #1 SMP Wed Aug 26 13:11:07 MSD 2009 x86_64 x86_64 x86_64 GNU/Linux
[root@V100205C4HB9V-1 ~]#

Ok, now that I know the OS I create a normal user to avoid using the root account.

[root@V100205C4HB9V-1 ~]# useradd –Gwheel ivan

Then I change the server name to mygdon

[root@V100205C4HB9V-1 /]# sed -i 's/V100205C4HB9V-1/mygdon/g' /etc/sysconfig/network
[root@V100205C4HB9V-1 ~]# sed -i 's/V100205C4HB9V-1/mygdon/g' /etc/hosts
[root@V100205C4HB9V-1 ~]# echo HOST.DOMAIN.com > /etc/hostname
[root@V100205C4HB9V-1 ~]# hostname -F /etc/hostname

Unfortunately I was unable to persist the new hostname, because it is a VPS server, there are ways around this, but didn’t have the time to make the changes so I just moved on, and leave this for later

The next thing I did was update the OS, and add the rpmforge repo because I will need some apps from there

[root@V100205C4HB9V-1 ~]# yum update
[root@V100205C4HB9V-1 ~]# yum upgrade
[root@V100205C4HB9V-1 ~]# wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm
[root@V100205C4HB9V-1 ~]# rpm -Uhv rpmforge-release-0.5.1-1.$dist.rf.$arch.rpm
[root@V100205C4HB9V-1 ~]# yum update
[root@V100205C4HB9V-1 ~]# yum upgrade

Then I installed some packages I often use:

[root@V100205C4HB9V-1 ~]# yum install htop screen vim-enhanced

The VPS already had a web stack installed I just did some configuration:

Configuring Apache Virtual Hosts

[root@V100205C4HB9V-1 ~]# mkdir /var/www/vhosts/{site1, site2} –p
[root@V100205C4HB9V-1 ~]# vi /etc/httpd/conf/httpd.conf

Here I Uncommented the following directive

NameVirtualHost *:80

and Added a default vhost a new vhost

<virtualhost *:80>
    DocumentRoot /var/www/vhosts/default
    ServerName mygdon.site1.net
    <directory /var/www/vhosts/default>
        Options Indexes FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </directory>
    ErrorLog logs/mygdon.site1.net-error_log
    CustomLog logs/mygdon.site1.net-access_log common
</virtualhost>
 
<virtualhost *:80>
    DocumentRoot /var/www/vhosts/site2
    ServerName appname.site2.net
    <directory /var/www/vhosts/site2>
        Options Indexes FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </directory>
    ErrorLog logs/appname.site2.net-error_log
    CustomLog logs/appname.site2.net-access_log common
</virtualhost>

then restarted the apache server:

[root@V100205C4HB9V-1 ~]# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting  httpd:                                            [  OK  ]

and  I wrote a simple php file to test this out:

[root@V100205C4HB9V-1 ~]# echo '&lt;? phpinfo(); ?&gt;' > /var/www/vhosts/site1/index.php

And because I haven’t configured a DNS server I just temporarily added the server to my hosts file (On my local machine):

root@mini:/etc# echo 'subdomain.site1.net 54.65.74.23' > /etc/hosts

and here is the result:

testing-vhost 

Configuring Mysql

Once I had the virtual hosts configuration in place I added a mysql user and changed the default root password:

 

[root@V100205C4HB9V-1 vhosts]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.0.77 Source distribution
 
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
 
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
+--------------------+
3 rows in set (0.00 sec)
 
mysql> UPDATE mysql.user SET Password=PASSWORD('pass-here') WHERE user='root';
Query OK, 3 rows affected (0.02 sec)
Rows matched: 3  Changed: 3  Warnings: 0
 
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)
 
mysql> CREATE USER 'ivan'@'localhost' IDENTIFIED BY 'pass-here';
Query OK, 0 rows affected (0.01 sec)
 
mysql> GRANT ALL PRIVILEGES ON *.* TO 'ivan'@'localhost' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
 
mysql> CREATE USER 'ivan'@'%' IDENTIFIED BY 'pass-here';
Query OK, 0 rows affected (0.00 sec)
 
mysql> GRANT ALL PRIVILEGES ON *.* TO 'ivan'@'%' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
 
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
 
mysql>

 

Now the server is  ready for adding some virtual hosts, I just need to configure a DNS server and the mail server, but because the DNS is on another server and already working I just have to add a new zone, as for mail server, this server will be only used to send emails so I don’t need to dig in postfix configuration files for now.

I’ll write another post regarding the security, but for now this will work.

Categories: Linux Tags: , , , , ,

Ubuntu 9.10 on an hp mini 110-1125nr

January 26th, 2010 Ivan Villareal No comments

I got this new mini 110, it came with Windows 7 Starter, and after a day of using it I was very frustrated because it was very limiting, for example, I was unable to change my Desktop background, the network management is confusing and frustrating, and it had a lot of crapware, except for the hp games, that some of them are fun.

Anyway, right now I don’t have time to spend getting a new OS on this machine, I just want something that works, I don’t plan using this to work, but I would like to have some of the tools I use into this.

So my options were, trying Ubuntu remix or Windows Xp, after checking that hp had the drivers for XP, I was going to change Windows 7 to Xp, but I was reading how to create a USB boot drive, and it was too much hassle for me. (I’m very lazy for any Microsoft stuff).

My next option was Ubuntu remix, I’m not a big fan of Ubuntu, but I wanted something to just worked out of the box, also this little netbook comes with splashtop, a really nice feature for checking stuff online fast, and I didn’t want to loose this so I really didn’t knew how well this was going to work.

I started downloading Ubuntu 9.10 Karmic yesterday night, just in case, Today after more frustrating things, I decided to give Karmic a try.

I grabbed my usb pendrive, a 1gb  kingston traveler, mounted the iso and ran usbinst.exe, it was pretty straightforward, my only advice to you would be to avoid saving space for your documents in the usb, my first try I set this to 30Mb and the boot failed, so I set the do not save feature.

It took about 40 minutes to finish copying the files, after it was done, I restarted the netbook with the pendrive connected, and at the first boot screen I pressed F9 key for booting options, selected the pendrive and that was it.

After testing ubuntu from the pendrive, it ran pretty well and everything but the wifi worked, I did an installation, keeping the windows partition and the hp restore partition, just in case.

The installation was pretty smooth, no issues at all, after the first boot I just installed the broadcom drivers, it was pretty easy with the driver manager in ubuntu, and the wifi was working

Update: My hp mini was stolen by a couple of elderly people, I saw the video :( , so I’m unable to play more with this, but the time I had this I was very happy with it, it performed well.

Categories: Hardware, Linux Tags: , ,