Add lamp/php.md
This commit is contained in:
parent
c44ace4208
commit
ed7a646de1
135
lamp/php.md
Normal file
135
lamp/php.md
Normal file
@ -0,0 +1,135 @@
|
||||
|
||||
# Installation
|
||||
|
||||
```sh
|
||||
dnf install php82
|
||||
dnf install php82-php-opcache php82-php-gd php82-php-curl php82-php-mysqlnd php82-php-mbstring
|
||||
dnf install php82-php-devel php82-php-xml php82-php-pear php82-php-fpm php82-php-mysql php82-php-pdo
|
||||
dnf install php82-php-json php82-php-zip php82-php-common php82-php-cli php82-php-xmlrpc
|
||||
dnf install php82-php-xml php82-php-tidy php82-php-soap php82-php-bcmath
|
||||
```
|
||||
|
||||
```sh
|
||||
dnf install php74
|
||||
dnf install php74-php-opcache php74-php-gd php74-php-curl php74-php-mysqlnd php74-php-mbstring
|
||||
dnf install php74-php-devel php74-php-xml php74-php-pear php74-php-fpm php74-php-mysql php74-php-pdo
|
||||
dnf install php74-php-json php74-php-zip php74-php-common php74-php-cli php74-php-xmlrpc
|
||||
dnf install php74-php-xml php74-php-tidy php74-php-soap php74-php-bcmath
|
||||
```
|
||||
|
||||
# Configure
|
||||
|
||||
```sh
|
||||
sed -i 's/:9000/:9074/' /etc/opt/remi/php74/php-fpm.d/www.conf
|
||||
sed -i 's/:9000/:9080/' /etc/opt/remi/php82/php-fpm.d/www.conf
|
||||
semanage port -a -t http_port_t -p tcp 9080
|
||||
semanage port -a -t http_port_t -p tcp 9074
|
||||
```
|
||||
|
||||
# SystemD
|
||||
|
||||
```
|
||||
systemctl start php82-php-fpm
|
||||
systemctl start php74-php-fpm
|
||||
systemctl enable php74-php-fpm
|
||||
systemctl enable php82-php-fpm
|
||||
systemctl status php74-php-fpm
|
||||
systemctl status php82-php-fpm
|
||||
```
|
||||
|
||||
# php-cgi
|
||||
|
||||
`/var/www/cgi-bin/php82.fcgi`
|
||||
|
||||
```sh
|
||||
#!/bin/bash
|
||||
exec /bin/php82-cgi
|
||||
```
|
||||
|
||||
`/var/www/cgi-bin/php74.fcgi`
|
||||
|
||||
```sh
|
||||
#!/bin/bash
|
||||
exec /bin/php74-cgi
|
||||
```
|
||||
|
||||
`chmod 755 /var/www/cgi-bin/php*`
|
||||
|
||||
# httpd configs
|
||||
|
||||
`/etc/httpd/conf.d/php82.conf`
|
||||
|
||||
```xml
|
||||
Listen 8082
|
||||
|
||||
<VirtualHost *:8082>
|
||||
ServerAdmin root@localhost.com
|
||||
ServerName exmaple82.com
|
||||
DocumentRoot /var/www/html
|
||||
DirectoryIndex index.php index.html
|
||||
<FilesMatch "\.php$">
|
||||
<If "-f %{REQUEST_FILENAME}">
|
||||
SetHandler "proxy:unix:/var/opt/remi/php82/run/php-fpm/www.sock|fcgi://localhost"
|
||||
</If>
|
||||
</FilesMatch>
|
||||
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
|
||||
AddHandler php82-fcgi .php
|
||||
Action php82-fcgi /cgi-bin/php82.fcgi
|
||||
<Directory "/var/www/html">
|
||||
AllowOverride All
|
||||
</Directory>
|
||||
</VirtualHost>
|
||||
```
|
||||
|
||||
`/etc/httpd/conf.d/php74.conf`
|
||||
|
||||
```xml
|
||||
Listen 8074
|
||||
|
||||
<VirtualHost *:8074>
|
||||
ServerAdmin root@localhost.com
|
||||
ServerName exmaple74.com
|
||||
DocumentRoot /var/www/html
|
||||
DirectoryIndex index.php index.html
|
||||
<FilesMatch "\.php$">
|
||||
<If "-f %{REQUEST_FILENAME}">
|
||||
SetHandler "proxy:unix:/var/opt/remi/php74/run/php-fpm/www.sock|fcgi://localhost"
|
||||
</If>
|
||||
</FilesMatch>
|
||||
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
|
||||
AddHandler php74-fcgi .php
|
||||
Action php74-fcgi /cgi-bin/php74.fcgi
|
||||
<Directory "/var/www/html">
|
||||
AllowOverride All
|
||||
</Directory>
|
||||
</VirtualHost>
|
||||
```
|
||||
|
||||
|
||||
# Set Default
|
||||
|
||||
```sh
|
||||
scl enable php74 bash
|
||||
php -v
|
||||
scl enable php82 bash
|
||||
php -v
|
||||
```
|
||||
|
||||
|
||||
# Test
|
||||
|
||||
```sh
|
||||
echo "<?php phpinfo(); ?>" > /var/www/html/index.php
|
||||
```
|
||||
|
||||
```sh
|
||||
systemctl restart php82-php-fpm
|
||||
systemctl restart php74-php-fpm
|
||||
systemctl restart httpd
|
||||
```
|
||||
|
||||
|
||||
```sh
|
||||
firefox http://your-server:8082
|
||||
firefox http://your-server:8074
|
||||
```
|
||||
Loading…
x
Reference in New Issue
Block a user