« Nginx uWSGI and Ubuntu » : différence entre les versions
De Banane Atomic
Aller à la navigationAller à la recherche
(10 versions intermédiaires par le même utilisateur non affichées) | |||
Ligne 2 : | Ligne 2 : | ||
= Install = | = Install = | ||
<kode lang='bash'> | <kode lang='bash'> | ||
ai nginx uwsgi-plugin-php | ai nginx uwsgi uwsgi-plugin-php | ||
# check nginx | # check nginx and uwsgi are running | ||
sc-status uwsgi | |||
sc-status nginx | sc-status nginx | ||
</kode> | </kode> | ||
= Site configuration = | = Site configuration = | ||
<kode lang='bash'> | <kode lang='bash'> | ||
# enable | # enable the uwsgi configuration | ||
sudo ln -s /etc/uwsgi/apps-available/phpinfo.conf /etc/uwsgi/apps-enabled/phpinfo.conf | |||
sc-restart uwsgi | |||
# it creates sockets /var/run/uwsgi/app/<appname>/socket | |||
# enable the nginx configuration | |||
sudo ln -s /etc/nginx/sites-available/phpinfo.conf /etc/nginx/sites-enabled/phpinfo.conf | sudo ln -s /etc/nginx/sites-available/phpinfo.conf /etc/nginx/sites-enabled/phpinfo.conf | ||
sc-restart nginx | sc-restart nginx | ||
Ligne 21 : | Ligne 24 : | ||
<filebox fn='/etc/nginx/sites-available/phpinfo.conf' lang=nginx> | <filebox fn='/etc/nginx/sites-available/phpinfo.conf' lang=nginx> | ||
server { | server { | ||
server_name phpinfo.net; | server_name phpinfo.net; | ||
listen 80; | |||
root /var/www/php; | |||
index info.php; | |||
location ~ \.php$ { | location ~ \.php$ { | ||
include uwsgi_params; | include uwsgi_params; | ||
uwsgi_modifier1 14; | uwsgi_modifier1 14; | ||
uwsgi_pass | uwsgi_pass unix:/var/run/uwsgi/app/phpinfo/socket; | ||
} | } | ||
} | } | ||
</filebox> | |||
<filebox fn='/etc/uwsgi/apps-available/phpinfo.ini'> | |||
[uwsgi] | |||
master = true | |||
cheap = true | |||
idle = 600 | |||
die-on-idle = true # If app is not used often, it will exit and be launched again by systemd requested by users. | |||
manage-script-name = true | |||
plugins = php | |||
php-docroot = /var/www/php | |||
php-index = info.php | |||
php-allowed-ext = .php | |||
</filebox> | |||
= Log = | |||
* {{boxx|/var/log/uwsgi/app}} | |||
= Systemd = | |||
== [https://uwsgi-docs.readthedocs.io/en/latest/Systemd.html#one-service-per-app-in-systemd One service per app in systemd] == | |||
<filebox fn='/etc/systemd/system/uwsgi-app@.socket' lang='ini'> | |||
[Unit] | |||
Description=Socket for uWSGI app %i | |||
[Socket] | |||
ListenStream=/var/run/uwsgi/%i.socket | |||
SocketUser=www-%i | |||
SocketGroup=www-data | |||
SocketMode=0660 | |||
[Install] | |||
WantedBy=sockets.target | |||
</filebox> | |||
<filebox fn='/etc/systemd/system/uwsgi-app@.service' lang='ini'> | |||
[Unit] | |||
Description=%i uWSGI app | |||
After=syslog.target | |||
[Service] | |||
ExecStart=/usr/bin/uwsgi \ | |||
--ini /etc/uwsgi/apps-available/%i.ini \ | |||
--socket /var/run/uwsgi/%i.socket | |||
User=www-%i | |||
Group=www-data | |||
Restart=on-failure | |||
KillSignal=SIGQUIT | |||
Type=notify | |||
StandardError=syslog | |||
NotifyAccess=all | |||
</filebox> | </filebox> |
Dernière version du 9 août 2023 à 17:15
Install
ai nginx uwsgi uwsgi-plugin-php # check nginx and uwsgi are running sc-status uwsgi sc-status nginx |
Site configuration
# enable the uwsgi configuration sudo ln -s /etc/uwsgi/apps-available/phpinfo.conf /etc/uwsgi/apps-enabled/phpinfo.conf sc-restart uwsgi # it creates sockets /var/run/uwsgi/app/<appname>/socket # enable the nginx configuration sudo ln -s /etc/nginx/sites-available/phpinfo.conf /etc/nginx/sites-enabled/phpinfo.conf sc-restart nginx |
phpinfo
/etc/nginx/sites-available/phpinfo.conf |
server { server_name phpinfo.net; listen 80; root /var/www/php; index info.php; location ~ \.php$ { include uwsgi_params; uwsgi_modifier1 14; uwsgi_pass unix:/var/run/uwsgi/app/phpinfo/socket; } } |
/etc/uwsgi/apps-available/phpinfo.ini |
[uwsgi] master = true cheap = true idle = 600 die-on-idle = true # If app is not used often, it will exit and be launched again by systemd requested by users. manage-script-name = true plugins = php php-docroot = /var/www/php php-index = info.php php-allowed-ext = .php |
Log
- /var/log/uwsgi/app
Systemd
One service per app in systemd
/etc/systemd/system/uwsgi-app@.socket |
[Unit] Description=Socket for uWSGI app %i [Socket] ListenStream=/var/run/uwsgi/%i.socket SocketUser=www-%i SocketGroup=www-data SocketMode=0660 [Install] WantedBy=sockets.target |
/etc/systemd/system/uwsgi-app@.service |
[Unit] Description=%i uWSGI app After=syslog.target [Service] ExecStart=/usr/bin/uwsgi \ --ini /etc/uwsgi/apps-available/%i.ini \ --socket /var/run/uwsgi/%i.socket User=www-%i Group=www-data Restart=on-failure KillSignal=SIGQUIT Type=notify StandardError=syslog NotifyAccess=all |