... | @@ -188,13 +188,78 @@ Testen kann man mit `nginx -t` und nginx neustarten mit `nginx -s`. |
... | @@ -188,13 +188,78 @@ Testen kann man mit `nginx -t` und nginx neustarten mit `nginx -s`. |
|
|
|
|
|
## PostgreSQL
|
|
## PostgreSQL
|
|
|
|
|
|
|
|
Wir haben PostgreSQL 9.6 am laufen.
|
|
|
|
|
|
|
|
Neue Datenbank anlegen:
|
|
|
|
|
|
|
|
```sql
|
|
|
|
# sudo -u postgres -i
|
|
|
|
$ psql -U postgres
|
|
|
|
CREATE ROLE myuser LOGIN password 'secret';
|
|
|
|
CREATE DATABASE mydatabase ENCODING 'UTF8' OWNER myuser;
|
|
|
|
```
|
|
|
|
|
|
## MySQL
|
|
## MySQL
|
|
|
|
|
|
|
|
Neue Datenbank anlegen:
|
|
|
|
|
|
|
|
```sql
|
|
|
|
$ mysql -u root -p
|
|
|
|
CREATE DATABASE db_user;
|
|
|
|
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'secret';
|
|
|
|
GRANT USAGE ON *.* to newuser@localhost identified by 'secret';
|
|
|
|
GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';
|
|
|
|
GRANT ALL PRIVILEGES ON db_user.* to newuser@localhost ;
|
|
|
|
```
|
|
|
|
|
|
# PHP
|
|
# PHP
|
|
|
|
|
|
# Python
|
|
Wir haben PHP5.6 und PHP7.1 via php-fpm. Am einfachsten ist ein einen neuen Pool mit der UID des neuen Users anzulegen.
|
|
|
|
|
|
|
|
# cd /etc/php/7.1/fpm/pool.d
|
|
|
|
|
|
|
|
```ini
|
|
|
|
; /etc/php/7.1/fpm/pool.d/newuser.conf
|
|
|
|
[newuser]
|
|
|
|
user = newuser
|
|
|
|
group = newuser
|
|
|
|
|
|
|
|
listen = /run/php/php7.1-fpm-newuser.sock
|
|
|
|
|
|
|
|
listen.owner = www-data
|
|
|
|
listen.group = www-data
|
|
|
|
|
|
|
|
; kann man anpassen, ondemand spart ram, wenn wenig genutzt, sonst dynamic
|
|
|
|
pm = ondemand
|
|
|
|
pm.max_children = 2
|
|
|
|
pm.start_servers = 2
|
|
|
|
pm.min_spare_servers = 1
|
|
|
|
pm.max_spare_servers = 1
|
|
|
|
; idle timeout für ondemand
|
|
|
|
pm.process_idle_timeout = 10s;
|
|
|
|
|
|
# JVM
|
|
env[PATH] = /usr/local/bin:/usr/bin:/bin
|
|
|
|
env[TMP] = /tmp
|
|
|
|
env[TMPDIR] = /tmp
|
|
|
|
env[TEMP] = /tmp
|
|
|
|
```
|
|
|
|
|
|
|
|
Jetzt kann man im nginx via FastCGI PHP nutzen:
|
|
|
|
|
|
|
|
```
|
|
|
|
location ^~ /~newuser {
|
|
|
|
alias /home/newuser/public_html;
|
|
|
|
location ~ \.php(?|$) {
|
|
|
|
include fastcgi_params;
|
|
|
|
fastcgi_index index.php;
|
|
|
|
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
|
|
|
fastcgi_pass unix:/run/php/php7.1-fpm-newuser.sock;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
# Python/Ruby/...
|
|
|
|
|
|
|
|
Klappt vermutlich mit uWSGI. Hier ein [Beispiel](http://flask.pocoo.org/docs/0.12/deploying/uwsgi/)
|
|
|
|
|
|
|
|
... |