server-block-setup
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| server-block-setup [2021/12/27 09:52] โ created 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. | ||
| - | |||
| - | |||
| - | |||
| - | |||
| - | ===== Material ===== | ||
| - | |||
| - | :?: | ||
| - | |||
| - | |||
| - | |||
| - | |||
| - | ===== Server Blocks setup ===== | ||
| - | |||
| - | 2. 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. | ||
| - | - Set up document root directories | ||
| - | 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(); | ||
| - | |||
| - | - 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 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; | ||
| - | } | ||
| - | } | ||
| - | |||
| - | - Enable server blocks and restart nginx | ||
| - | 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 | ||
| - | |||
| - | 3. MariaDB install | ||
| - | Basic install of MariaDB | ||
| - | sudo apt update | ||
| - | sudo apt install mariadb-server | ||
| - | |||
| - | |||
| - | You still need to configure user, rights and server configuration but this will not be described in this document. | ||
| - | 4. PHP processor | ||
| - | Note: `x` should be replaced with the correct PHP version | ||
| - | 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` and set it to 0 | ||
| - | 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. | ||
| - | 5. REDCap and Grafana | ||
| - | You can replace your example index.php files with RC and GF installation files. For RC and GF installation, | ||
| - | |||
| - | ===== Ressources ===== | ||
| - | |||
| - | * Server block install: https:// | ||
| - | * MariaDB install: https:// | ||
| - | * PHP processing for nginx (resources in French): https:// | ||
| - | |||
| - | |||
| - | |||
| - | DELETEME | ||
| - | == Credentials == | ||
server-block-setup.1640595177.txt.gz ยท Last modified: 2021/12/27 09:52 by arnaud_poletto
