server-block-setup
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| server-block-setup [2021/12/27 10:40] – arnaud_poletto | server-block-setup [2022/01/10 14:56] (current) – removed arnaud_poletto | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Server Blocks Setup ====== | ||
| - | ===== Purpose and Scope ===== | ||
| - | |||
| - | In this document, we will describe the steps to add //server blocks// (SB) to a dokku-nginx environment in order to be able to access web application without docker containers. We will not describe here the necessary steps to install //REDCap// (RC) or //Grafana// (GF). Nor will we discuss user management, database configuration, | ||
| - | |||
| - | |||
| - | |||
| - | |||
| - | ===== Prerequisite ===== | ||
| - | |||
| - | * Ubuntu server 18.04 | ||
| - | * Nginx 1.14.0 | ||
| - | * //sudo// privileges on the server. | ||
| - | |||
| - | |||
| - | |||
| - | |||
| - | ===== Server Blocks setup ===== | ||
| - | |||
| - | When using nginx server, we need SB (virtual hosts in Apache) to be able to access more than one domain in a single sever. | ||
| - | We need to create these directories for each needed sites: | ||
| - | < | ||
| - | sudo mkdir -p / | ||
| - | sudo mkdir -p / | ||
| - | </ | ||
| - | |||
| - | Assign the current user and give him right rights on the created folders (do not use root user): | ||
| - | < | ||
| - | sudo chown -R $USER:$USER / | ||
| - | sudo chown -R $USER:$USER / | ||
| - | sudo chmod -R 755 /var/www | ||
| - | </ | ||
| - | |||
| - | Create a test file for each site: | ||
| - | < | ||
| - | nano / | ||
| - | </ | ||
| - | |||
| - | Edit each php file with some test content: | ||
| - | < | ||
| - | <?php | ||
| - | phpinfo(); | ||
| - | </ | ||
| - | |||
| - | Now, create server Block files for each domain. Create the first SB and use the default template.: | ||
| - | < | ||
| - | sudo cp / | ||
| - | </ | ||
| - | |||
| - | Edit the new SB: | ||
| - | < | ||
| - | sudo nano / | ||
| - | </ | ||
| - | |||
| - | Here is an example of SB file configuration: | ||
| - | < | ||
| - | server { | ||
| - | listen 80; | ||
| - | listen [::]:80; | ||
| - | |||
| - | root / | ||
| - | index.php; | ||
| - | |||
| - | server_name redcap.local; | ||
| - | |||
| - | location / { | ||
| - | try_files $uri $uri/ =404; | ||
| - | } | ||
| - | } | ||
| - | </ | ||
| - | |||
| - | Now, copy the file to create the 2nd server block: | ||
| - | < | ||
| - | sudo cp / | ||
| - | </ | ||
| - | |||
| - | And edit it: | ||
| - | < | ||
| - | sudo nano / | ||
| - | </ | ||
| - | < | ||
| - | server { | ||
| - | listen 80; | ||
| - | listen [::]:80; | ||
| - | |||
| - | root / | ||
| - | index.php; | ||
| - | |||
| - | server_name grafana.local; | ||
| - | |||
| - | location / { | ||
| - | try_files $uri $uri/ =404; | ||
| - | } | ||
| - | } | ||
| - | </ | ||
| - | |||
| - | Create links between files: | ||
| - | < | ||
| - | sudo ln -s / | ||
| - | sudo ln -s / | ||
| - | </ | ||
| - | |||
| - | Check if there is no syntax errors in any created files: | ||
| - | < | ||
| - | sudo nginx -t | ||
| - | </ | ||
| - | |||
| - | If there is no error, you can restart nginx server | ||
| - | < | ||
| - | sudo systemctl restart nginx | ||
| - | </ | ||
| - | |||
| - | ===== MariaDB Setup ===== | ||
| - | |||
| - | Then, install MariaDB: | ||
| - | < | ||
| - | sudo apt update | ||
| - | sudo apt install mariadb-server | ||
| - | </ | ||
| - | |||
| - | You still need to configure users, rights and server configuration but this will not be described in this document. | ||
| - | |||
| - | |||
| - | |||
| - | |||
| - | ===== PHP processor ===== | ||
| - | Note: '' | ||
| - | Nginx need a php processor to be able to deliver dynamic content: | ||
| - | < | ||
| - | sudo apt-get install php-fpm php-mysql | ||
| - | </ | ||
| - | |||
| - | Open the php.ini for fpm: | ||
| - | < | ||
| - | sudo nano etc/ | ||
| - | </ | ||
| - | |||
| - | Comment out the line with '' | ||
| - | < | ||
| - | cgi.fix_pathinfo=0 | ||
| - | </ | ||
| - | |||
| - | Then, we can restart the PHP processor with: | ||
| - | < | ||
| - | sudo systemctl restart php7.x-fpm.service | ||
| - | </ | ||
| - | |||
| - | We have to specify the php processor to be used for each server blocks. Open both (RC and GF) SB files: | ||
| - | < | ||
| - | sudo nano / | ||
| - | </ | ||
| - | |||
| - | And add these lines: | ||
| - | < | ||
| - | location ~ \.php$ { | ||
| - | include snippets/ | ||
| - | fastcgi_pass unix:/ | ||
| - | } | ||
| - | |||
| - | location ~ /\.ht { | ||
| - | deny all; | ||
| - | } | ||
| - | </ | ||
| - | |||
| - | Check the nginx configuration: | ||
| - | < | ||
| - | sudo nginx -t | ||
| - | </ | ||
| - | |||
| - | If no error, reaload it: | ||
| - | < | ||
| - | systemctl systemctl reload nginx | ||
| - | </ | ||
| - | |||
| - | If you want more information on SB directive, please refer to the official nginx documentation. | ||
| - | Both server block php page should be accessible and rendered correctly. | ||
| - | |||
| - | |||
| - | |||
| - | |||
| - | ===== REDCap and Grafana ===== | ||
| - | You can replace your example '' | ||
| - | |||
| - | |||
| - | |||
| - | |||
| - | ===== Ressources ===== | ||
| - | |||
| - | * Server block install: https:// | ||
| - | * MariaDB install: https:// | ||
| - | * PHP processing for nginx (resources in French): https:// | ||
server-block-setup.1640598049.txt.gz · Last modified: 2021/12/27 10:40 by arnaud_poletto
