sobota, 10 września 2011

Drupal na FreeBSD

Soft:
host - FreeBSD8.2_64
nginx - 1.06
php - 5.3.8
mysql - 5.5.15
drupal - 7.8
php-fpm - 5.3.8

# portmaster www/drupal7 www/nginx databases/mysql55-server

Autostart:

# ee /etc/rc.conf
nginx_enable="YES"
mysql_server_enable="YES"
php_fpm_enable="YES"

Plik konfiguracyjny nginx

# ee /usr/local/etc/nginx/nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

sendfile on;
keepalive_timeout 65;

server {
server_name mail1.domena.pl;
root /usr/local/www/drupal7; ## <-- Ścieżka do katalogu drupala.

location = /favicon.ico {
log_not_found off;
access_log off;
}

location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}

# This matters if you use drush
location = /backup {
deny all;
}
location ~ \..*/.*\.php$ {
return 403;
}

location / {
# This is cool because no php is touched for static content
try_files $uri @rewrite;
}

location @rewrite {
# Some modules enforce no slash (/) at the end of the URL
# Else this rewrite block wouldn't be needed (GlobalRedirect)
rewrite ^/(.*)$ /index.php?q=$1;
}

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/www/drupal7$fastcgi_script_name;
include fastcgi_params;
}

# Fighting with ImageCache? This little gem is amazing.
location ~ ^/sites/.*/files/imagecache/ {
try_files $uri @rewrite;
}
# Catch image styles for D7 too.
location ~ ^/sites/.*/files/styles/ {
try_files $uri @rewrite;
}

location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}

}

Baza danych dla drupala:
hasło dla roota

mysqladmin -u root password tutaj_hasło

baza drupal:

mysql -u root -p
mysql> create database drupal;
mysql> grant all on drupal.* to drupal@localhost identified by 'tutaj_hasło_dla_użytkownika_drupal';
mysql> flush privileges;
mysql> exit

Start demonów

/usr/local/etc/rc.d/nginx start
/usr/local/etc/rc.d/mysql-server start
/usr/local/etc/rc.d/php-fpm start