mirror of
https://github.com/AlexBocken/mykb.git
synced 2024-12-28 22:24:02 +01:00
added initial php installation guide
This commit is contained in:
parent
f59434b1d9
commit
76109d76ff
62
docs/php.md
Normal file
62
docs/php.md
Normal file
@ -0,0 +1,62 @@
|
||||
# PHP
|
||||
An easily integratable language for dynamic HTML with read/write file access possible on the server side.
|
||||
|
||||
# Installation
|
||||
As always, we're assuming Debian + Nginx for this.
|
||||
|
||||
```sh
|
||||
apt update
|
||||
apt install php php-fpm
|
||||
```
|
||||
`php-fpm` should automatically enable it's service.
|
||||
Verify via `systemctl status php7.3-fpm.service`
|
||||
|
||||
# Setup
|
||||
Check whether you want to use a TCP connection or a UNIX socket for php connections.
|
||||
The default and recommended way is TCP/IP.
|
||||
|
||||
## TCP/IP
|
||||
You can edit the IP and port of the connection in `/etc/php/7.3/fpm/pool.d/www.conf`
|
||||
The default is:
|
||||
```
|
||||
listen = 127.0.0.1:9000
|
||||
```
|
||||
|
||||
## Socket
|
||||
For socket, use:
|
||||
```
|
||||
listen = run/php/php7.3-fpm.sock
|
||||
```
|
||||
|
||||
## Nginx
|
||||
To enable nginx to talk to php add the following to your website config:
|
||||
```nginx
|
||||
location ~\.php${
|
||||
include snippets/fastcgi-php.conf
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
}
|
||||
```
|
||||
replace TCP/IP address with the appropriate socket file if that's your preferred setup.
|
||||
|
||||
Create a file in the root dir for your website (so probably somwhere in `/var/www/`) ending in `.php` with the content:
|
||||
```php
|
||||
<?php
|
||||
phpinfo();
|
||||
```
|
||||
|
||||
And visit `example.com/file.php` to see whether it worked.
|
||||
You should get a screen with a lot of information about your php installation.
|
||||
|
||||
## File writing permissions
|
||||
Per default PHP is unable to read or write to your server drive.
|
||||
It is best for this to re-own any directories where php will be writing to to the user and group `www-data`.
|
||||
Thus a
|
||||
```sh
|
||||
chown -R www-data:www-data <dir>
|
||||
chmod -R 744 <dir>
|
||||
```
|
||||
should be a good starting-off point.
|
||||
Files only need to have permissions of `644` of course so maybe change that as well.
|
||||
|
||||
# Learning PHP
|
||||
If you're completely new to php [w3schools' course](https://www.w3schools.com/php) is probably a good starting point.
|
1
index.md
1
index.md
@ -14,6 +14,7 @@ Happy to accept pull requests for new topics!
|
||||
- [neomutt](docs/neomutt.md) highly customizable TUI email client
|
||||
- [rainloop](docs/rainloop.md) webbased email client
|
||||
- [server](docs/ServerSetup.md) short guide for hosting a server
|
||||
- [php](docs/php.md) short guide for getting php up and running with nginx
|
||||
|
||||
# Admin
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user