Задать вопрос
@Scorpiored88

Как разрешить запись файла fastcgi?

Всем доброго!
Есть не большой django проект, который мне пришлось немного расширить. Запускает и работает это все через связку fastcgi и Lighttpd.
Так вот, после расширения функционала fastcgi не хочет запускатся, говорит что у него нету прав на создания PID файла (/root/projectDir) и лог файла (/var/log/) хотя права на папки(/root/progectDir/pidDIR и /var/log/ ) Chmod 775.
Подскажите Пожалуйста
service fastcgi2 restart
Job for fastcgi2.service failed. See 'systemctl status fastcgi2.service' and 'journalctl -xn' for details.

systemctl status fastcgi2.service
● fastcgi2.service - LSB: Start FastCGI2 servers with Django.
   Loaded: loaded (/etc/init.d/fastcgi2)
   Active: failed (Result: exit-code) since Thu 2017-03-23 16:38:18 UTC; 1min 0s ago
  Process: 1128 ExecStop=/etc/init.d/fastcgi2 stop (code=exited, status=0/SUCCESS)
  Process: 1502 ExecStart=/etc/init.d/fastcgi2 start (code=exited, status=1/FAILURE)

Mar 23 16:38:18 raspberrypi fastcgi2[1502]: Starting FastCGI servers: /etc/init.d/fastcgi2, mainv2_projectRestarting lighttpd (via systemctl): lighttpd.service.
Mar 23 16:38:18 raspberrypi fastcgi2[1502]: chmod: cannot access ‘/root/projectFolder/run/mainv2_project.pid’: No such file or directory
Mar 23 16:38:18 raspberrypi systemd[1]: fastcgi2.service: control process exited, code=exited status=1
Mar 23 16:38:18 raspberrypi systemd[1]: Failed to start LSB: Start FastCGI2 servers with Django..
Mar 23 16:38:18 raspberrypi systemd[1]: Unit fastcgi2.service entered failed state.


journalctl -xn

-- Logs begin at Thu 2017-03-23 16:18:43 UTC, end at Thu 2017-03-23 16:43:45 UTC. --
Mar 23 16:43:44 raspberrypi lighttpd[1643]: Syntax OK
Mar 23 16:43:45 raspberrypi systemd[1]: Started Lighttpd Daemon.
-- Subject: Unit lighttpd.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit lighttpd.service has finished starting up.
-- 
-- The start-up result is done.
Mar 23 16:43:45 raspberrypi fastcgi2[1629]: Starting FastCGI servers: /etc/init.d/fastcgi2, mainv2_projectRestarting lighttpd (via systemctl): lighttpd.service.
Mar 23 16:43:45 raspberrypi fastcgi2[1629]: chmod: cannot access ‘/root/projectFolder/run/mainv2_project.pid’: No such file or directory
Mar 23 16:43:45 raspberrypi systemd[1]: fastcgi2.service: control process exited, code=exited status=1
Mar 23 16:43:45 raspberrypi systemd[1]: Failed to start LSB: Start FastCGI2 servers with Django..
-- Subject: Unit fastcgi2.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit fastcgi2.service has failed.
-- 
-- The result is failed.
Mar 23 16:43:45 raspberrypi systemd[1]: Unit fastcgi2.service entered failed state.
Mar 23 16:43:45 raspberrypi lighttpd[1653]: 2017-03-23 16:43:45: (log.c.118) opening errorlog '/var/log/lighttpd/error.log' failed: Permission denied
Mar 23 16:43:45 raspberrypi systemd[1]: lighttpd.service: main process exited, code=exited, status=255/n/a
Mar 23 16:43:45 raspberrypi systemd[1]: Unit lighttpd.service entered failed state.


/etc/init.d/fastcgi2
#! /bin/bash
### BEGIN INIT INFO
# Provides:          FastCGI2 servers for Django
# Required-Start:    networking
# Required-Stop:     networking
# Default-Start:     2 3 4 5
# Default-Stop:      S 0 1 6
# Short-Description: Start FastCGI2 servers with Django.
# Description:       Django, in order to operate with FastCGI, must be started
#                    in a very specific way with manage.py. This must be done
#                    for each DJango web server that has to run.
### END INIT INFO
#
# Author:  Guillermo Fernandez Castellanos
#          <guillermo.fernandez.castellanos AT gmail.com>.
#
# Version: @(#)fastcgi 0.1 11-Jan-2007 guillermo.fernandez.castellanos AT gmail.com
#

#### SERVER SPECIFIC CONFIGURATION
DJANGO_SITES="mainv2_project"
SITES_PATH=/root/projectFolder
RUNFILES_PATH=$SITES_PATH/run
HOST=127.0.0.1
PORT_START=1807
RUN_AS=www-data
FCGI_METHOD=threaded
#### DO NOT CHANGE ANYTHING AFTER THIS LINE!

set -e

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="FastCGI servers"
NAME=$0
SCRIPTNAME=/etc/init.d/$NAME

#
#       Function that starts the daemon/service.
#
d_start()
{
    # Starting all Django FastCGI processes
    PORT=$PORT_START
    for SITE in $DJANGO_SITES
    do
        echo -n ", $SITE"
	rm -rf $RUNFILES_PATH/$SITE.pid
        if [ -f $RUNFILES_PATH/$SITE.pid ]; then
            echo -n " already running"
        else
            start-stop-daemon --start --quiet \
                       --pidfile $RUNFILES_PATH/$SITE.pid \
                       --chuid $RUN_AS --exec /usr/bin/env -- python \
                       $SITES_PATH/$SITE/manage.py runfcgi \
                       method=$FCGI_METHOD \
                       host=$HOST port=$PORT pidfile=$RUNFILES_PATH/$SITE.pid
	/etc/init.d/lighttpd restart
            chmod 400 $RUNFILES_PATH/$SITE.pid
        fi
        let "PORT = $PORT + 1"
    done
}

#
#       Function that stops the daemon/service.
#
d_stop() {
    # Killing all Django FastCGI processes running
    for SITE in $DJANGO_SITES
    do
        echo -n ", $SITE"
        start-stop-daemon --stop --quiet --pidfile $RUNFILES_PATH/$SITE.pid \
                          || echo -n " not running"
        if [ -f $RUNFILES_PATH/$SITE.pid ]; then
           rm -f $RUNFILES_PATH/$SITE.pid
        fi
    done
}

ACTION="$1"
case "$ACTION" in
    start)
        echo -n "Starting $DESC: $NAME"
        d_start
        echo "."
        ;;

    stop)
        echo -n "Stopping $DESC: $NAME"
        d_stop
        echo "."
        ;;

    restart|force-reload)
        echo -n "Restarting $DESC: $NAME"
        d_stop
        sleep 1
        d_start
        echo "."
        ;;

    *)
        echo "Usage: $NAME {start|stop|restart|force-reload}" >&2
        exit 3
        ;;
esac

exit 0


/etc/lighttpd/lighttpd.conf

server.modules = (
	"mod_access",
	"mod_alias",
	"mod_compress",
 	"mod_redirect",
        "mod_rewrite",
	"mod_fastcgi"
)

server.document-root        = "/var/www/html"
server.upload-dirs          = ( "/var/cache/lighttpd/uploads" )
server.errorlog             = "/var/log/lighttpd/error.log"
server.pid-file             = "/var/run/lighttpd.pid"
server.username             = "www-data"
server.groupname            = "www-data"
server.port                 = 80


index-file.names            = ( "index.php", "index.html", "index.lighttpd.html" )
url.access-deny             = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

compress.cache-dir          = "/var/cache/lighttpd/compress/"
compress.filetype           = ( "application/javascript", "text/css", "text/html", "text/plain" )

# default listening port for IPv6 falls back to the IPv4 port
include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
include_shell "/usr/share/lighttpd/create-mime.assign.pl"
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"

  $SERVER["socket"] == "192.168.88.1.2:8080" {



                server.document-root = "/root/projectFolder/mainv2_project"
                fastcgi.server = (
                    "/server.fcgi" => (
                        "main" => (
                  #  "socket" => "/var/sock/main_first.sock",
                        "host" => "127.0.0.1",
             "port" => 1807,
  "check-local" => "disable",
                        )
                        ),
                        )
                alias.url = (
                        "/static" =>
"/root/projectFolder/mainv2_project/templates/static/",
                        )

                url.rewrite-once = (
                    "^(/static.*)$" => "$1",
                   "^/favicon\.ico$" => "/media/favicon.ico",
                    "^(/.*)$" => "/server.fcgi$1",
                                )
        }
  • Вопрос задан
  • 350 просмотров
Подписаться 1 Оценить 4 комментария
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы