I will write another post about the different solutions I have found and tested but for now I am installing AjaXplorer. This product is open source, installable on your own hardware and gives you access to your already existing file server with minor configuration.
Following are the instructions for installing AjaXplorer with Nginx on Debian Wheezy. The hardware I am using is a Raspberry Pi with a 4TB Western Digital USB hard drive attached. Because the Raspberry Pi is a low powered device I am using Nginx as the web server with PHP-FPM for processing php.
Assumptions
- You already have Debian 7.0 (Wheezy) running.
- You can download the AjaXplorer compressed file to your Debian server.
To start off with we need to install the prerequisite packages. I am keen to keep my Raspberry Pi lean and so I did some testing to determine the minimum required packages needed to get the full functionality of AjaXplorer. Note I am not including the requirements for the AjaXplorer desktop client yet because it is in beta and I am not interested in testing it. If you wish to use the desktop client you will need some rsync php related packages. So here is the command to install the prerequisites;
apt-get install nginx php5 php5-fpm php5-gd php5-cli php5-mcrypt
Once the prerequisites are installed, create the www directory and set ownership;
mkdir /var/www
chown www-data:www-data /var/www
We need to configure php to support larger file uploads so edit the php.ini file;
vim /etc/php5/fpm/php.ini
Edit the following values to your liking;
file_uploads = On
post_max_size = 20G
upload_max_filesize = 20G
max_file_uploads = 20000
Now we need to configure Nginx to setup our AjaXplorer web site (use your own domain name below);
vim /etc/nginx/sites-available/x.yourdomain.com
Here is the x.yourdomain.com config file I am using. Make sure you change the max_body_size value and replace x.yourdomain.com with your servers DNS name;
server {
listen 80;
server_name x.yourdomain.com;
root /var/www;
index index.php;
client_max_body_size 20G;
access_log /var/log/nginx/x.yourdomain.com.access.log;
error_log /var/log/nginx/x.yourdomain.com.error.log;
location / {
}
location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
expires max;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
include drop.conf;
include php.conf;
}
Take note of the two include statements at the bottom of the Nginx site file. You will need to make these files also;
vim /etc/nginx/drop.conf
And here is my drop.conf contents;
location ^~ /conf/ { deny all; }
location ^~ /data/ { deny all; }
location = /robots.txt { access_log off; log_not_found off; }
location = /favicon.ico { access_log off; log_not_found off; }
location ~ /\. { access_log off; log_not_found off; deny all; }
location ~ ~$ { access_log off; log_not_found off; deny all; }
Note the first two deny all statements above are specific to AjaXplorer.
Now create the php.conf file;
vim /etc/nginx/php.conf
Here is my php.conf contents;
location ~ \.php {
try_files $uri =404;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
The last statement in the above file is the mapping between Nginx and PHP5-FPM.
Now that all the Nginx files are created we can enable the site by deleting the default Nginx site and linking to the new site;
cd /etc/nginx/sites-enabled
rm default
ln -s ../sites-available/x.yourdomain.com
Time to get the AjaXplorer files. Download the latest version and save it to your /var/www directory. Extract the downloaded file to the root of the www directory;
cd /var/www
tar -xzf <gz file name here>
ls -l
mv <extracted directory name>/* /var/www
rm -R /var/www/<extracted directory name>
chown -R www-data:www-data /var/www
Prior to opening a browser and seeing the result we need to restart the required services to pick up the new config files;
service php5-fpm restart
service nginx restart
Now open a browser and hit your IP address or DNS name. The first time you access AjaXplorer you will see a diagnostics page that will look like this.
You will need to fix any issues discovered by the Diagnostics program before continuing. You will notice the warning about SSL Encryption. I am accessing my server using Pound as a reverse proxy to encrypt the pages using SSL.
Once you have fixed any errors reported by the Diagnostics page click on the link under the title to continue to the AjaXplorer main interface. You will need to log in with a username of admin and a password of admin for the first access. Make sure you change the password at some point.
The last required configuration for the installation is to adjust the AjaXplorer upload file size limit. This is achieved under settings;
That's it. AjaXplorer is now installed and waiting for you to configure repositories and other customizations. There are plugins available and client applications. I am using the Android client successfully and will look at the Desktop client once it is out of beta.
The Raspberry Pi is an amazing platform for free open tools like this and I am now using a low powered Pi with a USB disk as my home file server cutting my electricity bill and reducing my carbon foot print.
First of all, congratulations for such a nice post.
ReplyDeleteI followed your instructions to install AjaXplorer with a Raspberry Pi and, although I managed to make it work, it is slow as hell (much more than in my laptop). How does it run for you?
I noticed that the Ram consumption raises until it only lefts about 32Mb free.
Thank you!
Thanks for the comment Alberto.
ReplyDeleteYes, it runs really slow but works ok. I am not using the AjaXplorer as the primary file access tool so it does not bother me. It is too slow to use as your only access solution.
My Raspberry Pi has Samba, AjaXplorer and Deluge running on it. It is my primary file server at home and AjaXplorer is really more for remote access for the odd file here and there.
I am interested in the Desktop client when it is complete.
Just install APC or other accelerator to speed up php. It'll work much faster.
DeleteHi Almaz,
DeleteHey, thanks so much for the advice. I just installed APC after reading up on it. Easy to do - apt-get install php-apc
It seems to be twice as fast as it was before.
Thanks again,
In drop.conf you shoul use "~" instead of "=".
ReplyDeleteThanks for the feedback G.
DeleteI had a close look at the location directive (http://wiki.nginx.org/HttpCoreModule#location) and agree with you with a slight change. Rather than replacing the = with a ~, us a ^~ which halts searching once a match is found.
I have updated the article.
I have some problems with drop.conf
ReplyDeleteIf I use:
location ^~ /conf/ { deny all; }
location ^~ /data/ { deny all; }
location = /robots.txt { access_log off; log_not_found off; }
location = /favicon.ico { access_log off; log_not_found off; }
location ~ /\. { access_log off; log_not_found off; deny all; }
location ~ ~$ { access_log off; log_not_found off; deny all; }
It doesn't let me share any file to external users..
If I use:
location ^~ /conf/ { deny all; }
location ^~ /data/public/ { allow all; }
location ^~ /data/ { deny all; }
location = /robots.txt { access_log off; log_not_found off; }
location = /favicon.ico { access_log off; log_not_found off; }
location ~ /\. { access_log off; log_not_found off; deny all; }
location ~ ~$ { access_log off; log_not_found off; deny all; }
It download the public ".php" file and not show it
If I use:
location ^~ /conf/ { deny all; }
location ^~ /data/ { allow all; }
location = /robots.txt { access_log off; log_not_found off; }
location = /favicon.ico { access_log off; log_not_found off; }
location ~ /\. { access_log off; log_not_found off; deny all; }
location ~ ~$ { access_log off; log_not_found off; deny all; }
It let me see my public file but also private files!
Could I make an IF statement for hide all the contents of /data/ but show only /data/public/
?
Solved but it could be dangerous and not so useful:
ReplyDeletelocation ^~ /public/ { allow all; }
location ^~ /conf/ { allow 127.0.0.1; deny all; }
location ^~ /data/cache/ { allow 127.0.0.1; allow all; }
location ^~ /data/files/ { allow 127.0.0.1; deny all; }
location ^~ /data/logs/ { allow 127.0.0.1; deny all; }
location ^~ /data/personal/ { allow 127.0.0.1; deny all; }
location ^~ /data/plugins/ { allow 127.0.0.1; deny all; }
location ^~ /data/tmp/ { allow 127.0.0.1; deny all; }
location = /robots.txt { access_log off; log_not_found off; }
location = /favicon.ico { access_log off; log_not_found off; }
location ~ /\. { access_log off; log_not_found off; deny all; }
location ~ ~$ { access_log off; log_not_found off; deny all; }
If we could make a nested location ecluding everything excepr /data/public/ it could be a good way.
To be honest Rubens, I don't use the public share options of AjaXplorer so I haven't hit this issue.
DeleteIs there a better way? I don't have time to look into it now.