繁体   English   中英

在Vhost Ubuntu子域文件夹上安装/配置Symfony3.2->禁止错误403和错误500

[英]Installing/configurate Symfony3.2 on a Vhost Ubuntu subdomain folder --> Error 403 Forbidden and Error 500

我尝试在我的虚拟主机上安装Symfony3.2,并在ubuntu下运行Plesk。 我的目标是创建一个生产服务器状态来在线测试我的Symfony项目。 我想使用URL subexample.example.tldsubexample.example.tld/matchGen进入此项目。

在经历眼泪和永恒的自我怀疑的洞穴的过程中,我看到了许多不同的错误,甚至可以分解整个虚拟主机,包括我的电子邮件系统……非常棒。

好吧..现在我得到了403 Forbidden错误。 好消息(至少对我来说是):我看到了symfony的收藏夹,如果我尝试打开app_dev.php( subexample.example.tld/matchGen/web/app_dev.php ),它将说You are not allowed to access this file. Check app_dev.php for more information. You are not allowed to access this file. Check app_dev.php for more information. 使用subexample.example.tld/matchGen/web/app.php打开subexample.example.tld/matchGen/web/app.php导致重定向到subexample.example.tld/matchGen/web/The server returned a "500 Internal Server Error". subexample.example.tld遇到“禁止”。

我已经尝试过/做了以下事情:

现在查看error.logs:

/var/www/vhosts/system/subexample.example.tld/logs/error_logs

[Mon Apr 10 20:41:45.361150 2017] [autoindex:error] [pid 15012] [client 87.147.219.10:5188] AH01276: Cannot serve directory /var/www/vhosts/example.tld/subexample.example.tld/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
[Mon Apr 10 20:41:47.707623 2017] [autoindex:error] [pid 15012] [client 87.147.219.10:5188] AH01276: Cannot serve directory /var/www/vhosts/example.tld/subexample.example.tld/matchGen/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive

/var/log/apache2/matchGen_error.log/var/log/apache2/matchGen_access.log为空。

我的配置文件:

/etc/apache2/sites-available/subexample.example.tld.conf

<VirtualHost *:80>
    ServerName subexample.example.tld
    ServerAlias www.subexample.example.tld

    DocumentRoot /var/www/vhosts/example.tld/subexample.example.tld/matchGen/web
    <Directory  /var/www/vhosts/example.tld/subexample.example.tld/matchGen/web>
        AllowOverride None
        Require all granted
        Allow from All

        <IfModule mod_rewrite.c>
            Options -MultiViews
            RewriteEngine On
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^(.*)$ app.php [QSA,L]
            RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
        </IfModule>
    </Directory>

    # uncomment the following lines if you install assets as symlinks
    # or run into problems when compiling LESS/Sass/CoffeeScript assets
    # <Directory /var/www/project>
    #     Options FollowSymlinks
    # </Directory>

    # optionally disable the RewriteEngine for the asset directories
    # which will allow apache to simply reply with a 404 when files are
    # not found instead of passing the request into the full symfony stack
    <Directory  /var/www/vhosts/example.tld/subexample.example.tld/matchGen/web/bundles>
        <IfModule mod_rewrite.c>
            RewriteEngine Off
        </IfModule>
    </Directory>
    ErrorLog /var/log/apache2/matchGen_error.log
    CustomLog /var/log/apache2/matchGen_access.log combined
</VirtualHost>

/var/www/vhosts/system/subexample.example.tld/conf/httpd.conf

#ATTENTION!
#
#DO NOT MODIFY THIS FILE BECAUSE IT WAS GENERATED AUTOMATICALLY,
#SO ALL YOUR CHANGES WILL BE LOST THE NEXT TIME THE FILE IS GENERATED.
#IF YOU REQUIRE TO APPLY CUSTOM MODIFICATIONS, PERFORM THEM IN THE FOLLOWING FILES:
#/var/www/vhosts/system/subexample.example.tld/conf/vhost.conf
#/var/www/vhosts/system/subexample.example.tld/conf/vhost_ssl.conf
<IfModule mod_ssl.c>

        <VirtualHost xx.xx.xxx.xxx:443 >
                ServerName "subexample.example.tld:443"
                ServerAlias "www.subexample.example.tld"
                ServerAlias "ipv4.subexample.example.tld"
                ServerAdmin "root@example.tld"
                UseCanonicalName Off

                DocumentRoot "/var/www/vhosts/example.tld/subexample.example.tld"
                CustomLog /var/www/vhosts/system/subexample.example.tld/logs/access_ssl_log plesklog
                ErrorLog "/var/www/vhosts/system/subexample.example.tld/logs/error_log"

                <IfModule mod_suexec.c>
                        SuexecUserGroup "xxxx" "xxxx"
                </IfModule>

                <IfModule mod_userdir.c>
                        UserDir "/var/www/vhosts/example.tld/web_users"
                </IfModule>

                <IfModule mod_sysenv.c>
                        SetSysEnv PP_VHOST_ID "6a66d04f-d22f-4a30-bb80-ca47f117886a"
                </IfModule>

                ScriptAlias "/cgi-bin/" "/var/www/vhosts/example.tld/subexample.example.tld/cgi-bin/"

                Alias "/plesk-stat" "/var/www/vhosts/system/subexample.example.tld/statistics"
                <Location  /plesk-stat/>
                        Options +Indexes
                </Location>
                <Location  /plesk-stat/logs/>
                        Require valid-user
                </Location>
                Alias /webstat /var/www/vhosts/system/subexample.example.tld/statistics/webstat
                Alias /webstat-ssl /var/www/vhosts/system/subexample.example.tld/statistics/webstat-ssl
                Alias /ftpstat /var/www/vhosts/system/subexample.example.tld/statistics/ftpstat
                Alias /anon_ftpstat /var/www/vhosts/system/subexample.example.tld/statistics/anon_ftpstat
                Alias /awstats-icon /usr/share/awstats/icon

                SSLEngine on
                SSLVerifyClient none
                SSLCertificateFile /opt/psa/var/certificates/certyKQzXqX

                SetEnv PP_CUSTOM_PHP_INI /var/www/vhosts/system/subexample.example.tld/etc/php.ini
                SetEnv PP_CUSTOM_PHP_CGI_INDEX fastcgi

                <IfModule mod_fcgid.c>
                        FcgidInitialEnv PP_CUSTOM_PHP_INI /var/www/vhosts/system/subexample.example.tld/etc/php.ini
                        FcgidInitialEnv PP_CUSTOM_PHP_CGI_INDEX fastcgi
                        FcgidMaxRequestLen 134217728
                        FcgidIOTimeout 600
                </IfModule>

                TimeOut 600
                <Directory /var/www/vhosts/example.tld/subexample.example.tld>

                        <IfModule mod_fcgid.c>
                                <Files ~ (\.fcgi$)>
                                        SetHandler fcgid-script
                                        Options +ExecCGI
                                </Files>
                        </IfModule>
                        <IfModule mod_fcgid.c>
                                <Files ~ (\.php$)>
                                        SetHandler fcgid-script
                                        FCGIWrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper .php
                                        Options +ExecCGI
                                </Files>
                        </IfModule>

                        SSLRequireSSL

                        Options -Includes +ExecCGI

                </Directory>

                <Directory /var/www/vhosts/example.tld/web_users>

                        <IfModule mod_php4.c>
                                php_admin_flag engine off
                        </IfModule>

                        <IfModule mod_php5.c>
                                php_admin_flag engine off
                        </IfModule>

                </Directory>

                <Directory /var/www/vhosts/subexample.example.tld>
                        Options +FollowSymLinks
                </Directory>

                <Directory "/var/www/vhosts/system/subexample.example.tld/statistics">
                        AuthType Basic
                        AuthName "Domainstatistiken"
                        AuthUserFile "/var/www/vhosts/system/subexample.example.tld/pd/d..httpdocs@plesk-stat"
                        require valid-user
                </Directory>

                <IfModule mod_security2.c>
                </IfModule>

        </VirtualHost>

</IfModule>

<VirtualHost xx.xx.xxx.xxx:80 >
        ServerName "subexample.example.tld:80"
        ServerAlias "www.subexample.example.tld"
        ServerAlias "ipv4.subexample.example.tld"
        ServerAdmin "root@example.tld"
        UseCanonicalName Off

        DocumentRoot "/var/www/vhosts/example.tld/subexample.example.tld"
        CustomLog /var/www/vhosts/system/subexample.example.tld/logs/access_log plesklog
        ErrorLog "/var/www/vhosts/system/subexample.example.tld/logs/error_log"

        <IfModule mod_suexec.c>
                SuexecUserGroup "xxxx" "xxxx"
        </IfModule>

        <IfModule mod_userdir.c>
                UserDir "/var/www/vhosts/example.tld/web_users"
        </IfModule>

        <IfModule mod_sysenv.c>
                SetSysEnv PP_VHOST_ID "6a66d04f-d22f-4a30-bb80-ca47f117886a"
        </IfModule>

        ScriptAlias "/cgi-bin/" "/var/www/vhosts/example.tld/subexample.example.tld/cgi-bin/"

        Redirect permanent /plesk-stat https://subexample.example.tld/plesk-stat
        Redirect permanent /webstat https://subexample.example.tld/webstat
        Redirect permanent /webstat-ssl https://subexample.example.tld/webstat-ssl
        Redirect permanent /ftpstat https://subexample.example.tld/ftpstat
        Redirect permanent /anon_ftpstat https://subexample.example.tld/anon_ftpstat
        Redirect permanent /awstats-icon https://subexample.example.tld/awstats-icon

        <IfModule mod_ssl.c>
                SSLEngine off
        </IfModule>

        SetEnv PP_CUSTOM_PHP_INI /var/www/vhosts/system/subexample.example.tld/etc/php.ini
        SetEnv PP_CUSTOM_PHP_CGI_INDEX fastcgi

        <IfModule mod_fcgid.c>
                FcgidInitialEnv PP_CUSTOM_PHP_INI /var/www/vhosts/system/subexample.example.tld/etc/php.ini
                FcgidInitialEnv PP_CUSTOM_PHP_CGI_INDEX fastcgi
                FcgidMaxRequestLen 134217728
                FcgidIOTimeout 600
        </IfModule>

        TimeOut 600
        <Directory /var/www/vhosts/example.tld/subexample.example.tld>

                <IfModule mod_fcgid.c>
                        <Files ~ (\.fcgi$)>
                                SetHandler fcgid-script
                                Options +ExecCGI
                        </Files>
                </IfModule>
                <IfModule mod_fcgid.c>
                        <Files ~ (\.php$)>
                                SetHandler fcgid-script
                                FCGIWrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper .php
                                Options +ExecCGI
                        </Files>
                </IfModule>

                Options -Includes +ExecCGI

        </Directory>

        <Directory /var/www/vhosts/example.tld/web_users>

                <IfModule mod_php4.c>
                        php_admin_flag engine off
                </IfModule>

                <IfModule mod_php5.c>
                        php_admin_flag engine off
                </IfModule>

        </Directory>

        <Directory /var/www/vhosts/subexample.example.tld>
                Options +FollowSymLinks
        </Directory>

        <Directory "/var/www/vhosts/system/subexample.example.tld/statistics">
                AuthType Basic
                AuthName "Domainstatistiken"
                AuthUserFile "/var/www/vhosts/system/subexample.example.tld/pd/d..httpdocs@plesk-stat"
                require valid-user
        </Directory>

        <IfModule mod_security2.c>
        </IfModule>
</VirtualHost>

好吧,我认为这应该使您了解我的问题。 先感谢您! 啊...请为假人解释...我知道一些事情...但显然还不够。

编辑1:

我再次尝试更改权限...这次创建了一个新组,将我的matchGen文件夹放入其中,并尝试允许该组中的所有内容。

sudo addgroup Symfony --force-badname
Allowing use of questionable username.
Adding group `Symfony' (GID 1009) ...
Done.
sudo chown root.Symfony /var/www/vhosts/example.tld/subexample.example.tld/matchGen -R
chmod g+rwx /var/www/vhosts/example.tld/subexample.example.tld/matchGen

没变。

哦..,我将用户www-data添加到了Symfony组。

编辑2:

我尝试使用http://symfony.com/doc/current/setup/web_server_configuration.html#web-server-apache-fpm ,但没有任何变化。 重置后,我尝试再次打开subexample.example.tld/matchGen/web/ 好吧,它不起作用,但是这次错误似乎是不同的HTTP ERROR 500 所以...再次查看外观-> mod_fcgid: stderr: PHP Fatal error: Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/var/www/vhosts/example.tld/subexample.example.tld/matchGen/var/logs/prod.log" could not be opened: failed to open stream: Permission denied' in /var/www/vhosts/example.tld/subexample.example.tld/matchGen/var/cache/prod/classes.php:8203

权利绝对是一个问题。 但是为什么它不起作用? ...我尝试使用此指南使用acl设置www-data-user-> http://symfony.com/doc/current/setup/file_permissions.html#using-acl-on-a-system-that-supports-setfacl-linux-bsd

在setfacl命令的末尾,没有使用var或/ var,而是将matchGen用作文件夹。

没变。

编辑3:

我做的! 我到达Edit 2之后的位置后,这对我有所帮助。 “无法打开流:权限被拒绝”错误-Laravel

  1. 进入项目文件夹并使用php bin/console cache:clear --env=prod
  2. 跟进chmod -R 777 var
  3. 完成composer dump-autoload

最后...

如果您遇到相同的问题,这是您应该检查的事情列表:

  • 在您的项目文件夹中运行php bin/symfony_requirements 您可能需要在php.ini中设置时区
  • /etc/apache2/site-available为您的子域创建并激活配置/站点,并使用a2ensite subexample.example.tld.conf 创建文件时,请确保名称以.conf结尾。
  • 在创建/更改权限之前,请在项目文件夹中使用php bin/console cache:clear --env=prod ,然后使用chmod -R 777 var将其设置为var文件夹。 使用composer dump-autoload在项目文件夹中完成它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM