« Nginx and Ubuntu » : différence entre les versions
De Banane Atomic
Aller à la navigationAller à la recherche
Ligne 58 : | Ligne 58 : | ||
fastcgi_pass unix:/run/php/php-fpm.sock; | fastcgi_pass unix:/run/php/php-fpm.sock; | ||
} | } | ||
# Explicit access to the root website, redirect to main page | |||
location = / { | |||
return 301 /wiki/Main_Page; | |||
} | |||
# Every other entry point will be disallowed | |||
location / { | |||
return 404; | |||
} | |||
} | } | ||
</filebox> | </filebox> | ||
* [https://www.mediawiki.org/wiki/Manual:Short_URL/Nginx example with short url] | * [https://www.mediawiki.org/wiki/Manual:Short_URL/Nginx example with short url] |
Version du 9 août 2023 à 22:36
Install
ai nginx php-fpm # check nginx and php-fpm are running sc-status nginx sc-status php8.2-fpm |
Site configuration
# enable a web site 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 { listen 80; root /var/www/php; index info.php; server_name phpinfo.net; location ~ \.php$ { include snippets/fastcgi-php.conf; # With php-fpm (or other unix sockets): fastcgi_pass unix:/run/php/php-fpm.sock; } } |
Mediawiki
/etc/nginx/site-availables/mediawiki.conf |
server { server_name mediawiki.domain.net; listen 80; root /var/www/mediawiki; index index.php; # deny access to cache location ^~ /cache/ { deny all; } # don't execute php from images location ^~ /images/ { } # Handling for the article path (pretty URLs) location /wiki/ { rewrite ^/wiki/(?<pagename>.*)$ /index.php; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php-fpm.sock; } # Explicit access to the root website, redirect to main page location = / { return 301 /wiki/Main_Page; } # Every other entry point will be disallowed location / { return 404; } } |