Skip to content

Commit

Permalink
[+] Fix permission of public_html
Browse files Browse the repository at this point in the history
[*] Nginx logs in home directory
  • Loading branch information
Viktor Shulika committed Aug 30, 2010
1 parent 75a700f commit 805fe30
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
3 changes: 2 additions & 1 deletion config.info
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ conf_dir=Config directory,3,Default (/etc/nginx/)
sites_available_dir=sites-available subdirectory,3,Default (sites-available/)
sites_enabled_dir=sites-enabled subdirectory,3,Default (sites-enabled/)
nginx_pid=pid file,3,Default (/var/run/nginx.pid)
log_dir=Log directory,3,Default (/var/log/nginx/)
log_dir=Log directory,3,Default ({HOME}/logs/)
public_html_perm=public_html directory permissions,3,Default (0755)
23 changes: 15 additions & 8 deletions virtual_feature.pl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@

if($config{'log_dir'} eq "")
{
$log_dir = '/var/log/nginx/';
my ($d) = @_;
$log_dir = "$d->{'home'}/logs/";
}

sub feature_always_links
Expand Down Expand Up @@ -182,6 +183,7 @@ sub feature_setup

open($file, ">" . $conf_dir . $sites_available_dir . $d->{'dom'} . ".conf");
#TODO in config.info add nginx config template with default value conf_tmpl=nginx config template,9,server{ listen $d->{'ip'}:80;} or get it from nginx_conf.tpl and parse
#TODO Determine subdomain and dont put rewrite ^/(.*) http://www.$d->{'dom'} permanent;
my $conf = <<CONFIG;
server {
listen $d->{'ip'}:80;
Expand All @@ -208,13 +210,6 @@ sub feature_setup
expires 30d;
}
#location / {
#root $d->{'home'}/public_html;
#index index.php index.html index.htm;
#}
location ~ \.php\$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
Expand All @@ -232,6 +227,7 @@ sub feature_setup
symlink($conf_dir . $sites_available_dir . $d->{'dom'} . ".conf", $conf_dir . $sites_enabled_dir . $d->{'dom'} . ".conf");

reload_nginx();
fix_perm();

&$virtual_server::second_print(".. done");

Expand Down Expand Up @@ -261,4 +257,15 @@ sub reload_nginx
#TODO test nginx conf = nginx -t
my $pid = `cat $nginx_pid`;
`kill -HUP $pid`;
}

sub fix_perm
{
# TODO nginx run as www-data, default perm on public_html in Virtualmin 0740 Sequrity alert if chmod 0755
my ($d) = @_;
if($config{'public_html_perm'} eq "")
{
$public_html_perm = '0755';
}
chmod $public_html_perm, "$d->{'home'}/public_html/";
}

0 comments on commit 805fe30

Please sign in to comment.