1
1
freepoteries-doc/content/new_vh.rst
2019-09-09 16:37:40 +02:00

83 lines
2.7 KiB
ReStructuredText

new virtual host
################
:date: 2019-09-09 00:00
:modified: 2019-09-09 00:00
:tags: infra
:category: documentation
:slug: create_vh
:authors: Ms.Leave-A-Mix
:summary: How-To install a new virtual host to the webserver
This article will explain how to deploy a new service within your web server.
The service (framadate), is hosted on the same machine than the webserver
(nginx). You may like to create a new machine, to use the self-included
webserver of your programming language (php, python, ruby...), as the goal of
having one webserver is to save time by configuring only one monitoring system
and security system for many apps.
-------------
The Webserver
-------------
We use NGINX as a webserver. It is modular and aimed to be as small and
efficient as possible. Since then, it doesn't include the necessary programs to
run your scripts. You need to have another program to launch and manages your
processes. For our example, this will be php-fpm_. If you also use `Alpine
Linux`_ you can follow `this tutorial
<https://wiki.alpinelinux.org/wiki/Nginx_with_PHP#PHP7_Installation>`__.
------
System
------
I will use the commands with the default Alpine Linux tools, that are not like
Debian or Arch ones. Adapt this if you use another distro.
I suggest that the webserver is already installed, and is working for serving
php scripts.
We will create a new user that has access to the git repository of your program,
so you can update it's code easily, without having to re-upload at each
modification.
``useradd -rm www-git``
Create an passwordless ssh key for this user :
``su www-git
ssh-keygen``
If you need the git authentication (i.e. because your repo is private), do as
usual.
--------
Database
--------
Freepoteries uses one server to handle all database stuff. We will assume in
this documentation that the DB software is MariaDB_ (ver. 10.1.38, debian).
Your DB server needs to be accessible by the webserver machine, you can test
this on the webserver host by launching the following command :
``nc db.server db.port``
If it gives you the MariaDB version, you're ok to go with this.
You need to have an administrator access to the MariaDB server. On the DB
server, try this by launching the following commands :
``mariadb -u root``
If this connects you to the MariaDB prompt, you're ok.
Now, in this prompt, create the user for our app. It will own a database and all
the rights on it.
``CREATE DATABASE framadate;
CREATE USER 'framadate'@'www.freepoteries.fr' identified by '7VDYMDXJXHTC107Z61OWCVTWM';
GRANT ALL PRIVILEGES ON framadate TO 'framadate'@'www.freepoteries.fr';``
.. _php-fpm: https://php-fpm.org/
.. _Alpine Linux: https://alpinelinux.org/
.. _MariaDB: https://mariadb.org/