安装后Apache不会为Cockpit CMS提供服务(404错误)

时间:2017-10-11 20:15:29

标签: php apache ubuntu

我正在尝试让Cockpit CMS(https://getcockpit.com/documentation)在Ubuntu 16.04服务器上运行。文档是有限的。我已将cockpit文件夹放在/var/www/html/root/cms的Apache Document根目录中。

website.com/cms/install找到的安装页面有效。此页面现在重定向到无法找到的website.com/cms/auth/login(404错误)。 website.com/cms也会重定向到/cms/auth/login

目录/var/www/html/root/cms/auth/login不存在(与本地相同)。一切都在使用MAMP的本地环境中工作,使用相同的目录结构。

Apache日志有以下错误,但我认为它不相关:

server certificate does NOT include an ID which matches the server name

我尝试过配置Apache并为/cms/提供指向该目录的Alias。我还更改了/var/www/html/root/cms/目录的权限,以便所有文件都可读。

我尝试将DocumentRoot更改为/var/www/html2/。在此目录中只有cms文件夹。这没有什么区别,在请求website.com/cms/auth/login

时,它仍然会出现错误

我不认为这是一个依赖性问题。 Php版本是7.0。已安装PDO + SQLite。 php7.0-gd已安装。 mod_rewrite也已启用。

这是我启用网站的配置文件:

<VirtualHost *:80>
    Redirect / https://website.com/
</VirtualHost>
<VirtualHost *:443>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    #ServerName www.example.com

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/root
    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info  SSLCertificateChainFile /usr/local/ssl/crt/intermediate.crt
    SSLEngine on
        SSLCertificateFile /usr/local/ssl/crt/public.crt
        SSLCertificateKeyFile /usr/local/ssl/crt/website.key
        SSLCertificateChainFile /usr/local/ssl/crt/intermediate.crt
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf

    Alias /alternate/ "/var/www/html/alternate/"
    <Directory "/var/www/html/alternate/">
    </Directory>
    Alias /root/ "/var/www/html/root/"
        <Directory "/var/www/html/root/">
    </Directory>
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

2 个答案:

答案 0 :(得分:1)

install/index.php确实存在于磁盘上,因此只要Apache和PHP正常工作,您就可以在没有任何特殊服务器配置的情况下访问该文件。那就是你如何到达那里的。

但是,安装完成后,Cockpit会依赖.htaccess中指定的重定向规则,将auth/login之类的网址(其中)存储在磁盘上用于处理的真实文件。如果失败,则表示重写规则不起作用,您需要进行设置。

首先,确保已启用mod_rewrite。在Ubuntu上你应该能够这样做:

sudo a2enmod rewrite

接下来,您需要确保已启用.htaccess文件处理 - 如果不是,则{NULL}只会忽略.htaccess个文件(如Cockpit目录中的文件)。将以下部分添加到虚拟主机配置的VirtualHost块(可能类似于/etc/apache2/sites-available/website.conf):

# The Directory should be where Cockpit's README.md is
<Directory "/var/www/html/root/cms"> 
    AllowOverride All
</Directory>

接下来,正如评论中所讨论的,删除虚拟主机配置中的Alias es和空Directory块,它们不是必需的,只是让事情混淆。这是最终的配置文件:

<VirtualHost *:80>
    Redirect / https://website.com/
</VirtualHost>

<VirtualHost *:443>
    # Add your real, fully-qualified servername
    ServerName www.example.com

    ServerAdmin webmaster@localhost

    # The Directory should be where Cockpit's README.md is
    DocumentRoot /var/www/html/root/cms

    # The Directory should be where Cockpit's README.md is
    <Directory "/var/www/html/root/cms"> 
        AllowOverride All
    </Directory>

    SSLEngine on
        SSLCertificateFile /usr/local/ssl/crt/public.crt
        SSLCertificateKeyFile /usr/local/ssl/crt/website.key
        SSLCertificateChainFile /usr/local/ssl/crt/intermediate.crt
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

重启Apache以使这些更改生效:

sudo systemctl restart apache2

答案 1 :(得分:0)

Cockpit CMS Requirements:

PHP >= 5.5
PDO + SQLite (or MongoDB)
GD extension
mod_rewrite enabled (on apache) !!IMPORTANT!!

修复它,你可以在控制台中:

sudo a2enmod rewrite
sudo service apache2 restart