diff --git a/blog/add-php-to-nginx.html b/blog/add-php-to-nginx.html new file mode 100644 index 0000000..4131972 --- /dev/null +++ b/blog/add-php-to-nginx.html @@ -0,0 +1,75 @@ + + + + + + + + + + + + + Adding PHP to NGINX server + + + +
+

Adding PHP to NGINX server

+
+ +
+
+ +
+
+

PHP is one of the highest used programming languages for websites, and it allows you to add practically any functionality you'd ever want to your sites.

+ +

Install

+
sudo apt install php-fpm php-mysql
+ +

Um, I forgor

+
sudo nano /etc/php//fpm/php.ini
+

Comment the cgi.fix_pathinfo line, to look like below

+
#set cgi.fix_pathinfo = 0
+ +

Add to Website's NGINX conf

+

For each website you want to use php, you'll need to edit the confige file

+
sudo vim /etc/nginx/sites-available/
+

The following code needs adding within the XXX block

+
location ~ \.php$ {
+	include snippets/fastcgi-php.conf;
+	fastcgi_pass unix:/run/php/php-fpm.sock;
+}
+

This will use nginx's fastcgi-php.conf snippet which is more secure by deafult than many other php/nginx configs because it 404s if the files doesn't exist. Read Neal Poole'sDon't trust the tutorials for more info.

+ +

Reload NGINX

+
sudo systemctl reload nginx
+ +

Test it works

+

Create a PHP file e.g. filename.php in the website's directory, and add the snippet below into it

+
+

Go to that webpage in your browser e.g. domain.co.uk/filename.php, and if php is working you should see a dump of your PHP's version, headers, etc.

+ +

Make nginx use index.php as homepage/root

+

Now we'll set nginx to load up index.php as the root of the website, if it exists. Open the site's config with an editor

+
vim /etc/nginx/sites-available/
+

Change the index line to rad as below. This will then tell the server to load index.php, and if it doesn't exists, load index.html in it's stead

+
index index.php index.html
+			
+
+ + + + + diff --git a/blog/adminer-setup.html b/blog/adminer-setup.html index 258995d..f8c9b6a 100644 --- a/blog/adminer-setup.html +++ b/blog/adminer-setup.html @@ -35,7 +35,7 @@

To run adminer, you'll need a webserver with php set up. Thankfully I'm a great guy, and have written about these topics before.

Download the latest release

diff --git a/blog/guide-to-server-hosting.html b/blog/guide-to-server-hosting.html index 17e6beb..093055d 100644 --- a/blog/guide-to-server-hosting.html +++ b/blog/guide-to-server-hosting.html @@ -102,6 +102,7 @@
  • mailserver
  • cockpit for noob-friendly server management
  • Basic Homeserver for a web developer/designer
  • +
  • Host client websites
  • diff --git a/blog/index.html b/blog/index.html index 54317ad..37857e1 100644 --- a/blog/index.html +++ b/blog/index.html @@ -38,6 +38,7 @@

    2022