+20
New website custom defaults
Hi, it will be nice to have an option to set custom defaults when we create a new website in Ajenti V.
Cases of use:
1- We have a particular directory structure: /home/www/websitename/public_html but when we create a new website the default root is /srv/new-website and we have to change the root directory manually to fit our structure. The ideal situation is to be able to configure a default directory using wildcards replacement. Example: /home/www/%websitename%/public_html
2- Another example is the custom nginx config. We have an nginx conf file that applyes a generic config in terms of static files caching, security rules, etc., this file is located in /etc/nginx.templates.d/genericrules.conf and in every new website created we include that file writing:
include /etc/nginx.templates.d/generic_vhost.conf;
in custom conf in advance tab.
It would be great to be able to configure a default value.
3- It would be interesting also to configure the possibility that when you create a new site, also create a php pool with certain parameters.
Thx for all !
Cases of use:
1- We have a particular directory structure: /home/www/websitename/public_html but when we create a new website the default root is /srv/new-website and we have to change the root directory manually to fit our structure. The ideal situation is to be able to configure a default directory using wildcards replacement. Example: /home/www/%websitename%/public_html
2- Another example is the custom nginx config. We have an nginx conf file that applyes a generic config in terms of static files caching, security rules, etc., this file is located in /etc/nginx.templates.d/genericrules.conf and in every new website created we include that file writing:
include /etc/nginx.templates.d/generic_vhost.conf;
in custom conf in advance tab.
It would be great to be able to configure a default value.
3- It would be interesting also to configure the possibility that when you create a new site, also create a php pool with certain parameters.
Thx for all !
Customer support service by UserEcho
- Find file "api.py" (path /var/lib/ajenti/plugins/vh/api.py on my CentOS 6 system)
- Edit line 41, replace '/srv/new-website' with '/var/'+j['name'], so the whole line should look like this: self.root = j.get('root', '/var/'+j['name']) instead. (you can also modify it to your own needs. you can add +'/public_html' at the end of bracket, like this '/var/'+j['name']+'/public_html')
- Save file and restart Ajenti.
This will change the default template directory. Just beware that after an update package manager will most likely replace this file, so you would have to do it again.I also highly recommend you to backup the original file in case you made a mistake like missing ', so you can revert it back.
Solution for suggestion number two is to edit the same file as above, and just 2 lines below we have
self.custom_conf = j.get('custom_conf', '').
Now, we can insert our custom-default conf here.
self.custom_conf = j.get('custom_conf', 'include /etc/nginx.templates.d/generic_vhost.conf;')
I know almost nothing about Python, so your help served me a lot.
awesome flip, what about self.custom_conf for apache? what should i include there for the default template configuration?
May I suggest to move line 45 "self.slug=..." just after line 32 "self.name=..." and then in line 42 replacing with j.get('root', '/var/www/'+self.slug+'/public_html') or anything else than /var/www but you get a slugged path, compliant with nginx.
Thanks for the original trick !
Hi, How can I change it to display the username like: /srv/[username]/new-website
thanks in advance
'server_name': (
'server_name %s;' % (' '.join(domain.domain for domain in website.domains))
Does anyone know how to adjust this so that it automatically adds the www subdomain to each vhost? Right now I need to add the www as a separate domain in Ajenti for each domain added.
Should look like
server_name www.example.com example.com;
The way ajenti website creation works, it isn't possible. When you create a new page, you enter website name only (identificator), not server_name (domain), that is "example.com" by default. I could tell you, how to set server_name to website name and then add www to it automatically, though.
- sudo systemctl restart nginx - CentOS 7, ArchLinux
- sudo service nginx restart - Ubuntu, Centos 6.x, Debian
If that doesn't work, check your configuration - If you have domain properly configured etc