Páginas

quarta-feira, 28 de dezembro de 2011

Apache: Senha diretorio

O servidor Web Apache ajuda com o arquivo .htaccess que direciona o controle de cada pasta lida no servidor.
Primeiramente você deve criar um arquivo que contém o login e senha. Para isso utilize o comando:

# cd /diretorio/protegido

# htpasswd -c .htpasswd USER

A senha será solicitada e então cria-se um arquivo com o nome .htpasswd

# vim .htaccess

Insira as linhas:

AuthUserFile /home/usuario/.htpasswd
AuthType Basic
AuthName "Restrito"
Require valid-user

sábado, 24 de dezembro de 2011

FreeBSD: Erro instalação iRedMail

postfix instalation fail

############################################################################
Try this:
* When you get this error, try to Install mail/postfix26/ manually:
# cd /usr/ports/mail/postfix26/
# make clean
# make install clean
* If postfix is installed with above step, edit iRedMail-0.6.1/.iRedMail.installation.status, append this line:
export status_install_port_mailpostfix26='DONE'
* Re-execute iRedMail.sh script:
# bash iRedMail.sh

FONTE: http://www.iredmail.org/forum/topic1171-installation-failing-in-freebsd80-with-iredmail061.html
############################################################################

I also ran into this issue while installing 0.7.0-beta2. This will require a fix before .7 is released. Here is what I did to fix it based on directions from link above.

cd /usr/ports/mail/postfix26
make deinstall reinstall clean

Once complete, edit iRedMail-0.7.0-beta2/.iRedMail.installation.status and add the following line:

export status_install_port_mailpostfix26='DONE'


No meu caso, utilizo postfix 2.7. Fica "mailpostfix27".

FONTE: http://code.google.com/p/iredmail/issues/detail?id=52

sábado, 10 de dezembro de 2011

MySQL: Permissão para acesso remoto

Para quem tem um servidor com IP fixo e quer liberar o acesso remoto ao MySQL pela internet exigindo nome de usuário e senha, o comando é simples:

grant all privileges on BD.TABELA to usuário identified by "senha";

Exemplo:

mysql> grant all privileges on LOJA.* to ze identified by "123456";

Para quem quer restringir o acesso a um IP fixo (rede local sem DHCP ou Internet com ADSL Business):

mysql> grant all privileges on LOJA.* to ze@192.168.10.15 identified by "123456";

Para conectar use:

$ mysql -h 200.156.12.2 -D LOJA -u ze -p
Enter Passwd: 123456

quinta-feira, 8 de dezembro de 2011

Cron

#minute (0-59)
#| hour (0-23)
#| | day of the month (1-31)
#| | | month of the year (1-12 or Jan-Dec)
#| | | | day of the week (0-6 with 0=Sun or Sun-Sat)
#| | | | | commands
#| | | | | |
### rotate logs weekly (Sunday at 12midnight)
00 0 * * 0 squid -k rotate

sexta-feira, 2 de dezembro de 2011

FreeBSD: Installing PHP 5

A tutorial on installing PHP from the FreeBSD ports for Apache and MySQL. What you need to add to the httpd.conf file and which of the PHP5 ports to choose.

Choosing which port to use
In the past there were several ports for PHP such as /www/mod-php5, /lang/php5-cli, and /lang/php5. Since the release of PHP 5.1.14 there is now only /lang/php5 This port now allows you to choose if you want to install the CLI, CGI, and Apache module.

CLI stands for command line interpreter. It is used for running PHP scripts from the command line and makes creating shell scripts very simple if you already know PHP. The Apache PHP Module is disabled by default, so make SURE that if you plan to use this for web work that you enable it.

Installing the port
Since all PHP ports are now combined you will need to configure it to be sure the parts you need are built.

# cd /usr/ports/lang/php5
# make config
# make install
When you run make config you will be shown a list of options. To use PHP with Apache make sure the Apache Module box is selected.

Once php has installed you will need to install the extra modules for things such as MySQL. These modules are all located in the ports. Some of the most common modules are

/usr/ports/databases/php5-mysql - MySQL Database
/usr/ports/www/php5-session - Sessions
/usr/ports/graphics/php5-gd - Graphics Library
Adding the PHP 5 module to Apache
Apache needs the following lines in the httpd.conf file to use php. These lines should already be added by the port but if you have problems you should double check your httpd.conf file. Note that Apache 2.x does not need the AddModule line.

# Apache 1.3.x
LoadModule php5_module libexec/apache/libphp5.so
AddModule mod_php5.c
# Apache 2.x
LoadModule php5_module libexec/apache/libphp5.so
If you installed using the port and had apache installed already it should do this automatically for you.

Next find your DirectoryIndex section in your httpd.conf file. Apache is set up for PHP 4, but not PHP 5 currently so you will need to modify it and change the 4s to 5s like this.




DirectoryIndex index.php index.php3 index.html


DirectoryIndex index.php3 index.html




DirectoryIndex index.php index.html index.htm


DirectoryIndex index.html



This code is telling Apache to open index.php first you have the PHP 5 module loaded. You can change the order as you wish. Or if you just wanted to skip it you could simply add the following line to the httpd.conf file since you know you are going to have php 5.

DirectoryIndex index.php index.html index.htm
Now apache just needs to know what it should parse the PHP files with. These two lines should be added to the httpd.conf file, and can be put at the bottom if needed.

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
If want to use PHP code inside of .htm files you can just add on those extensions.

AddType application/x-httpd-php .php .htm .html
Configuring PHP
Settings for PHP are stored in /usr/local/etc/php.ini You will need to create this file by copying it from /usr/local/etc/php.ini-dist

# cp /usr/local/etc/php.ini-dist /usr/local/etc/php.ini
In this file you can set the memory limit for programs. Turn on global variables if you must, set the max file upload size, and everything else you need.

Testing PHP
Once you have restarted Apache so the changes take effect you are ready to test it. To test it run the following command to create a php file that you can attempt to run

# echo "" >> /usr/local/www/data/test.php
Then point your web browser to http://yourdomain.com/test.php and if it works you will see several pages of information on your PHP settings. If it did not work you will see only the text you typed in.