0

我首先在我的服务器上进行部署,但我的权限有问题。

我正在使用 jenkins 进行部署,我的构建步骤如下所示:

 echo '
  parameters:
     database_driver: pdo_mysql
     database_host: %database.host%
     database_port: null
     database_name: symfonyapp
     database_user: %database.user%
     database_password: %database.password%
     mailer_transport: smtp
     mailer_host: 127.0.0.1
     mailer_user: null
     mailer_password: null
     locale: cs
     secret: 08b6b8f6548a96bd1ff1533ec02e39ae
  '> app/config/parameters.yml

export SYMFONY__DATABASE__USER=user
export SYMFONY__DATABASE__HOST=localhost
export SYMFONY__DATABASE__PASSWORD=secret

composer.phar install --optimize-autoloader
php app/console cache:clear --env=prod --no-debug
php app/console assetic:dump --env=prod --no-debug

touch app/logs/prod.log
chmod -R 777 app/cache
chmod -R 777 app/logs

但是我收到此错误并且不知道为什么,因为我设置了所有内容,文件夹日志和缓存也是可写的

[Fri Sep 06 12:09:24 2013] [error] [client 217.112.169.14] PHP Warning:  mkdir(): Permission denied in /projectPath/app/cache/prod/classes.php on line 315
[Fri Sep 06 12:09:24 2013] [error] [client 217.112.169.14] PHP Fatal error:  Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/anotherPath/app/logs/prod.log" could not be opened: failed to open stream: No such file or directory' in /projectPath/app/cache/prod/classes.php:4787\nStack trace:\n
#0 /projectPath/app/cache/prod/classes.php(4735): Monolog\\Handler\\StreamHandler->write(Array)\n
#1 /projectPath/app/cache/prod/classes.php(4664): Monolog\\Handler\\AbstractProcessingHandler->handle(Array)\n
#2 /projectPath/app/cache/prod/classes.php(4850): Monolog\\Handler\\AbstractHandler->handleBatch(Array)\n
#3 /projectPath/app/cache/prod/classes.php(5066): Monolog\\Handler\\FingersCrossedHandler->handle(Array)\n
#4 /projectPath/app/cache/prod/classes.php(5166): Monolog\\Logger->addRecord(500, 'Uncaught PHP Ex...', Array)\n
#5 /projectPath/app/cache/prod/classes.php on line 4787
4

1 回答 1

1

2nd line in trace is telling you what's wrong.

[Fri Sep 06 12:09:24 2013] [error] [client 217.112.169.14] PHP Fatal error:  Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/anotherPath/app/logs/prod.log" could not be opened: failed to open stream: No such file or directory' in /projectPath/app/cache/prod/classes.php:4787\nStack trace:\n

And for jenkins it's much better to use phing or ant. Check out http://jenkins-php.org/ for handy setup.

Just as an idea. I guess your bash script is not being executed in a proper working directory. You can check this just ls -lah app/logs/prod.log

If you have paths other than on server where you invoke cache:clear then you will have wrong path in cache/prod/classes.php. You need to make same path for all servers that use rsync.

于 2013-09-06T11:49:05.070 回答