MusicLounge: NGINX WEB Server


# STEP8

# install lightweight web server (nginx) to:
# get access to covers (album artwork) from MPD client
# use a internet browser with MPD WEB Client MyMPD on your desktop PC, tablet or phone to play and browse your music library

# Install the web server and dependencies:

  1. $ sudo apt-get install nginx php-curl php-sqlite3 php-gd php-json php-xml php-mbstring php-fpm php-intl imagemagick

# Edit configuration:

  1. $ sudo nano /etc/nginx/nginx.conf

# add this lines under gzip section

 gzip on;
 gzip_vary on;
 gzip_buffers 16 8k;
 gzip_comp_level 6;
 gzip_min_length 1000;
 gzip_proxied expired no-cache no-store private auth;
 gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon;
 gzip_disable msie6;
 gzip_http_version 1.1;

# CTRL+O to save
# CTRL+X to exit


# Add an alias to get access to album cover (artwork) from http://192.168.x.x/music/…folder.jpg:
# add a redirection to myMPD (MPD WEB Client)
# Edit configuration go to location / { :

  1. $ sudo nano /etc/nginx/sites-available/default
	
location / {
	return 301 http://$host:8080/;
	# First attempt to serve request as file, then
	# as directory, then fall back to displaying a 404.
	try_files $uri $uri/ =404;
}
location /music {
	alias /mnt/media;
}
location /mympd/ {
	proxy_pass http://127.0.0.1:8080/;
}

# CTRL+O to save
# CTRL+X to exit

# OPTIONAL
# create temp directory to save settings

  1. $ sudo mkdir /var/www/html/tmp

# add the user pi (your username) to group www-data

  1. $ sudo usermod -a -G www-data pi

# set permission

  1. $ sudo chown -R www-data:www-data /var/www
  2. $ sudo chmod -R g+rwX /var/www

# create a soft link of the web directory
# to get access to it from your home

  1. ln -s /var/www/ ~/www

# restart service

  1. $ sudo systemctl restart nginx


  1. $ sudo systemctl status nginx

# reboot

  1. sudo reboot

# that’s it!


# now you can get access to your album covers from http

# type this address in your browser (replace with IP of the server and path to music that contains folder.jpg or cover.jpg )
# http://192.168.XX.XX/music/<song_path>/folder.jpg

# ATTENTION: you have to enter the IP of MusicLounge Audiophile Server and NOT the ip of your Music library share point
# http://192.168.1.xxx/music is now the link to get access to your musics from any music players whatever the platform (Android, iOS, Windows, Linux, …)

# FOR EXAMPLE

http://192.168.1.xxx/music/Bach/Toccata/folder.jpg


# start a new SSH session, it’s time to install the main part of this audiophile server – Music Player Daemon (AKA MPD)

Click the button NEXT below to continue…