Email This List Email This List Print This List Print This List

Set­ting up a new site with Ajenti *e.g. Word­Press

In this tutori­al we will set up a PHP web­site with Ajenti V, using Word­Press as example.
Pre­requis­ites: Ajenti V (NGINX, MySQL, PHP pack­ages), php-fpm, mysql, php5-mysql

1. Nav­ig­ate to Ajenti pan­el, and open Web­sites sec­tion. Click Cre­ate but­ton, and expand newly cre­ated New Web­site entry.

2. Uncheck Main­ten­ance mode check­box, set Name to “Blog”, and Path to, for example, “/​srv/​blog”, and click Cre­ate dir­ect­oryto cre­ate this dir­ect­ory on serv­er.

2a. Add fol­low­ing to Cus­tom con­fig­ur­a­tion:

# This order might seem weird - this is attempted to match last if rules below fail.
location / {
	try_files $uri $uri/ /index.php?$args;
}

# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;

# Directives to send expires headers and turn off 404 error logging.
location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
       access_log off; log_not_found off; expires max;
}

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

2b. For enhanced secur­ity, add fol­low­ing to the Cus­tom con­fig­ur­a­tion:

# Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
# Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban)
location ~ /\. {
	deny all;
}
# Deny access to any files with a .php extension in the uploads directory
# Works in sub-directory installs and also in multisite network
# Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban)
location ~* /(?:uploads|files)/.*\.php$ {
	deny all;
}

3a: Manu­ally pla­cing word­press files: place word­press files into /​srv/​blog
3b. Auto­mat­ic­ally down­load­ing word­press files: Input https://​word​press​.org/​l​a​t​e​s​t​.​zip into From URL text­box and clickDown­load and unpack. You will see the down­load and unpack­ing pro­cess take place. Once com­plete, close the ter­min­al tab. Then (import­ant!), use File Man­ager to move files from /​srv/​blog/​wordpress/​ to /​srv/​blog itself.

4. Under Iden­ti­fic­a­tion page, Cre­ate and set a domain entry.

5. Under Con­tent page, Cre­ate a new con­tent entry of type PHP.



5a. For enhanced secur­ity, add fol­low­ing to Cus­tom con­fig­ur­a­tion:

# Zero-day exploit defense.
# http://forum.nginx.org/read.php?2,88845,page=3
# Won't work properly (404 error) if the file is not stored on this server, which is entirely possible with php-fpm/php-fcgi.
# Comment the 'try_files' line out if you set up php-fpm/php-fcgi on another machine.  And then cross your fingers that you won't get hacked.
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;

6. Under MySQL page, click Cre­ate to cre­ate a data­base

7. Click Apply changes

8. Done! Now nav­ig­ate to http://domain/ and use the DB name, user­name and pass­word from MySQL page to set up your Word­Press install­a­tion.
Install the “Nginx Help­er” plu­gin to pre­vent all of your URLs from start­ing with index.php/

Thanks to Myles McNamara for con­trib­ut­ing to this guide!

Related Post

admin has written 133 articles