segunda-feira, 17 de novembro de 2014

Install PostgreSQL 9.3 on CentOS 7



Open Terminal ( Applications —> System Tools —> Terminal).
Switch to root user.
[raj@itzgeek~/]$ su -

Dependency:

rpm -Uvh ftp://ftp.muug.mb.ca/mirror/centos/7.0.1406/os/x86_64/Packages/uuid-1.6.2-26.el7.x86_64.rpm

Install PosgreSQL 9.1.3:

PostgreSQL publishes rpm packages for all Linux platforms, their packages are generally fresher than those in the other repository. We need to add the repository on our machine by installing repo rpm.
[root@itzgeek~/]# rpm -Uvh http://yum.postgresql.org/9.3/redhat/rhel-7-x86_64/pgdg-centos93-9.3-1.noarch.rpm
Install PostgreSQL 9.3.1 , enable only PostgreSQL repository to install.
[root@itzgeek~/]#  yum install postgresql93 postgresql93-server postgresql93-libs postgresql93-contrib postgresql93-devel --disablerepo=* --enablerepo=pgdg93

Configuring PostgreSQL 9.3.1 server:

Initialize the PostgreSQL.
[root@itzgeek~/]# /usr/pgsql-9.3/bin/postgresql93-setup initdb
PostgreSQL normally listens on the localhosts only, if would you like to enable the PostgreSQL to listen on all ip addresses; edit the /var/lib/pgsql/9.1/data/postgresql.conf .
[root@itzgeek~/]# vi /var/lib/pgsql/9.3/data/postgresql.conf
Go to Connections and Communications section, find the "listen_address" variable. Uncomment the "listen_addresses" and place "*" instead of "localhost"
Before editing:
#listen_addresses = "localhost"
After editing:
listen_addresses = "*"
Add your network to access database remotely; Edit  /var/lib/pgsql/9.3/data/pg_hba.conf.
[root@itzgeek~/]#  vi /var/lib/pgsql/9.3/data/pg_hba.conf
Add the following line according to your network configuration with md5 password authentication (Enable remote access of database).
# IPv4 local connections: host    all             all             127.0.0.1/32            md5 host    all             all             107.155.94.0/24         md5 # IPv6 local connections: host    all             all             ::1/128                 md5
Restart the PostgreSQL server.
[root@itzgeek~/]# systemctl start postgresql-9.3.service
Confirm the PostgreSQL listening.
[root@itzgeek ~/]# netstat -antup | grep 5432 tcp        0      0 0.0.0.0:5432            0.0.0.0:*               LISTEN      39620/postgres tcp6       0      0 :::5432                 :::*                    LISTEN      39620/postgres
Auto start the service on startup.
[root@itzgeek~/]# systemctl enable postgresql-9.3.service

Creating Database:

Login as postgres user.
[root@geeksite~/]$ su -l postgres
create the database called "test"
-bash-4.2$ createdb test
Login into the database.
-bash-4.2$ psql test
Create a new user called "raj" to manage the databases.
test=# CREATE USER raj WITH SUPERUSER LOGIN PASSWORD 'raj';
Login with the superuser.
sam@geeksite~/$ psql -h localhost -d test -U raj
That's all!. You have successfully installed the PostgreSQL 9.3 on CentOS 7 / RHEL 7.

segunda-feira, 26 de maio de 2014

Remove NULL values from PHP arrays with 1 line [Linux]

Remove NULL values from PHP arrays with 1 line

I had an array with something like the following: Array ( [0] => [1] => test [2] => fun ). But I don't want [0], the empty value in the array.

After searching the web for a good solution, I saw that people were using anywhere from 4 to 10+ lines of code to remove null values from arrays. This is obviously overkill so I decided to tackle the problem myself.

Remove NULL values only

$new_array_without_nulls = array_filter($array_with_nulls, 'strlen');

Remove any FALSE values

This includes NULL values, EMPTY arrays, etc. Thanks to Paul Scott for pointing out this method.

$new_array_without_nulls = array_filter($array_with_nulls);

 

terça-feira, 20 de maio de 2014

Jail only a specific user with vsftpd [Linux]

You have 2 options:

 

chroot_local_user=YES

chroot_list_enable=YES

chroot_list_file=/etc/vsftpd/nonchroot.list

 

# Where file /etc/vsftpd/nonchroot.list should contail the users you don’t want to chroot.

 

OR

 

chroot_list_enable=YES

chroot_list_file=/etc/vsftpd/chroot.list

 

Where the file /etc/vsftpd/chroot.list should contain the users you want to be chrooted to their home. By default all other users should have access to the / (root)

quarta-feira, 30 de abril de 2014

Substituir caracteres por quebra de linha

Quebra de linha manual ( )

 

No Word lica em substituir, ou CTRL + L:

 

Digita o termo de busca, e no outro digite: ^l or ^11