Nginx 1.4.x auf Unix Systemen
Diese Dokumentation deckt die Installation und Konfiguration von PHP mit
PHP-FPM für ein Nginx 1.4.x HTTP Server ab.
Diese Anleitung setzt voraus, dass Sie Nginx aus dem Quelltext erstellt haben
und dadurch alle Binaries haben und die Konfigurations Dateien in
/usr/local/nginx
abgelegt sind. Wenn dies nicht der Fall ist
und Sie Nginx über eine andere Quelle bezogen haben, dann
sehen Sie bitte unter » Nginx Wiki nach,
um dieses Manual für Ihre Installation zu übersetzen.
Diese Anleitung wird die Basics der Konfiguration eines Nginx Servers abdecken,
um PHP Applikationen auszuführen und unter Port 80 bereitzustellen. Eine Studie
der Nginx und PHP-FPM Dokumentation ist Voraussetzung für eine optimale Installation,
die auch über den Umfang dieser Dokumentation hinaus geht.
Hinweis: In dieser Dokumentation wurden Versionsnummern durchgehend mit
einem 'x' ersetzt. Dies stellt sicher, dass die Dokumentation auch für künftige
Versionen richtig bleibt. Bitte ersetzen Sie diese soweit notwendig mit Ihrer
entstprechenden Version.
-
Voraussetzung ist, dass Sie im Nginx Wiki die
» Installations Seite
besuchen, um Nginx für Ihr System zu erhalten und zu installieren.
-
Erhalten und entpacken der PHP-Quelle:
-
Konfigurieren und Erstellen von PHP. Dies ist die Stelle, an der Sie
Ihre PHP Installation individuell mit verschiedenen Optionen anpassen.
Sowas wie: welche Erweiterung (extension) aktiviert (enabled) wird.
Führen Sie ./configure --help für eine Liste der verfügbaren Optionen aus.
In unserem Beispiel werden wir eine einfache Konfiguration mit PHP-FPM and MySQLi
Unterstützung durchführen.
-
Erhalten und verschieben von Konfigurationsdateien an die richtige Stelle
-
Es ist wichtig, dass wir Nginx daran hindern Anfragen an das PHP-FPM Backend
zu leiten, wenn die Datei nicht existiert. Dies erlaubt uns willkürliche Skript
Eingaben (script injection) zu verhindern.
Wir können dies durch eine Einstellung beheben, indem wir innerhalb unserer php.ini Datei
die cgi.fix_pathinfo
Direktive auf 0
setzen.
Einlesen der php.ini:
Positionieren auf cgi.fix_pathinfo=
und wie folgt modifizieren:
-
php-fpm.conf muss angepasst werden, damit php-fpm als User www-data
und Gruppe www-data ausgeführt wird, bevor wir es Service starten können:
Finden und modifizieren Sie folgendes:
Der php-fpm Service kann wie folgt gestartet werden:
Diese Anleitung wird nicht weiter auf die php-fpm Konfiguration eingehen. Wenn Sie
weiteres Interesse an der php-fpm Konfiguration haben, dann ziehen Sie bitte die
entsprechende Dokumentation heran.
-
Nginx muss jetzt konfiguriert werden, um PHP Applikationen ablaufen zu lassen:
Modifizieren Sie den Bereich voreingestellte Positionen, um zu gewährleisten,
dass .php Dateien verarbeitet werden:
Der nächste Schritt soll sicherstellen, dass .php Dateien an
des PHP-FPM Backend geleitet werden. Geben Sie unter dem auskommentierten
standard PHP location Block folgendes ein:
Neustart von Nginx.
-
Erstellen einer Test Datei
Nun navigieren Sie zu http://localhost. Die Funktion phpinfo() sollte nun angezeigt werden.
Folgen Sie den obigen Schritten und Sie werden ein laufenden Nginx Web-Server
mit Unterstützung für PHP als ein FPM
SAPI
Modul erhalten.
Natürlich sind noch viel mehr Konfigurations-Einstellungen für Nginx und PHP verfügbar.
Für weitere Informationen geben Sie ./configure --help im entsprechenden
Quellpfad ein.
Lenny ¶8 years ago
Building from source is not easy if something is a bit different, and I had a hard time with some directory and configuration options. I was floundering around the web until I found this site that translated from Chinese. No one else had the solution. I couldn't get php fpm to start until I changed the directory (Item 2.ERROR: Unable to globalize). I had other issues listed but I was able to solve them. Please don't delete this, it is very useful info.
The original site (it is in Chinese, not my site, but I want to give credit):
(there is some more there, you can goto the site)
blog.dream1987.top/?paged=2
Installation problems:
1. configure: error:. Xml2-config not found Please check your libxml2 installation.
solution:
apt-get install libxml2-dev
2.Warning: Declaration of PEAR_Installer :: download () should be compatible with & PEAR_Downloader :: download ($ params) in phar: ///root/php-7.0.0alpha1/pear/install-pear-nozlib.phar/PEAR /Installer.php on line 43
Warning: Declaration of PEAR_PackageFile_Parser_v2 :: parse () should be compatible with PEAR_XMLParser :: parse ($ data) in phar: ///root/php-7.0.0alpha1/pear/install-pear-nozlib.phar/PEAR/PackageFile/ Parser / v2.php on line 113
[PEAR] Archive_Tar - already installed: 1.3.13
[PEAR] Console_Getopt - already installed: 1.3.1
[PEAR] Structures_Graph- already installed: 1.0.4
Warning: Declaration of PEAR_Task_Replace :: init () should be compatible with PEAR_Task_Common :: init ($ xml, $ fileAttributes, $ lastVersion) in phar: ///root/php-7.0.0alpha1/pear/install-pear-nozlib. phar / PEAR / Task / Replace.php on line 31
[PEAR] XML_Util - already installed: 1.2.3
Warning: Declaration of PEAR_Task_Windowseol :: init () should be compatible with PEAR_Task_Common :: init ($ xml, $ fileAttributes, $ lastVersion) in phar: ///root/php-7.0.0alpha1/pear/install-pear-nozlib. phar / PEAR / Task / Windowseol.php on line 76
Warning: Declaration of PEAR_Task_Unixeol :: init () should be compatible with PEAR_Task_Common :: init ($ xml, $ fileAttributes, $ lastVersion) in phar: ///root/php-7.0.0alpha1/pear/install-pear-nozlib. phar / PEAR / Task / Unixeol.php on line 76
[PEAR] PEAR - already installed: 1.9.5
solution:
Workaround not found (http://pear.php.net/bugs/bug.php?id=20554)
3. Start php-fpm
1.ERROR: failed to open configuration file '/usr/local/etc/php-fpm.conf': No such file or directory (2)
ERROR: failed to load configuration file '/usr/local/etc/php-fpm.conf'
ERROR: FPM initialization failed
solution:
Php-fpm.conf copy files from the source file to that location.
cp /root/php-7.0.0alpha1/sapi/fpm/php-fpm.conf /usr/local/etc/php-fpm.conf
2.ERROR: Unable to globalize '/usr/local/NONE/etc/php-fpm.d/*.conf' (ret = 2) from /usr/local/etc/php-fpm.conf at line 125.
ERROR: failed to load configuration file '/usr/local/etc/php-fpm.conf'
ERROR: FPM initialization failed
solution:
Edit /usr/local/etc/php-fpm.conf document introduced * .conf part, change to the correct path include = / usr / local / etc / php-fpm.d / *. Conf
If there is no /usr/local/etc/php-fpm.d directory, create the directory.
3.WARNING: Nothing matches the include pattern '/usr/local/etc/php-fpm.d/*.conf' from /usr/local/etc/php-fpm.conf at line 125.
ERROR:. No pool defined at least one pool section must be specified in config file
ERROR: failed to post process the configuration
ERROR: FPM initialization failed
solution:
cp www.conf.default www.conf
4.ERROR: [pool www] can not get gid for group 'nobody'
ERROR: FPM initialization failed
solution:
Www.conf open files, user and group users into nginx default settings, usually the default is www-data.
1097625354 at qq dot com ¶5 years ago
cp php/php.ini-development php/lib/php.ini
cp php/etc/php-fpm.conf.default php/etc/php-fpm.conf
cp php/etc/php-fpm.d/www.conf.default php/etc/php-fpm.d/www.conf
MiXiM ¶2 years ago
With ubuntu use
:>sudo apt install php-mbstring
uanaoeng at outlook dot com ¶5 years ago
When I run the following command to start the php-fpm:
/usr/local/bin/php-fpm
I got the following error information:
Unable to globalize '/usr/local/NONE/etc/php-fpm.d/*.conf' (ret=2) from /usr/local/etc/php-fpm.conf at line 143.
To fix this error, do:
change the string "include=NONE/etc/php-fpm.d/*.conf" to "include=etc/php-fpm.d/*.conf" in the file "/usr/local/etc/php-fpm.conf" with text editor.
After that, I try to start the php-fpm again and got error information again:
Nothing matches the include pattern '/usr/local/etc/php-fpm.d/*.conf' from /usr/local/etc/php-fpm.conf at line 143.
To fix this error, do:
cp /usr/local/etc/php-fpm.d/www.conf.default /usr/local/etc/php-fpm.d/www.conf
610010559 at qq dot com ¶4 years ago
in linux system, if you want to add php-fpm service to system service; it is easy to do that, because php offer the relate shell script:
after make and make install;enter the source code package sapi/fpm/init.d.php-fpm ; type the code in the linux system.
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
then you can use "php-fpm {start|stop|force-quit|restart|reload|status|configtest} " command to control your php-fpm program more convenient .
Akash Kumar Sharma ¶8 years ago
If you get "File not found" error then add "root ROOT_DIR_LOCATION" directive to PHP location block i.e. "location ~* \.php$ { }" , where ROOT_DIR_LOCATION is root directory like "/usr/share/nginx/html" .
nguyentienlong88 at gmail dot com ¶8 years ago
at step 3, if there is no configure script yet, you need to rebuiding configure script using this command:
./buildconf --force