CustomBuild Nginx edition

As this is about to be released, I was wondering how people are going to use it? The main issue for shared hosting still seems to be the per user config which has to be done manually.
 
Hello,

We're going to take it in steps.
Since the next release of DA has many fixes/features, we're only going to include the vanilla release of nginx for alpha.. pre-alpha even.
We're new to it, so won't be able to offer support for it until we fully get a handle on how it works.

That being said, once it's well tested, we can start looking at good ways to customize it.

If all goes well, DA 1.43.0 RC1 should be out within a week. (skipping 1.42.2, since there are so many changes)

John
 
Hi John,
thanks for this update
we will wait after this big release and then the alpha for nginx edition

Keep up the wonderful work!

Best Regards,
Star Network
 
I will wait to see how it runs on others machines before I change to it for a production server.
 
I wrote a "total" conversion for DA to ditch Apache and make it work with Nginx and PHP5-FPM. I did this because of one customer who simply refused to get rid of DirectAdmin, because he wanted to be able to control all aspects of his machine without having to rely on a system administrator.

After implementing this conversion however, I discovered two things:

1. Nginx + PHP5-FPM is far superior than Apache with mod_php, in terms of memory and I/O usage. Nginx is simply a much faster, more efficient web server than Apache ever was, by several orders of magnitude.
2. DirectAdmin is so flexible, it actually allowed me to implement this conversion with relative ease!

So I went ahead and installed this on a few more machines that I manage, and I have to say the difference in performance is quite impressive!


Here are the highlights of what I wrote so far:

- Eliminates Apache completely (This is not another "nginx proxying apache" plugin)
- Nginx handles port 80 and 443, with full support for SSL as implemented by DirectAdmin (fully transparent)
- Support for Domain Aliases and Pointers
- Automatically detects the type of site installed by the customer, and implements a correct nginx template for it
- Support for page caching + purging, especially for Wordpress + The Nginx Helper plugin
- So far I wrote templates for the following systems:
- Wordpress (Full caching - Extremely fast!)
--- Wordpress Multisite (Full caching too!)
--- Joomla
--- Droopal
--- Magento
--- Generic PHP Site
- FPM Pools are "ondemand" meaning that the number of running processes are minimized
- Total user separation
- Support for "custom" configs (a config that the generator won't overwrite)
- Able to add/remove sites easily, taking effect immediately
- The .htaccess file is NOT (and never will be) supported, but with the templates above, it is not really needed anymore since "SEO Friendly" URL's are supported out of the box.
- Handles the most common php security issues
- Per user FPM pools + their own php settings, such as the ability to disable_functions per pool, or set other php values per pool, which makes things way more flexible and more secure.
- phpMyAdmin & RoundCube are supported out of the box for all sites "as usual"
- Utilize all the tricks in the Nginx books to optimize access to static files!


Here's what I plan to add in the future:

- Special Nginx page in the panel to:
--- Control per site Nginx caching on/off
--- Specify cookie names & paths that disable caching
--- Button to purge the cache
--- Control rate limiting
--- Password Protect directories
- Support for media streaming with seek support
- Support for memcache caching (Currently caching is done either to the disk, or to a tmpfs ramdisk)
- More templates, including one for Magento that offers the full page cache for extreme performance
- Detect when components like W3 Total Cache generate an nginx.conf and include it automatically
- Detect when custom nginx.conf files are gone, and repair the configs so as not to break nginx
- Support for hot-linking protection for an entire site or per directory


How this conversion works:

I basically tapped the 4 custom templates, and made them generate nginx configurations and php5-fpm configurations in all the right places. More importantly, I have achieved a "sane" and working Nginx and FPM configuration settings that make the sites function really well, allow large file uploads, long running php scripts, and either reduce or completely eliminate Bad Gateway errors (so far I don't see any). This took weeks of painstaking research into nginx and php5-fpm minutiae.

I'm considering releasing this to the public on my own gitlab site, so anyone can fork it, modify it, and enjoy my efforts, but I would love to first get some developers who use DA to join me on the project as developers/testers, and possible contributors to fix the code to make it more flexible, configurable and robust. I don't want someone to think it is a "shelf product" that can just be installed and life is suddenly "pink". Sure, if I install it for you myself it will work great, but there is no "readme" or "install.txt" right now :)

So if you are a PHP developer and you're interested in contributing, contact me and I'll interview you about your setup and experience, and consider you for this early pilot.
 
Last edited:
Are you sure? I don't have any stats but my experience would say the opposite.

I copied everything from my older low-end server (1 MB) to similar specs but with only 768 MB just to test whether everything runs well. I also converted from Apache-mod-php to nginx-php-fpm which was a quite straightforward process. The result was pretty astonishing. The static files flashed to the browser immediately and the PHP part did not any worse. The memory use of a typical CMS page dropped from 1.8 MB to 760 Kb - the 1 MB decrease/request seems to be pretty constant. I am absolutely certain about the results and the funny thing is that my customers noticed the same thing. I told them I had upgraded the server and that it will probably show in the invoice :)

I did have my doubts about the performance and the learning curve but I actually find the nginx configuration easier even though it is also more flexible. I also have several PHP versions running concurrently (5.3, 5,4 and 5.5 alpha for testing) without any problems. If there is script/library/app that needs an older version I can make it work.

I am now dropping Apache completely in all my servers. The .htaccess stuff is not a big deal, after all. Redirection rules are easy to write to nginx (and they perform better there). None of my clients is using .htpasswd (or whatever it was). One can also use domain-specific sections in the php.ini file(s) should one need any fine-tuning, for instance.

That said there may be situations where Apache is necessary but I have not yet found any during the two months of running nginx.
 
That quote of me was about mod_php vs php-fpm without nginx, but like I said in a few posts below that is that it depends on how you configure it.

Maybe you or someone else can answer this (I'm not using php-fpm at this moment), if you use php-fpm for shared hosting then you either have:
- 1 proces for each user idling, consuming memroy
- maybe 0 if that is possible, or maybe 1 and minimized, it needs to fire up when a user visits the website after a while when there wasn't anyone (this may happen a lot on shared hosting with low traffic) -- and this takes time I guess..
Especially with something heavy as magento or a wordpress with a lot of bad plugins.

With mod_php/ruid you've got a couple of processes maintaining all php for all users which on paper sounds more efficient to me.

But if anyone thinks/knows different please tell.
 
You can try nginx with the latest version of CustomBuild 2.0 and DA 1.43 RC1 :) On our testboxes it worked with no problems.
 
I think you forgot to re-install PHP after "./build nginx". Just run the following, it should fix your problems:
Code:
cd /usr/local/directadmin/cuustombuild
./build update
./build php n
 
replay

I think you forgot to re-install PHP after "./build nginx". Just run the following, it should fix your problems:
Code:
cd /usr/local/directadmin/cuustombuild
./build update
./build php n

Sir,

I did your install, i still get 403 error, how about teamvieuwer sessie or skype ?

cd /usr/local/directadmin/custombuild
./build update
./build php n
 
User contacted me and his problem was:
Code:
root@nginx-testserver:/usr/local/directadmin# ./directadmin o
Compiled on 'Debian 6.0 64-bit'
Compile time: Dec  4 2012 at 00:18:10
Compiled with IPv6

Which means that he was running an old version of DirectAdmin. Please note that CustomBuild 2.0 needs DirectAdmin 1.43 RC1 at least.
 
I just completed an install with 1.43 RC1 with the newest custombuild 2.0 which installed php-fpm55 and nginx.
However the nginx configurations seem to not be generated. I checked in directadmin.conf and I see there that nginx=1 but still configs are not generated.
I even tried the /usr/local/directadmin/custombuild/build rewrite_confs command but it still did not generate them.

Any ideas on how to fix it will be most appreciated :)

Another problem is that Dovecot fails to start, it looks for the server.crt file in /etc/httpd/conf/ssl.crt/ instead of /etc/nginx/ssl.crt/. But that's an easy one to fix manually.
 
Last edited:
xd

I have now nginx fully running thanks to private support form smtalk .

I can create/delete users. Exim is working fine.

What still not work is some features (maybe for the next update or i do something wrong)

when i brows to the server IP http://84.243.229.118 i get 403 error
When i brows to some DA features like webmail it does not work, see nginx.vservs.com/roundcube ore something else it gets 403 error.

I think i do something wrong, i will make some tests today.

@smtalk i like/love this project well done sir!http://forum.directadmin.com/images/icons/icon14.png
 
I just completed an install with 1.43 RC1 with the newest custombuild 2.0 which installed php-fpm55 and nginx.
However the nginx configurations seem to not be generated. I checked in directadmin.conf and I see there that nginx=1 but still configs are not generated.
I even tried the /usr/local/directadmin/custombuild/build rewrite_confs command but it still did not generate them.

Any ideas on how to fix it will be most appreciated :)

Another problem is that Dovecot fails to start, it looks for the server.crt file in /etc/httpd/conf/ssl.crt/ instead of /etc/nginx/ssl.crt/. But that's an easy one to fix manually.

Thank you for the report about dovecot.conf, it's fixed in the latest version of CB 2.0 now (not uploaded to DA servers yet). About the other problem you mentioned, please post the output of:
Code:
/usr/local/directadmin/directadmin o
ls /usr/local/directadmin/data/templates | grep nginx

It doesn't look to be DA 1.43 RC1, if it generates no nginx files.
 
I have now nginx fully running thanks to private support form smtalk .

I can create/delete users. Exim is working fine.

What still not work is some features (maybe for the next update or i do something wrong)

when i brows to the server IP http://84.243.229.118 i get 403 error
When i brows to some DA features like webmail it does not work, see nginx.vservs.com/roundcube ore something else it gets 403 error.

I think i do something wrong, i will make some tests today.

@smtalk i like/love this project well done sir!http://forum.directadmin.com/images/icons/icon14.png

I am happy to hear that you like it :) Your problem is caused by /var/www owned by apache. The fix is simple (added to CB 2.0 now):
Code:
chown webapps:nginx /var/www
 
Hello
I get error in loading site in my server with nginx
Nginx is functioning normally
How to do?
 
Make sure you run DirectAdmin 1.43 RC1 and CustomBuild 2.0 on your server.
 
Back
Top