Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung Nächste ÜberarbeitungBeide Seiten der Revision | ||
content:apache_phpfpm [2020/04/03 16:07] – [PHP Configuration] Daniel | content:apache_phpfpm [2020/04/06 08:49] – [About PHP- Modules] Daniel | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
- | ====== Howto setup a LAMP-Server in 2018 ====== | + | ====== Howto setup a LAMP-Server in 2018-2020 ====== |
This documentation is about how to set up a LAMP- Server (Linux, Apache, MySql, PhP) in the current, most stable way. The Reason for me writing this is, that default Installations of common Distruibutions are often based on an old way in Server- Configuration, | This documentation is about how to set up a LAMP- Server (Linux, Apache, MySql, PhP) in the current, most stable way. The Reason for me writing this is, that default Installations of common Distruibutions are often based on an old way in Server- Configuration, | ||
+ | |||
===== Choosing Installation-Media & Install Basic System ===== | ===== Choosing Installation-Media & Install Basic System ===== | ||
Zeile 108: | Zeile 109: | ||
</ | </ | ||
+ | |||
* I would suggest using a newer Version of php-fpm than in the default Repositories. E.g. using the Version of Repository " | * I would suggest using a newer Version of php-fpm than in the default Repositories. E.g. using the Version of Repository " | ||
* Either install the new Version with 1-Click-Install there **or** | * Either install the new Version with 1-Click-Install there **or** | ||
Zeile 115: | Zeile 117: | ||
</ | </ | ||
- | * Than, install mod_fcgi - it is used to tunnel request to php-fpm: | ||
- | < | ||
- | sudo zypper install apache2-mod_fcgid | ||
- | sudo a2enmod proxy proxy_fcgi setenvif | ||
- | |||
- | </ | ||
* Copy the configuration-files for php-fpm: | * Copy the configuration-files for php-fpm: | ||
Zeile 131: | Zeile 127: | ||
* Than go to / | * Than go to / | ||
* Explanation: | * Explanation: | ||
- | * This here is new for the setup: in "/ | ||
- | * If using sockets, make sure the path exists and is writeable by the apache- user (an that this mathces the user in www.conf for php-fpm) | ||
The " | The " | ||
Zeile 141: | Zeile 135: | ||
* pm.min_spare_servers = 6 | * pm.min_spare_servers = 6 | ||
* pm.max_spare_servers = 18 | * pm.max_spare_servers = 18 | ||
+ | |||
+ | ==== Using Sockets ==== | ||
+ | |||
+ | Whenever you can - you should use unix sockets instead of TCP/IP, because of less overhead. If you are on the same machine (apache and php-fpm), than you can. | ||
+ | |||
+ | So this here is new for the setup: in "/ | ||
+ | |||
+ | < | ||
+ | listen = / | ||
+ | listen.owner = wwwrun | ||
+ | listen.group = www | ||
+ | listen.mode = 0660 | ||
+ | |||
+ | </ | ||
+ | |||
+ | You need to make the file be created by systemd, so create a file / | ||
+ | |||
+ | < | ||
+ | d / | ||
+ | |||
+ | </ | ||
+ | |||
==== PHP Configuration ==== | ==== PHP Configuration ==== | ||
Zeile 158: | Zeile 174: | ||
=== About PHP- Modules === | === About PHP- Modules === | ||
- | many modules for PHP are offered in the Distrubution. I **would not recommend using those** - as they need to be compiled against your php. If you update PHP and your modules are the same, they may brake your PHP. Better use pearl / pecl and install modules with it! | + | many modules for PHP are offered in the Distrubution. I **would not recommend using those** - as all php-modules |
- | And again don' | + | Better |
- | and see [[https://www.php.net/manual/en/install.pecl.intro.php|https:// | + | For me, i needed: php-pear, php-pecl, php7-devel (for command phpize) |
+ | |||
+ | Which can be found in the Repo: [[https://build.opensuse.org/project/show/devel: | ||
+ | |||
+ | After that, modules can be installed by e.g. "pecl install imagick" | ||
+ | |||
+ | Restart | ||
===== Tell Apache to use php-fpm ===== | ===== Tell Apache to use php-fpm ===== | ||
- | After php-fpm | + | For making Apache use php-fpm |
+ | |||
+ | Caution: this has noting to do with "mod_fcgi"! You will not need mod_fcgi, as this would manage php itself in a new server, which we dont' want! " | ||
+ | |||
+ | * To enable this and all its dependencies, | ||
+ | |||
+ | < | ||
+ | sudo a2enmod setenvif rewrite proxy proxy_fcgi | ||
+ | |||
+ | </ | ||
+ | |||
+ | Now, tell proxy_fcgi to use php: | ||
- | * Edit / | + | * Create |
< | < | ||
Zeile 194: | Zeile 227: | ||
</ | </ | ||
+ | ===== Start and check Apache ===== | ||
Now you can start and enable apache2 | Now you can start and enable apache2 | ||
- | < | ||
+ | < | ||
sudo systemctl start apache2 | sudo systemctl start apache2 | ||
- | sudo systemctl enable | + | sudo systemctl enable |
</ | </ | ||
+ | |||
+ | check if the modules have beend loaded: | ||
+ | |||
+ | < | ||
+ | apache2ctl -M | ||
+ | |||
+ | </ | ||
+ | |||
+ | This should include proxy_fcgi_module now. | ||
+ | |||
+ | |||
+ | ==== Create a PHP- Test- File ==== | ||
+ | |||
+ | Create the File / | ||
+ | |||
+ | < | ||
+ | <?php | ||
+ | |||
+ | // Show all information, | ||
+ | phpinfo(); | ||
+ | |||
+ | ?> | ||
+ | |||
+ | </ | ||
+ | |||
+ | Now open your Web- Browser and go to: [[http:// | ||
+ | |||
+ | This should give you the complete Info of your php-configuration. If something fails, check if the above services are started an/or the logfiles. | ||
You are done. Now its up to you to fill Apache with content. Have fun! | You are done. Now its up to you to fill Apache with content. Have fun! | ||