owncloud 位于 arch + nginx + uwsgi 的子目录中

owncloud 位于 arch + nginx + uwsgi 的子目录中

在我的 Arch Linux 服务器进行过几次系统更新后,它所托管的 o​​wncloud web 界面停止工作。不幸的是,我最近才注意到这个问题,而且我无法真正恢复到正常工作的系统,因为我不知道它什么时候坏了。

因此我尝试修复配置,疯狂地进行谷歌搜索,但似乎找不到这里的问题所在。

无论我怎么尝试,我总是会回到这个错误:

1 月 23 日 18:17:45 spiky nginx[26523]:2015/01/23 18:17:45 [错误] 26525#0:*231 open()“/srv/http/owncloud/index.php/core/js/oc.js”失败(20:不是目录),客户端:192.168.22.153,服务器:localhost,请求:“GET /owncloud/index.php/core/js/oc.js?v=7d8216c61f4b90cea6296accb4f9f414&_=1422033462089 HTTP/1.1”,主机:“spiky”,引荐来源:“https://spiky/owncloud/index.php/apps/files/

我可以登录,但“文件”应用程序保持为空,所有 ajax 控件均不起作用(菜单、按钮)。

这是我的 nginx.conf:

worker_processes  1;

events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       80;
        server_name  localhost;

        include conf/httpx_common_body.conf;
    }

    # HTTPS server
    #
    server {
        listen       443 ssl;
        server_name  localhost;

        ssl_certificate      ssl/cert.crt;
        ssl_certificate_key  ssl/cert.key;

        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;

        include conf/httpx_common_body.conf;
    }

}

这是我的conf/httpx_common_body.conf:

index index.html index.php;
root /srv/http;

# This is to avoid Request Entity Too Large error
client_max_body_size 15G;

# This block will catch static file requests, such as images, css, js
# The : prefix is a "non-capturing" mark, meaning we do not require
# the pattern to be captured into $1 which should help improve performance
location ~* \.(:ico|css|js|gif|jpeg|png)$ {
    # Some basic cache-control for static files to be sent to the browser
    expires max;
    add_header Pragma public;
    add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}

# Deny access to .htaccess and other hidden files, if Apache's document root
# concurs with nginx's one
location ~ /\. {
    deny  all;
    log_not_found off;
    access_log off;
}

location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
}


# Entry point for the owncloud application
location ~ ^/owncloud/ {

    try_files $uri $uri/ index.php;
    index index.php;

    rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect;
    rewrite ^/carddav(.*)$ /remote.php/carddav$1 redirect;
    rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect;

    # Deny access to some special files
    location ~ ^/(data|config|\.ht|db_structure\.xml|README) {
        deny all;
    }

    # Pass all .php or .php/path urls to uWSGI
    location ~ ^(.+\.php)(.*)$ {
        include uwsgi_params;
        uwsgi_modifier1 14;
        uwsgi_pass unix:///run/uwsgi/owncloud.socket;
    }

    # everything else goes to the filesystem,
    # but / will be mapped to index.php and run through uwsgi
    location ~ .* {
        index index.php;
        rewrite ^/.well-known/carddav /remote.php/carddav/ redirect;
        rewrite ^/.well-known/caldav /remote.php/caldav/ redirect;
    }
}

# Redirect server error pages to the static page /50x.html
error_page   404 /50x.html;
error_page   500 502 503 504  /50x.html;

location = /50x.html {
    root   /usr/share/nginx/html;
}

# Everything else goes to the filesystem,
location / {
    root /srv/http;
    index index.html index.htm index.php;
}

我的owncloud.ini(由uwsgi服务使用):

[uwsgi]
master = true
socket = /run/uwsgi/owncloud.socket

# Change this to where you want ownlcoud data to be stored (maybe /home/owncloud)
owncloud_data_dir = /srv/data/owncloud
chdir             = %(owncloud_data_dir)

plugins = php
php-docroot     = /srv/http
php-index       = index.php

# Exta settings
uid = http
gid = http
procname-master = uwsgi owncloud


# only allow these php files, I don't want to inadvertently run something else
php-allowed-ext = index.php
php-allowed-ext = public.php
php-allowed-ext = remote.php
php-allowed-ext = cron.php
php-allowed-ext = status.php
php-allowed-ext = settings/apps.php
php-allowed-ext = core/ajax/update.php
php-allowed-ext = core/ajax/share.php
php-allowed-ext = core/ajax/requesttoken.php
php-allowed-ext = core/ajax/translations.php
php-allowed-ext = search/ajax/search.php
php-allowed-ext = search/templates/part.results.php
php-allowed-ext = settings/admin.php
php-allowed-ext = settings/users.php
php-allowed-ext = settings/personal.php
php-allowed-ext = settings/help.php
php-allowed-ext = settings/ajax/getlog.php
php-allowed-ext = settings/ajax/setlanguage.php
php-allowed-ext = settings/ajax/setquota.php
php-allowed-ext = settings/ajax/userlist.php
php-allowed-ext = settings/ajax/createuser.php
php-allowed-ext = settings/ajax/removeuser.php
php-allowed-ext = settings/ajax/enableapp.php
php-allowed-ext = core/ajax/appconfig.php
php-allowed-ext = settings/ajax/setloglevel.php
php-allowed-ext = ocs/v1.php

# set php configuration for this instance of php, no need to edit global php.ini
php-set = date.timezone=Etc/UTC
#php-set = open_basedir= -- not used 
php-set = session.save_path=/tmp/php_sess
php-set = post_max_size=15G
php-set = upload_max_filesize=15G

# load all extensions only in this instance of php, no need to edit global php.ini
php-set = extension=bz2.so
php-set = extension=curl.so
php-set = extension=intl.so
php-set = extension=openssl.so
php-set = extension=pdo_sqlite.so
php-set = extension=exif.so
php-set = extension=gd.so
php-set = extension=imagick.so
php-set = extension=gmp.so
php-set = extension=iconv.so
php-set = extension=mcrypt.so
php-set = extension=sockets.so
php-set = extension=sqlite3.so
php-set = extension=xmlrpc.so
php-set = extension=xsl.so
php-set = extension=zip.so
php-set = extension=mysql.so

processes = 10
cheaper = 2
cron = -3 -1 -1 -1 -1 /usr/bin/php -f %(php-docroot)/owncloud/cron.php 1>/dev/null

最后是我的 owncloud config.php:

<?php

/**
 * Only enable this for local development and not in production environments
 * This will disable the minifier and outputs some additional debug informations
 */
define('DEBUG', false);

$CONFIG = array(

/**
 * This is a unique identifier for your ownCloud installation, created
 * automatically by the installer. This example is for documentation only,
 * and you should never use it because it will not work. A valid ``instanceid``
 * is created when you install ownCloud.
 *
 * 'instanceid' => 'd3c944a9a',
 */
'instanceid' => 'ocff347a58c2',

 /**
 * The salt used to hash all passwords, auto-generated by the ownCloud
 * installer. (There are also per-user salts.) If you lose this salt you lose
 * all your passwords. This example is for documentation only,
 * and you should never use it.
 *
 *'passwordsalt' => 'd3c944a9af095aa08f',
 */
'passwordsalt' => 'ad434175f3a829785fd67784672082',

/**
 * Your list of trusted domains that users can log into. Specifying trusted
 * domains prevents host header poisoning. Do not remove this, as it performs
 * necessary security checks.
 */
'trusted_domains' =>
  array (
  ),

/**
 * Where user files are stored; this defaults to ``data/`` in the ownCloud
 * directory. The SQLite database is also stored here, when you use SQLite. (SQLite is 
 * available only in ownCloud Community Edition)
 */
'datadirectory' => '/var/www/owncloud/data',

/**
 * The current version number of your ownCloud installation. This is set up
 * during installation and update, so you shouldn't need to change it.
 */
'version' => '7.0.4.2',

/**
 * Identifies the database used with this installation. See also config option
 * ``supportedDatabases``
 *
 * Available:
 *  - sqlite (SQLite3 - Community Edition Only)
 *  - mysql (MySQL)
 *  - pgsql (PostgreSQL)
 *  - oci (Oracle - Enterprise Edition Only)
 *  - mssql (Microsoft SQL Server - Enterprise Edition Only)
 */
'dbtype' => 'mysql',

/**
 * Your host server name, for example ``localhost``, ``hostname``,
 * ``hostname.example.com``, or the IP address. To specify a port use
 * ``hostname:####``; to specify a Unix socket use
 * ``localhost:/path/to/socket``.
 */
'dbhost' => 'localhost',

/**
 * The name of the ownCloud database, which is set during installation. You
 * should not need to change this.
 */
'dbname' => 'owncloud',

/**
 * The user that ownCloud uses to write to the database. This must be unique
 * across ownCloud instances using the same SQL database. This is set up during
 * installation, so you shouldn't need to change it.
 */
'dbuser' => 'owncloud_user',

/**
 * The password for the database user. This is set up during installation, so
 * you shouldn't need to change it.
 */
'dbpassword' => '---removed---',

/**
 * Prefix for the ownCloud tables in the database.
 */
'dbtableprefix' => 'oc_',

/**
 * Additional driver options for the database connection, eg. to enable SSL
 * encryption in MySQL.
 */
/*
'dbdriveroptions' => array(
    PDO::MYSQL_ATTR_SSL_CA => '/file/path/to/ca_cert.pem',
),
*/

/**
 * Indicates whether the ownCloud instance was installed successfully; ``true``
 * indicates a successful installation, and ``false`` indicates an unsuccessful
 * installation.
 */
'installed' => true,


/**
 * User Experience
 *
 * These optional parameters control some aspects of the user interface. Default
 * values, where present, are shown.
 */

/**
 * This sets the default language on your ownCloud server, using ISO_639-1
 * language codes such as ``en`` for English, ``de`` for German, and ``fr`` for
 * French. It overrides automatic language detection on public pages like login
 * or shared items. User's language preferences configured under "personal ->
 * language" override this setting after they have logged in.
 */
'default_language' => 'en',

/**
 * Set the default app to open on login. Use the app names as they appear in the
 * URL after clicking them in the Apps menu, such as documents, calendar, and
 * gallery. You can use a comma-separated list of app names, so if the first
 * app is not enabled for a user then ownCloud will try the second one, and so
 * on. If no enabled apps are found it defaults to the Files app.
 */
'defaultapp' => 'files',

/**
 * ``true`` enables the Help menu item in the user menu (top right of the
 * ownCloud Web interface). ``false`` removes the Help item.
 */
'knowledgebaseenabled' => true,

/**
 * ``true`` enables avatars, or user profile photos. These appear on the User
 * page, on user's Personal pages and are used by some apps (contacts, mail,
 * etc). ``false`` disables them.
 */
'enable_avatars' => true,

/**
 * ``true`` allows users to change their display names (on their Personal
 * pages), and ``false`` prevents them from changing their display names.
 */
'allow_user_to_change_display_name' => true,

/**
 * Lifetime of the remember login cookie, which is set when the user clicks the
 * ``remember`` checkbox on the login screen. The default is 15 days, expressed
 * in seconds.
 */
'remember_login_cookie_lifetime' => 60*60*24*15,

/**
 * The lifetime of a session after inactivity; the default is 24 hours,
 * expressed in seconds.
 */
'session_lifetime' => 60 * 60 * 24,

/**
 * Enable or disable session keep-alive when a user is logged in to the Web UI.
 * Enabling this sends a "heartbeat" to the server to keep it from timing out.
 */
'session_keepalive' => true,

/**
 * The directory where the skeleton files are located. These files will be
 * copied to the data directory of new users. Leave empty to not copy any
 * skeleton files.
 */
'skeletondirectory' => '',

/**
 * The ``user_backends`` app allows you to configure alternate authentication
 * backends. Supported backends are IMAP (OC_User_IMAP), SMB (OC_User_SMB), and
 * FTP (OC_User_FTP).
 */
/*
'user_backends' => array(
    array(
        'class' => 'OC_User_IMAP',
        'arguments' => array('{imap.gmail.com:993/imap/ssl}INBOX')
    )
),
*/

/**
 * Deleted Items (trash bin)
 *
 * These parameters control the Deleted files app.
 */

/**
 * When the trash bin app is enabled (default), this is the number of days a
 * file will be kept in the trash bin. Default is 30 days.
 */
'trashbin_retention_obligation' => 30,

/**
 * Disable or enable auto-expiration for the trash bin. By default
 * auto-expiration is enabled.
 */
'trashbin_auto_expire' => true,


/**
 * ownCloud Verifications
 *
 * ownCloud performs several verification checks. There are two options,
 * ``true`` and ``false``.
 */

/**
 * Check 3rd party apps to make sure they are using the private API and not the
 * public API. If the app uses the private API it cannot be installed.
 */
'appcodechecker' => true,

/**
 * Check if ownCloud is up-to-date and shows a notification if a new version is
 * available.
 */
'updatechecker' => true,

/**
 * Is ownCloud connected to the Internet or running in a closed network?
 */
'has_internet_connection' => true,

/**
 * Allows ownCloud to verify a working WebDAV connection. This is done by
 * attempting to make a WebDAV request from PHP.
 */
'check_for_working_webdav' => true,

/**
 * This is a crucial security check on Apache servers that should always be set
 * to ``true``. This verifies that the ``.htaccess`` file is writable and works.
 * If it is not, then any options controlled by ``.htaccess``, such as large
 * file uploads, will not work. It also runs checks on the ``data/`` directory,
 * which verifies that it can't be accessed directly through the web server.
 */
'check_for_working_htaccess' => true,

/**
 * In certain environments it is desired to have a read-only config file.
 * When this switch is set to ``true`` ownCloud will not verify whether the
 * configuration is writable. However, it will not be possible to configure
 * all options via the web-interface. Furthermore, when updating ownCloud
 * it is required to make the config file writable again for the update
 * process.
 */
'config_is_read_only' => false,

/**
 * Logging
 */

/**
 * By default the ownCloud logs are sent to the ``owncloud.log`` file in the
 * default ownCloud data directory. If syslogging is desired, set this parameter
 * to ``syslog``.
 */
'log_type' => 'syslog',

/**
 * Change the ownCloud logfile name from ``owncloud.log`` to something else.
 */
'logfile' => 'owncloud.log',

/**
 * Loglevel to start logging at. Valid values are: 0 = Debug, 1 = Info, 2 =
 * Warning, 3 = Error. The default value is Warning.
 */
'loglevel' => 0,

/**
 * This uses PHP.date formatting; see http://php.net/manual/en/function.date.php
 */
'logdateformat' => 'F d, Y H:i:s',

/**
 * The default timezone for logfiles is UTC. You may change this; see
 * http://php.net/manual/en/timezones.php
 */
'logtimezone' => 'Europe/Berlin',

/**
 * Append all database queries and parameters to the log file. Use this only for
 * debugging, as your logfile will become huge.
 */
'log_query' => false,

/**
 * Log successful cron runs.
 */
'cron_log' => true,

/**
 * Enables log rotation and limits the total size of logfiles. The default is 0,
 * or no rotation. Specify a size in bytes, for example 104857600 (100 megabytes
 * = 100 * 1024 * 1024 bytes). A new logfile is created with a new name when the
 * old logfile reaches your limit. The total size of all logfiles is double the
 * ``log_rotate_sizerotation`` value.
 */
'log_rotate_size' => false,


/**
 * Alternate Code Locations
 *
 * Some of the ownCloud code may be stored in alternate locations.
 */

/**
 * ownCloud uses some 3rd party PHP components to provide certain functionality.
 * These components are shipped as part of the software package and reside in
 * ``owncloud/3rdparty``. Use this option to configure a different location.
 */
'3rdpartyroot' => '',

/**
 * If you have an alternate ``3rdpartyroot``, you must also configure the URL as
 * seen by a Web browser.
 */
'3rdpartyurl' => '',

/**
 * This section is for configuring the download links for ownCloud clients, as
 * seen in the first-run wizard and on Personal pages.
 */
'customclient_desktop' =>
    'http://owncloud.org/sync-clients/',
'customclient_android' =>
    'https://play.google.com/store/apps/details?id=com.owncloud.android',
'customclient_ios' =>
    'https://itunes.apple.com/us/app/owncloud/id543672169?mt=8',

/**
 * Apps
 *
 * Options for the Apps folder, Apps store, and App code checker.
 */

/**
 * When enabled, admins may install apps from the ownCloud app store.
 * The app store is disabled by default for ownCloud Enterprise Edition
 */
'appstoreenabled' => true,

/**
 * The URL of the appstore to use.
 */
'appstoreurl' => 'https://api.owncloud.com/v1',

/**
 * Use the ``apps_paths`` parameter to set the location of the Apps directory,
 * which should be scanned for available apps, and where user-specific apps
 * should be installed from the Apps store. The ``path`` defines the absolute
 * file system path to the app folder. The key ``url`` defines the HTTP web path
 * to that folder, starting from the ownCloud web root. The key ``writable``
 * indicates if a web server can write files to that folder.
 */
'apps_paths' => array(
    0 =>
    array(
        'path'=> '/srv/http/owncloud/apps',
        'url' => '/apps',
        'writable' => true,
    ),
),

/**
 * @see appcodechecker
 */


/**
 * Previews
 *
 * ownCloud supports previews of image files, the covers of MP3 files, and text
 * files. These options control enabling and disabling previews, and thumbnail
 * size.
 */

/**
 * By default, ownCloud can generate previews for the following filetypes:
 *
 * - Images files
 * - Covers of MP3 files
 * - Text documents
 *
 * Valid values are ``true``, to enable previews, or
 * ``false``, to disable previews
 */
'enable_previews' => true,
/**
 * The maximum width, in pixels, of a preview. A value of ``null`` means there
 * is no limit.
 */
'preview_max_x' => null,
/**
 * The maximum height, in pixels, of a preview. A value of ``null`` means there
 * is no limit.
 */
'preview_max_y' => null,
/**
 * If a lot of small pictures are stored on the ownCloud instance and the
 * preview system generates blurry previews, you might want to consider setting
 * a maximum scale factor. By default, pictures are upscaled to 10 times the
 * original size. A value of ``1`` or ``null`` disables scaling.
 */
'preview_max_scale_factor' => 10,
/**
 * custom path for LibreOffice/OpenOffice binary
 */
'preview_libreoffice_path' => '/usr/bin/libreoffice',
/**
 * Use this if LibreOffice/OpenOffice requires additional arguments.
 */
'preview_office_cl_parameters' =>
    ' --headless --nologo --nofirststartwizard --invisible --norestore '.
    '-convert-to pdf -outdir ',

/**
 * Only register providers that have been explicitly enabled
 *
 * The following providers are enabled by default:
 *
 *  - OC\Preview\Image
 *  - OC\Preview\MarkDown
 *  - OC\Preview\MP3
 *  - OC\Preview\TXT
 *
 * The following providers are disabled by default due to performance or privacy
 * concerns:
 *
 *  - OC\Preview\Movies
 *  - OC\Preview\MSOffice2003
 *  - OC\Preview\MSOffice2007
 *  - OC\Preview\MSOfficeDoc
 *  - OC\Preview\OpenDocument
 *  - OC\Preview\PDF
 *  - OC\Preview\StarOffice
 *  - OC\Preview\SVG
 */
'enabledPreviewProviders' => array(
    'OC\Preview\Image',
    'OC\Preview\MP3',
    'OC\Preview\TXT',
    'OC\Preview\MarkDown'
),


/**
 * Maintenance
 *
 * These options are for halting user activity when you are performing server
 * maintenance.
 */

/**
 * Enable maintenance mode to disable ownCloud
 *
 * If you want to prevent users to login to ownCloud before you start doing some
 * maintenance work, you need to set the value of the maintenance parameter to
 * true. Please keep in mind that users who are already logged-in are kicked out
 * of ownCloud instantly.
 */
'maintenance' => false,

/**
 * When set to ``true``, the ownCloud instance will be unavailable for all users
 * who are not in the ``admin`` group.
 */
'singleuser' => false,


/**
 * SSL
 */

/**
 * Change this to ``true`` to require HTTPS for all connections, and to reject
 * HTTP requests.
 */
'forcessl' => false,

/**
 * Extra SSL options to be used for configuration.
 */
'openssl' => array(
    'config' => '/absolute/location/of/openssl.cnf',
),


/**
 * Miscellaneous
 */

/**
 * Blacklist a specific file or files and disallow the upload of files
 * with this name. ``.htaccess`` is blocked by default.
 * WARNING: USE THIS ONLY IF YOU KNOW WHAT YOU ARE DOING.
 */
'blacklisted_files' => array('.htaccess'),

/**
 * Define a default folder for shared files and folders other than root.
 */
'share_folder' => '/',

/**
 * If you are applying a theme to ownCloud, enter the name of the theme here.
 * The default location for themes is ``owncloud/themes/``.
 */
'theme' => '',

/**
 * X-Frame-Restriction is a header which prevents browsers from showing the site
 * inside an iframe. This is be used to prevent clickjacking. It is risky to
 * disable this, so leave it set at ``true``.
 */
'xframe_restriction' => true,

/**
 * The default cipher for encrypting files. Currently AES-128-CFB and
 * AES-256-CFB are supported.
 */
'cipher' => 'AES-256-CFB',

/**
 * Server details for one or more memcached servers to use for memory caching.
 * Memcache is only used if other memory cache options (xcache, apc, apcu) are
 * not available.
 */
'memcached_servers' => array(
    // hostname, port and optional weight. Also see:
    // http://www.php.net/manual/en/memcached.addservers.php
    // http://www.php.net/manual/en/memcached.addserver.php
    array('localhost', 11211),
    //array('other.host.local', 11211),
),

/**
 * Location of the cache folder, defaults to ``data/$user/cache`` where
 * ``$user`` is the current user. When specified, the format will change to
 * ``$cache_path/$user`` where ``$cache_path`` is the configured cache directory
 * and ``$user`` is the user.
 */
'cache_path' => '',

/**
 * EXPERIMENTAL: option whether to include external storage in quota
 * calculation, defaults to false.
 */
'quota_include_external_storage' => false,

/**
 * Specifies how often the filesystem is checked for changes made outside
 * ownCloud.
 *
 * 0 -> Never check the filesystem for outside changes, provides a performance
 * increase when it's certain that no changes are made directly to the
 * filesystem
 *
 * 1 -> Check each file or folder at most once per request, recommended for
 * general use if outside changes might happen.
 *
 * 2 -> Check every time the filesystem is used, causes a performance hit when
 * using external storages, not recommended for regular use.
 */
'filesystem_check_changes' => 1,

/**
 * All css and js files will be served by the web server statically in one js
 * file and one css file if this is set to ``true``.
 */
'asset-pipeline.enabled' => false,

/**
 * Where ``mount.json`` file should be stored, defaults to ``data/mount.json``
 */
'mount_file' => 'data/mount.json',

/**
 * When ``true``, prevent ownCloud from changing the cache due to changes in the
 * filesystem for all storage.
 */
'filesystem_cache_readonly' => false,


  'secret' => '--removed--',
);

我知道应该生成 core/js/oc.js 但对我来说似乎并非如此......

我做错了什么?

答案1

问题解决了。

这个问题 100% 是我的错:我曾经使用过 apache,但是我对 nginx 完全不熟悉,我复制了在 Google 上找到的几行代码,而没有过多考虑它们的含义。

问题出在我的conf/httpx_common_body.conf上。规则

location ~* \.(:ico|css|js|gif|jpeg|png)$ {
    # Some basic cache-control for static files to be sent to the browser
    expires max;
    add_header Pragma public;
    add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}

缓存 js 文件。不好。只需从过滤器中删除“js”即可解决我的问题。

location ~* \.(:ico|css|gif|jpeg|png)$ {
    # Some basic cache-control for static files to be sent to the browser
    expires max;
    add_header Pragma public;
    add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}

干杯。

相关内容