ubuntu:nginx:install_nginx_with_php_and_mysql_support
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
ubuntu:nginx:install_nginx_with_php_and_mysql_support [2019/12/05 00:43] – created peter | ubuntu:nginx:install_nginx_with_php_and_mysql_support [2020/07/15 09:30] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Ubuntu - nginx - Install Nginx with PHP and MySql support ====== | ====== Ubuntu - nginx - Install Nginx with PHP and MySql support ====== | ||
+ | Instruction how to install and configure Nginx, PHP (with PHP-FPM) and MySql server. | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Install MySql server ===== | ||
+ | |||
+ | <code bash> | ||
+ | sudo apt install mysql-server | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Install Nginx and PHP ===== | ||
+ | |||
+ | Install Nginx and PHP related packages including PHP-FPM (FastCGI Process Manager). | ||
+ | |||
+ | <code bash> | ||
+ | sudo apt install nginx php5-fpm php5-mysql | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Configure Nginx ===== | ||
+ | |||
+ | Configure Nginx to pass .php files to FPM. | ||
+ | |||
+ | Add these lines somewhere in the server {} section (or uncomment as they are already in the file): | ||
+ | |||
+ | <file bash / | ||
+ | location ~ \.php$ { | ||
+ | fastcgi_split_path_info ^(.+\.php)(/ | ||
+ | fastcgi_pass unix:/ | ||
+ | fastcgi_index index.php; | ||
+ | include fastcgi_params; | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Configure FPM ===== | ||
+ | |||
+ | Fix a security issue by configuring FPM. | ||
+ | |||
+ | More details here: http:// | ||
+ | |||
+ | Uncomment and modify this line: | ||
+ | |||
+ | <file bash / | ||
+ | ; | ||
+ | </ | ||
+ | |||
+ | so that it looks like this: | ||
+ | |||
+ | <file bash / | ||
+ | cgi.fix_pathinfo=0 | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Restart FPM ===== | ||
+ | |||
+ | <code bash> | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Start Nginx ===== | ||
+ | |||
+ | <code bash> | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Create a test PHP file ===== | ||
+ | |||
+ | Create a test PHP file in the Nginx document root, located in / | ||
+ | |||
+ | <code bash> | ||
+ | echo "<? | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Test ===== | ||
+ | |||
+ | Check if Nginx and FPM are configured correctly by loading this url: | ||
+ | |||
+ | < | ||
+ | http:// | ||
+ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | Replace {server} with the hostname or IP address of your server. | ||
+ | </ | ||
+ | |||
+ | |||
+ | If you see a PHP a list of PHP configurations everything is correctly configured. | ||
ubuntu/nginx/install_nginx_with_php_and_mysql_support.1575506598.txt.gz · Last modified: 2020/07/15 09:30 (external edit)