Category: Aprendendo

Jul 04 2009

Install Apache2, PHP5, PHPmyAdmin, MySQL

Hello,

I will just show how to quickly install Apache 2, PHP5, MYSQL and PHPmyAdmin in Ubuntu.

Install apache2 with:

$ sudo apt-get install apache2

Install PHP5:

$ sudo apt-get install php5 php5-common php5-cli

Install MYSQL:

$ sudo apt-get install mysql-client mysql-server

(During the installation it will ask you password for root user of MySQL)

Install PHPMyAdmin:

$ sudo apt-get install phpmyadmin

(It will ask the MySQL password and of the PHPMyAdmin user)

Best Regards,
Matheus

Jun 15 2009

Update End Point, TunnelBroker

Hello,

If you want to UPDATE your tunnelbroker end point, you can use this: http://ipv4.tunnelbroker.net/ipv4_end.php

There are the format that you have to use. In /etc/rc.local file I add this line to get my IPADDRESS:

IP=`ifconfig eth0 | grep “inet addr” | cut -d : -f 2 | cut -d B -f 1 | sed ‘s/^ *//;s/ *$//’`

And after this one to update the ENDPOINT

wget https://ipv4.tunnelbroker.net/ipv4_end.php?ipv4b=$IP&pass=senha&user_id=USERID&tunnel_id=TUNNELID

Best Regards,
Matheus

Jun 07 2009

Open ping in server from one IP

Good Night,

If you want to enable PING in your SERVER just from ONE IP use this IPtables rule:

$ sudo iptables -A INPUT -p icmp -s 150.162.60.37 -j ACCEPT

Best Regards,
Matheus

Jun 06 2009

Install and Configure DHCP server in Ubuntu

Good night,

If you want to install DHCP server in Ubuntu, use

$ sudo apt-get install dhcp3-server

And then edit /etc/dhcp3/dhcpd.conf I commented all lines and add this ones:

INTERFACES=”eth1″; # INTERFACE CONECATADA AO MEU ROTEADOR
ddns-update-style none;
default-lease-time 600;
max-lease-time 7200;
authoritative; # DHCP PRINCIPAL DA REDE

subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.100 192.168.0.150; # FAIXA DE IPS A SER DISTRIBUIDA
option routers 192.168.0.254; # GATEWAY
option domain-name-servers 200.247.141.11; # SERVIDOR DNS
option subnet-mask 255.255.255.0; # MASCARA DE SUBREDE
option broadcast-address 192.168.0.255; # ENDEREÇO DE BROADCAST
default-lease-time 600;
max-lease-time 7200;
}

Restart eh DHCP server:

$ sudo /etc/init.d/dhcp3-server restart

See you,
Matheus

Reference:
Google + DHCP SERVER UBUNTU

May 26 2009

Share internet in a SERVER connected to WAN port.

Hello,

The last days I keep trying to configure my server. I know how to configure the network to this:

MODEM -> (eth0) Servidor (eth1) -> (LAN Port) Router (LAN Ports) -> Computers

This topology don`t work for me, because in this way I lost one WAN Port. So I thought in this topology:

MODEM -> (eth0) Servidor (eth1) -> (Porta WAN) Router (Portas LAN) -> Computadores

First of all configure your eth1 manyally as (edit /etc/network/interfaces):

auto eth1
iface eth1 inet static
address 192.168.100.254
netmask 255.255.255.0
network 192.168.100.0
broadcast 192.168.100.255

After this I add this iptables rules:

sysctl net.ipv4.ip_forward=1
iptables -t nat -A POSTROUTING –out-interface eth0 -j MASQUERADE
iptables -A FORWARD –in-interface eth0 -j ACCEPT

I need to setup the router manually:

IP Address : 192.168.100.1
Subnet Mask : 255.255.255.0
ISP Gateway Address : 192.168.100.254
Primary DNS Address : 200.247.141.11 (DNS)
Secondary DNS Address : 200.247.141.12 (DNS)

So up and running

Matheus

May 24 2009

Install Ubuntu from Pendrive

Hello,

Today I will just recomment to you the post of Juliano Martins about how o install Ubuntu from pendrive.

UPDATE: In the last days I tried the tool from Ubuntu (USB Startup Disk Creaator) and it works!

Best Regards,
Matheus

May 16 2009

Client and Server, Java XML-RPC

Good night,

A few days ago I created a XML-RPC server to test some functions. What is XML-RPC? XML-RPC is a remote procedure call (RPC) protocol which uses XML to encode its calls and HTTP as a transport mechanism.(wikipedia) To start using XML-RPC in Java I used apache xml-rpc.

Example client and server XML-RPC.

Best Regards,
Matheus

May 09 2009

Creating your own Url shortener.

Good Night,

Here I will show you how to create your own url shortener.

First of all you need to create a table like this:

CREATE TABLE IF NOT EXISTS `urls` (
`uid` int(11) NOT NULL auto_increment,
`url` text default NULL,
`unique_chars` varchar(25) BINARY NOT NULL,
PRIMARY KEY (`uid`),
UNIQUE KEY `unique_chars` (`unique_chars`)
);

This code was taken from Abhise in this post “Create your own tinyurl with php and mySQL” that was my bigest reference, from it I took some functions and update other ones to be more efficient. For an example I changed the field to BINARY so it be CASE SENSITIVE (aaaa different from AAAA)

The Abhise says to create many files, I particularly, created one file with all functions where I add all the functions and just called the functions in the files.

Read more »

May 06 2009

Linked List, Data Structure

Hello,

What is a Linked List? Linked-list is a list that each element has a pointer to the next one.

The professor once again send us an enunciation to solve and it is too big. And I will not translate it. Inside the problem it have a Linked list.

Problem using linked-list..

Regards,
Matheus

PS: You can see the enunciation in portuguese and then use google translate to translate it

Read more »

Apr 29 2009

List, with pointers, Data Structure

Hello,

Today I will introduce you to a list using pointers. This list doesn’t have limit of elements (if you have infinite memory). Again the enunciation is too big, so take the file, read it and learn.

Stack with pointers implementation

Regards,
Matheus

PS: You can see the enunciation in portuguese and then use google translate to translate it