JavaEar 专注于收集分享传播有价值的技术资料

Linux: Setup PHP FastCGI for Monkey Server

问题描述


英文原文

I'm trying to get PHP installed on my Linux device which already has Monkey Server installed, I do not have Apache installed. I want to be able to use FastCGI. I've downloaded and installed PHP7 according to these and these instructions and made sure the files are setup correctly; for the second link I did not install all of the packages listed at the beginning but most are already installed. The problem I am having is when I execute /etc/init.d/php-fpm start I get a list of errors which are generated from the script trying to run /sbin/php-fpm, the errors are as follows:

  1. Starting php-fpm
  2. /sbin/php-fpm: line 1: [Unit]: command not found
  3. /sbin/php-fpm: line 2: PHP: command not found
  4. /sbin/php-fpm: line 3: network.target: command not found
  5. /sbin/php-fpm: line 5: [Service]: command not found
  6. /sbin/php-fpm: line 8: --nodaemonize: command not found
  7. /sbin/php-fpm: line 9: -USR2: command not found
  8. /sbin/php-fpm: line 11: [Install]:
  9. command not found ................................... failed

The /sbin/php-fpm file is as follows:

[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target

[Service]
Type=@php_fpm_systemd@
PIDFile=@localstatedir@/run/php-fpm.pid
ExecStart=@sbindir@/php-fpm --nodaemonize --fpm-config @sysconfdir@/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID

[Install]
WantedBy=multi-user.target

Lastly, I am running on a Yocto build of Linux so I do not have the luxury of sudo apt-get install <package>. The second hyperlink from above I couldn't complete the instructions involving the commands insserv and systemctl because those two commands are not present. Any help is appreciated, I just want FastCGI on a lightweight server for embedded Linux. If there are better options I am open to them but Apache is too big.

Edit:

I believe now my issues may be because I do not have systemd on my Linux distrubution which is why it is not handling items like [Unit]. Could someone please comment on this? I'm not familiar with systemd.


中文翻译

I'm trying to get PHP installed on my Linux device which already has Monkey Server installed, I do not have Apache installed. I want to be able to use FastCGI. I've downloaded and installed PHP7 according to these and these instructions and made sure the files are setup correctly; for the second link I did not install all of the packages listed at the beginning but most are already installed. The problem I am having is when I execute /etc/init.d/php-fpm start I get a list of errors which are generated from the script trying to run /sbin/php-fpm, the errors are as follows:

  1. Starting php-fpm
  2. /sbin/php-fpm: line 1: [Unit]: command not found
  3. /sbin/php-fpm: line 2: PHP: command not found
  4. /sbin/php-fpm: line 3: network.target: command not found
  5. /sbin/php-fpm: line 5: [Service]: command not found
  6. /sbin/php-fpm: line 8: --nodaemonize: command not found
  7. /sbin/php-fpm: line 9: -USR2: command not found
  8. /sbin/php-fpm: line 11: [Install]:
  9. command not found ................................... failed

The /sbin/php-fpm file is as follows:

[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target

[Service]
Type=@php_fpm_systemd@
PIDFile=@localstatedir@/run/php-fpm.pid
ExecStart=@sbindir@/php-fpm --nodaemonize --fpm-config @sysconfdir@/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID

[Install]
WantedBy=multi-user.target

Lastly, I am running on a Yocto build of Linux so I do not have the luxury of sudo apt-get install <package>. The second hyperlink from above I couldn't complete the instructions involving the commands insserv and systemctl because those two commands are not present. Any help is appreciated, I just want FastCGI on a lightweight server for embedded Linux. If there are better options I am open to them but Apache is too big.

Edit:

I believe now my issues may be because I do not have systemd on my Linux distrubution which is why it is not handling items like [Unit]. Could someone please comment on this? I'm not familiar with systemd.

I'm trying to get PHP installed on my Linux device which already has Monkey Server installed, I do not have Apache installed. I want to be able to use FastCGI. I've downloaded and installed PHP7 according to these and these instructions and made sure the files are setup correctly; for the second link I did not install all of the packages listed at the beginning but most are already installed. The problem I am having is when I execute /etc/init.d/php-fpm start I get a list of errors which are generated from the script trying to run /sbin/php-fpm, the errors are as follows:

  1. Starting php-fpm
  2. /sbin/php-fpm: line 1: [Unit]: command not found
  3. /sbin/php-fpm: line 2: PHP: command not found
  4. /sbin/php-fpm: line 3: network.target: command not found
  5. /sbin/php-fpm: line 5: [Service]: command not found
  6. /sbin/php-fpm: line 8: --nodaemonize: command not found
  7. /sbin/php-fpm: line 9: -USR2: command not found
  8. /sbin/php-fpm: line 11: [Install]:
  9. command not found ................................... failed

The /sbin/php-fpm file is as follows:

[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target

[Service]
Type=@php_fpm_systemd@
PIDFile=@localstatedir@/run/php-fpm.pid
ExecStart=@sbindir@/php-fpm --nodaemonize --fpm-config @sysconfdir@/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID

[Install]
WantedBy=multi-user.target

Lastly, I am running on a Yocto build of Linux so I do not have the luxury of sudo apt-get install <package>. The second hyperlink from above I couldn't complete the instructions involving the commands insserv and systemctl because those two commands are not present. Any help is appreciated, I just want FastCGI on a lightweight server for embedded Linux. If there are better options I am open to them but Apache is too big.

Edit:

I believe now my issues may be because I do not have systemd on my Linux distrubution which is why it is not handling items like [Unit]. Could someone please comment on this? I'm not familiar with systemd.

I'm trying to get PHP installed on my Linux device which already has Monkey Server installed, I do not have Apache installed. I want to be able to use FastCGI. I've downloaded and installed PHP7 according to these and these instructions and made sure the files are setup correctly; for the second link I did not install all of the packages listed at the beginning but most are already installed. The problem I am having is when I execute /etc/init.d/php-fpm start I get a list of errors which are generated from the script trying to run /sbin/php-fpm, the errors are as follows:

  1. Starting php-fpm
  2. /sbin/php-fpm: line 1: [Unit]: command not found
  3. /sbin/php-fpm: line 2: PHP: command not found
  4. /sbin/php-fpm: line 3: network.target: command not found
  5. /sbin/php-fpm: line 5: [Service]: command not found
  6. /sbin/php-fpm: line 8: --nodaemonize: command not found
  7. /sbin/php-fpm: line 9: -USR2: command not found
  8. /sbin/php-fpm: line 11: [Install]:
  9. command not found ................................... failed

The /sbin/php-fpm file is as follows:

[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target

[Service]
Type=@php_fpm_systemd@
PIDFile=@localstatedir@/run/php-fpm.pid
ExecStart=@sbindir@/php-fpm --nodaemonize --fpm-config @sysconfdir@/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID

[Install]
WantedBy=multi-user.target

Lastly, I am running on a Yocto build of Linux so I do not have the luxury of sudo apt-get install <package>. The second hyperlink from above I couldn't complete the instructions involving the commands insserv and systemctl because those two commands are not present. Any help is appreciated, I just want FastCGI on a lightweight server for embedded Linux. If there are better options I am open to them but Apache is too big.

Edit:

I believe now my issues may be because I do not have systemd on my Linux distrubution which is why it is not handling items like [Unit]. Could someone please comment on this? I'm not familiar with systemd.

1个回答

    最佳答案

  1. 英文原文

    Default Yocto build does not use systemd as init. For a lightweight server, I did recommend the lighttpd server and it has FastCGI support. Using Yocto you should build php and lighttpd and then transfer the php-cgi and lighttpd-module-fastcgi ipk's generated to the module. php and lighttpd can be included in the image by having

    IMAGE_INSTALL_append = " php lighttpd"
    

    in your local.conf file. The links that you refer to in your post are useless for Yocto.


    中文翻译

    Default Yocto build does not use systemd as init. For a lightweight server, I did recommend the lighttpd server and it has FastCGI support. Using Yocto you should build php and lighttpd and then transfer the php-cgi and lighttpd-module-fastcgi ipk's generated to the module. php and lighttpd can be included in the image by having

    IMAGE_INSTALL_append = " php lighttpd"
    

    in your local.conf file. The links that you refer to in your post are useless for Yocto.