How to setup a WordPress PHP site with Nginx, PHP5-FPM, and MySQL using Ajenti V with working Permalinks

Ajenti V

While beta testing Ajenti-V and attempting to setup a simple WordPress site, I ran into enough problems to warrant creating this tutorial.  Mainly because the way Ajenti-V sets up Nginx, there was a good hour of troubleshooting and testing that I had to do before getting a fully functioning site that had working permalinks.  Below I will describe exactly what needs to be done to get a full WordPress site up and running with Nginx, MySQL, PHP5, and Ajenti-V.

So to get started, i’m going to assume this is a blank VPS running Ubuntu, but these instructions should work for pretty much any distribution.

Install Ajenti

First you will need to install Ajenti, and there are instruction on Ajenti’s website on how to do so.  For this example you will need to follow instructions for Ubuntu:

Setup Ajenti

Go ahead and login to Ajenti and set everything up.  Make sure to change your password under the Configure section:
default username: root
default password: admin
default url:

Install Ajenti-V

Now it’s time to install Ajenti-V.  There are instructions on Ajenti’s website How to Install Ajenti-V on Debian (Ubuntu), but there are a few prerequisites missing and will cause problems when trying to use MySQL.

Remove Apache2

Sometimes depending on how Ubuntu was setup (or if a template was used) you may have Apache2 already installed on the server, because Ajenti uses Nginx we do not need Apache.  Run this command from SSH terminal:

 Install Ajenti-V and Ajenti-V Packages

 Install other required packages

 Restart Ajenti

Custom Edit or New Nginx files while using Ajenti

If you plan on using any custom files for Nginx or even editing the configuration files Nginx uses (or Ajenti creates), you cannot edit the existing files.  Ajenti will automatically overwrite those files and you will be stuck wondering why the configuration you put in those files keeps disappearing.

So, you have two options if you want to edit the existing Nginx configuration files, or the website specific configuration.

If you want to edit the Nginx configuration file, you can place any new something.conf  in this directory:

If you look at the  /etc/nginx/nginx.conf  file you will see that all files with a  .conf extension will be automatically loaded after all files in the  /etc/nginx/conf.d/ directory.  This is where you should place any additional configuration files you may want to use with Nginx.  Remember, these files will be for actual Nginx configuration.

If you want to specify configuration for a specific domain/website you should include that extra configuration in the Ajenti configuration section where we add this file below (Advanced > Custom Configuration):

You can also create a new file anywhere you want, and just add another include declaration to that file.


Create custom Nginx WordPress directory and files

Due to the way Ajenti V sets up Nginx, we will need to create our own Nginx WordPress directory to keep all of our extra configuration files inside.  Wordpress has instructions on their site on How to Setup WordPress with Nginx, but to save you the time of troubleshooting and playing around with the settings to find out what you need to remove, I created a Github with the modified files.

Login to your server over SSH, create the new directory, and change to that directory:

Download the modified restrictions.conf from my Github repo:

Download the modified wordpress.conf from my Github repo:


Setup PHP WordPress Site with Ajenti V

Create New Website

Ajenti V New Website

Ajenti V New Website



Navigate to Ajenti panel, and open Websites section. Click Create button, and expand newly created New Website entry.



 General Settings

Ajenti V General Setup

Ajenti V General Setup


Uncheck Maintenance mode checkbox, set Name to “Blog”, and Path to, for example, “/srv/blog”, and click Create directory to create this directory on server.

Next you will need to add two lines under the Custom configuration section that will include two files we created from above:


 Identification Settings


Ajenti V Identification

Ajenti V Identification



Under Identification page, Create and set a domain entry.



Content Settings (PHP)

Ajenti V PHP FastCGI

Ajenti V PHP FastCGI

Under Content page, Create a new content entry of type PHP.

Required Min processes – set to 1 if unsure.

Required Max processes – set to something between 10 and 60 if unsure.

Required custom configuration for WordPress, which will help prevent an Nginx exploit, all you need to do is add this code to the Custom configuration section:

 MySQL Settings

Ajenti V MySQL

Ajenti V MySQL



Under MySQL page, click Create to create a database. Click Apply changes, now navigate to http://domain/ and use the DB name, username and password from MySQL page to set up your WordPress installation.  Profit!



Install Nginx Helper Plugin

Wordpress Nginx Helper Plugin

WordPress Nginx Helper Plugin


You should now login to your WordPress site and install the “Nginx Helper” plugin to prevent all of your URLs from starting with index.php/:

Helpful Logs and Troubleshooting

A couple debug file locations to help you get everything up and running:



If you’re having problems getting this to work, through SSH you can check the status and start/stop/restart Nginx, PHP5-FPM, and Ajenti with these simple commands below.  Just replace status with start/stop/restart, etc:


Orlando, FL

Did this post help you?

Give back and rate it for me!

Related Posts

  • SONB

    I managed to install Ajenti V on Ubuntu 16.04, now I’m getting this error:

    nginx: [emerg] duplicate location “/” in /etc/nginx/conf.d/wp-test.conf:73
    nginx: configuration file /etc/nginx/nginx.conf test failed

    Any idea how to fix it?

  • Doug Knowles

    has anyone been able to successfully configure two separate wordpress domains using agent v and nginx.

    i can’t seem to access the second site with the second domain name just keeps taking me to the default i noticed the comments in your wp config file it say # WordPress single blog rules.

    would I have to change that file someway to make it work?

  • Luke Mackenzie

    Is this limited to PHP 5.3? I can’t see anything in the Ajenti docs about more recent php versions and ajenti-v seems to use 5.3

  • j

    upon further investigation ajenti reports nginx service check as having failed. My guess is due to the custom config.

    Ajenti has been updated and the custom config screens look much different but i believe ive done it correctly.

  • j

    it would be helpful to include the wordpress installation information… as the guide shows how to make ajenti work with wordpress but really nothing about wordpress.

    after finishing your guide navigating to turns up an error 404

    i can view the files in ssh aswell as ajenti so they are there.

  • Hi Myles, you really helped me and others a lot with this post, Still going strong I see.

    I’m checking in with a question concerning how to use server blocks in another area, since your article really shows how it’s done correctly. If I may… I’m trying to get auth_basic working on /wp-login.php using “ngx_http_auth_basic_module”, having a devil of a time to tell you the truth. I’m either confused about putting my .htpasswd file in the nginx dir as WP Codex stipulates and the info directly from Nginx. I read conflicting recommendations about the actual /path to this and getting something more authoritative would be great if you could spare the time. I’ve tried half a dozen ways without breaking my site (and a few that did) using your .conf files and also trying directly in the sever blocks but never any joy. I hope you have a great July 4th holiday weekend as well.

    location /wp-login.php {
    auth_basic “Administrator Login”;
    auth_basic_user_file .htpasswd;


    • Try using the full path to the .htpasswd file, I updated the wordpress.conf file as an example of what *should* work, haven’t tested it though:

      • Thanks for that Myles. Your code works but led me to another problem I’ve been researching. If I make the perms 644 for the .htpasswd file it wants to download the page. If I make them 640 the page becomes a 500 (though the site is unaffected). Using the full path and your code got me farther than I was yesterday.

        • Must be how the browser is dealing with fcgi or fpm-php5 in the Ajenti set up. Would like to resolve but waay above my skill-set.

          • 640 if the correct perms, did you check to make sure the owner is correct? Should be something like www-data or apache2 (or something similar), just do a ls -lah to see what the other files are set to, then use chown to change ownership.

          • Also check the log files as 500 error should output something in nginx error logs

  • erwanlescop


    Great tutorial indeed!

    Just curious: why don’t you recommend (like WP Codex for instance) to set cgi.fix_pathinfo to false in the fpm php.ini? Redundant in your opinion with the try_files $uri=404; setting?

    • Thanks, and yes you are correct, IMO it is redundant to use try_files and set the fix_pathinfo = 0 , BUT with that said, if nginx and php-fpm are running on separate servers the try_files will not work correctly. It’s probably good to go ahead and make the change in the php.ini file, but IIRC just using try_files should be enough.

    • Forgot to mention as well, I haven’t tested it with WordPress using cgi.fix_pathinfo = 0, but if WordPress relies on PATH_INFO to be set correctly that may cause issues.

    • Just want to follow up regarding this, I tested one of my sites while having fix_pathinfo value changed, and when attempting to restore using backup buddy it failed completely, wouldn’t even load the page.

      Just an FYI I would actually now recommend not making that change.

      • erwanlescop

        Oh this is weird, thanks for this interesting update. As a matter of fact, as for me, I never got any issue with this cgi.fix_pathinfo setting, since WP is not supposed to rely on PATH_INFO. Anyway, I do agree it seems “obviously” redundant with try_files to avoid the pitfall, despite the WP Codex recommandation. And I never run nginx and php-fpm on seperate servers (who really does?): hence no issue with the try_files setting.

  • Chris Bourke

    Hi Myles,

    As a complete beginner (i only installed Ajenti a few days ago, my first go at a digital ocean vps, and a beginner with ubuntu) i found your walkthrough so easy to follow! Thanks.

    Unfortunately im stuk at this point –

    I have queried nginx with $ service nginx status and i get: {nginx is not running}

    Then $ service nginx start i get:
    {Starting nginx: nginx: [emerg] location “/favicon.ico” is outside location “[^/].php(/|$)” in /etc/nginx.wp/restrictions.conf:3
    nginx: configuration file /etc/nginx/nginx.conf test failed}

    Not sure where to go from here, any help would be greatly appreciated!

  • Robin

    I followed the steps you mentioned above but when I try to visit my website url it downloads the webpage.

  • Dave Garello


    have you try Nginx fastcgi_cache from in ajenti?

    • I have not but shouldn’t be too difficult to implement. I’m actually working on a site that will be published soon and I will look into this and post a reply here once I give it a try

      • Dave Garello

        Thanks for reply.
        I’m waiting for the good news 🙂

      • erwanlescop

        Any recommendation on this specific point, in the end, or you left aside the topic?

      • nginx -V 2>&1 | grep nginx-cache-purge -o

        Ajenti’s NGINX doesn’t support fastcgi_cache_purge. Do you have any advice on integrating a custom compiled nginx into Ajenti? Thank you very much for your generous help with this control panel.

    • Dave Garello

      Yes, But when I try to put nginx.custom.d the custom configuration don’t show up.
      I put in php custom configuration or in nginx custom configuration on ajenti panel, cause nginx config test fail.

  • biz worx

    can you please post a similar tutorial on how to configure BIND9 with Ajenti.

    Much Thanks

  • Disqus is being a bear here on where comments appear, looks like I replied to myself when I thought it was a the bottom (newest) of thread. Please delete if necessary/double content. I tried to post about a redirect loop when putting return 301$request_uri; in my server block (example.conf) after following your guide all is good except that glitch…

    Edit: thought I resolved with additional server block in site.conf. not. This was so simple before.
    Edit: Can do in nginx.conf with additional server blocks no prob, but that’s going to add up to a lot in that file, and wanted a semi-auto way to do this. For some reason my nginx.conf appears to be overwritten periodically, possibly Ajenti but not sure yet as I investigate.

    • Yes that’s one of the main reasons I posted this on here, Ajenti does overwrite the files so anything you put in the actual conf file will be removed, you have to add it under /etc/nginx.custom.d/ instead of /etc/nginx/, if you look in the nginx.conf file you will see any .conf files in that directory will be loaded after the standard conf.d/ that Ajenti generates. I’ll add this to the tutorial above.

      • Getting your insight on this is great, thanks Myles. Look forward to your update of the tut.

      • Working great all round. Aside: I never had to use the Nginx helper plugin… isn’t that just a function of index.php in the permalink structure? (either way my set up works without it). And thx again Myles for your great blog. Quite the nice custom theme you’ve built:)

        • The Nginx helper will help clear the cache (when needed), and one of the main reasons I mentioned it, was it will remove the site from showing index.php (ie, but thanks for the support, it’s actually just blogify theme I had to do a lot of custom tweaks on 🙂

  • Stu R

    Very nice site here Myles, and the post got my attention. Only having Ajenti installed for a day threw me for a couple loops, as I’m used to a distinctly different Ubuntu/Nginx set up (as you allude to in writing it…). Other than using ssh/mysql to install a previous database when moving a site, is there a way in Ajenti to do this operation that you know of? I guess the next step is figuring out how to get phpmyadmin working with it. Again, thanks.

    • You’re welcome, I had to do quiet a bit of troubleshooting to get it setup for the first time, so as long as I helped at least 1 other person that makes it worth writing this tutorial. Regarding the database there’s nothing I know of for Ajenti, and i’ve actually been looking for a plugin (WordPress) or something that would allow me to sync both databases and themes/plugins, etc, but haven’t seen to found anything I liked, so may end up having to create one 🙂

      But the good thing about ajenti, is plugins are pretty easy to create, so even creating a plugin that would dump and then import a database shouldn’t be too difficult…but i’ll probably work on the WP sync one first 🙂 Right now all I do is just use WP Duplicator and then transfer over FTP or SSH and restore them.

      • My avatar didn’t show on the first post (disqus:), and thanks for your reply Myles. I generally go to the source for things regarding Nginx but this is not like the boxes I have gotten used to managing… Anyway, regarding the info. I use BackWPup to dropbox, then Adminer to import the db. Another fast and clean method I think.

        My overall first impression with Ajenti(v) is that I am so used to the command line, finding simple things that are muscle memory in ssh, take getting used to out on the whacky web. The best thing about it is user control without using jailkit and all the crazy chrooting that drives me round the bend. I also thought (Ajenti) was a user control panel so I could let clients have an account and do some functions, maybe down the road a bit as it evolves.

        Have a great weekend.

        • Yeah that’s one of the reasons I posted this, I noticed that the configuration was different than what I was used to and I knew it would throw others through a loop.

          The only real clients we use Ajenti for is those who have their own VPS or dedi and don’t want the additional costs associated with cPanel/WHM.

          For a while we were using Webmin (and a lot of our old clients still use it), but it started to confuse a lot of those who “thought” they wanted an unmanaged server. Right now Ajenti V is really just more geared and focused towards hosting website instead of just a “server admin” panel.

          Hopefully soon it will be possible to setup emails, more database functions, etc, but being as though it is an open source project, it all depends on the developer having time to work on something he’s not being paid for, or others contributing 🙂

          I’ve been using Ajenti since the inception and it’s come a long way so far, but it has great potential.

          • Reading more of your articles this morning while trying to figure out a few things in Ajenti. I don’t get vsftp, or how to correctly create a share in Samba since setting both these services up inside (which may be a contradiction in itself). I’m only used to being alone on a machine so never cared about granting sftp to others). That said I would like to learn how this works and I have 2 sites I migrated in over the weekend (thanks to your set up guide here). I can AllowUsers user2 in sshd_config, and he can login but then most of the file system is open. I figure that’s why we have vsftp (and/or Samba) in Ajenti… are they mutually exclusive? If I need to seriously back up and you have a pointer about best practice here…. I’d love to hear that. Thank you again.

          • You’re just trying to provide file access to the user?

          • Short answer. yes, to his site files at /srv/… thx

          • haha no worries man, that’s why I was asking, there really isn’t many “requirements” for ajenti, it’s just options you have to manage those specific applications IF they are installed, glad you got everything worked out

          • Got it worked out. As I thought after writing that, I didn’t need Samba or vsftpd. I installed them thinking they were some sort of requirement for Ajenti usability. My bad for not doing my due diligence first.