转载来源:https://docs.nextcloud.com/server/15/admin_manual/installation/source_installation.html#example-installation-on-centos-7-server

NextCloud Installation on CentOS 7 server

In this install tutorial we will be deploying CentOS 7.5, PHP 7.2, MariaDB, Redis as memcache and Nextcloud running on Apache.

Start off by installing a CentOS 7 minimal install. This should provide a sufficient platform to run a successful Nextcloud instance.

First install some dependencies you will be needing during installation, but which will also be useful in every day use situations:

yum install -y epel-release yum-utils unzip curl wget \
bash-completion policycoreutils-python mlocate bzip2

Now make sure your system is up to date:

yum update -y

Apache:

yum install -y httpd

Create a virtualhost file and add the following content to it:

vi /etc/httpd/conf.d/nextcloud.conf<VirtualHost *:80>DocumentRoot /var/www/html/ServerName  your.server.com<Directory "/var/www/html/">Require all grantedAllowOverride AllOptions FollowSymLinks MultiViews
</Directory>
</VirtualHost>

Make sure the apache web service is enabled and started:

systemctl enable httpd.service
systemctl start httpd.service

PHP:

Next install the PHP modules needed for this install. Remember, because this is a limited basic install, we only install the neccessary modules, not all of them. If you are making a more complete install, please refer to PHP module list at the top of this page.:

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpmyum install -y php72w php72w-cli php72w-common php72w-curl php72w-gd \
php72w-mbstring php72w-mysqlnd php72w-process php72w-xml php72w-zip \
php72w-opcache php72w-pecl-apcu php72w-intl php72w-pecl-redis

Database

As mentioned, we will be using MySQL/MariaDB as our database.:

yum install -y mariadb mariadb-server

Make sure the database service is enabled to start at boot time.:

systemctl enable mariadb.service
systemctl start mariadb.service

Installing Nextcloud

Nearly there, so keep at it, you are doing great!

Now download the archive of the latest Nextcloud version:

  • Go to the Nextcloud Download Page.

  • Go to Download Nextcloud Server > Download > Archive file for server owners and download either the tar.bz2 or .zip archive.

  • This downloads a file named nextcloud-x.y.z.tar.bz2 or nextcloud-x.y.z.zip (where x.y.z is the version number).

  • Download its corresponding checksum file, e.g. nextcloud-x.y.z.tar.bz2.md5, or nextcloud-x.y.z.tar.bz2.sha256.

  • Verify the MD5 or SHA256 sum:

    md5sum -c nextcloud-x.y.z.tar.bz2.md5 < nextcloud-x.y.z.tar.bz2
    sha256sum -c nextcloud-x.y.z.tar.bz2.sha256 < nextcloud-x.y.z.tar.bz2
    md5sum  -c nextcloud-x.y.z.zip.md5 < nextcloud-x.y.z.zip
    sha256sum  -c nextcloud-x.y.z.zip.sha256 < nextcloud-x.y.z.zip
    
  • You may also verify the PGP signature:

    wget https://download.nextcloud.com/server/releases/nextcloud-x.y.z.tar.bz2.asc
    wget https://nextcloud.com/nextcloud.asc
    gpg --import nextcloud.asc
    gpg --verify nextcloud-x.y.z.tar.bz2.asc nextcloud-x.y.z.tar.bz2
    

For the sake of the walk-through, we grabbed the latest version of Nextcloud in the form a zip file, confirmed the download with the above-mentioned command, and now we will extract it:

unzip nextcloud-*.zip

Copy the content over to the root directory of your webserver. In our case, we are using apache so it will be /var/www/html/:

cp -R nextcloud/ /var/www/html/

During the install process, no data folder is created, so we will create one manually to help with the installation wizard:

mkdir /var/www/html/nextcloud/data

Make sure that apache has read and write access to the whole nextcloud folder:

chown -R apache:apache /var/www/html/nextcloud

Restart apache:

systemctl restart httpd.service

Create a firewall rule for access to apache:

firewall-cmd --zone=public --add-service=http --permanent
firewall-cmd --reload

Redis:

yum install -y redis
systemctl enable redis.service
systemctl start redis.service

SELinux

Again, there is an extensive write-up done on SELinux which can be found at SELinux configuration, so if you are using SELinux in Enforcing mode, please run the commands suggested on that page. The following commands only refers to this tutorial:

semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/data(/.*)?'
semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/config(/.*)?'
semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/apps(/.*)?'
semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/.htaccess'
semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/.user.ini'
semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/3rdparty/aws/aws-sdk-php/src/data/logs(/.*)?'restorecon -R '/var/www/html/nextcloud/'setsebool -P httpd_can_network_connect on

If you need more SELinux configs, refer to the above-mentioned URL, return to this tutorial.

Once done with with SELinux, please head over to http://your.server.com/nextcloud and follow the steps as found Installation wizard, where it will explain to you exactly how to proceed with the final part of the install, which is done as admin user through your web browser.

Note

If you use this tutorial, and you see warnings in the web browser after installation about OPcache not being enabled or configured correctly, you need to make the suggested changes in /etc/php.d/opcache.ini for the errors to disappear. These warnings will be on the Admin page, under Basic settings.

Because we used Redis as a memcache, you will need a config similar to the following example in /var/www/html/nextcloud/config/config.php which is auto-generated when you run the online installation wizard mentioned earlier.

Example config:

'memcache.distributed' => '\OC\Memcache\Redis',
'memcache.locking' => '\OC\Memcache\Redis',
'memcache.local' => '\OC\Memcache\APCu',
'redis' => array('host' => 'localhost','port' => 6379,),

Remember, this tutorial is only for a basic setup of Nextcloud on CentOS 7, with PHP 7.2. If you are going to use more features like LDAP or Single Sign On, you will need additional PHP modules as well as extra configurations. So please visit the rest of the Admin manual, Introduction, for detailed descriptions on how to get this done.

Apache Web server configuration

On Debian, Ubuntu, and their derivatives, Apache installs with a useful configuration so all you have to do is create a /etc/apache2/sites-available/nextcloud.conf file with these lines in it, replacing the Directory and other filepaths with your own filepaths:

Alias /nextcloud "/var/www/nextcloud/"<Directory /var/www/nextcloud/>Options +FollowSymlinksAllowOverride All<IfModule mod_dav.c>Dav off</IfModule>SetEnv HOME /var/www/nextcloudSetEnv HTTP_HOME /var/www/nextcloud</Directory>

Then enable the newly created site:

a2ensite nextcloud.conf

Additional Apache configurations

  • For Nextcloud to work correctly, we need the module mod_rewrite. Enable it by running:

    a2enmod rewrite
    

    Additional recommended modules are mod_headersmod_envmod_dir and mod_mime:

    a2enmod headers
    a2enmod env
    a2enmod dir
    a2enmod mime
    

    If you’re running mod_fcgi instead of the standard mod_php also enable:

    a2enmod setenvif
    
  • You must disable any server-configured authentication for Nextcloud, as it uses Basic authentication internally for DAV services. If you have turned on authentication on a parent folder (via e.g. an AuthType Basic directive), you can turn off the authentication specifically for the Nextcloud entry. Following the above example configuration file, add the following line in the <Directory> section:

    Satisfy Any
    
  • When using SSL, take special note of the ServerName. You should specify one in the server configuration, as well as in the CommonName field of the certificate. If you want your Nextcloud to be reachable via the internet, then set both of these to the domain you want to reach your Nextcloud server.

  • Now restart Apache:

    service apache2 restart
    
  • If you’re running Nextcloud in a subdirectory and want to use CalDAV or CardDAV clients make sure you have configured the correct Service discovery URLs.

Pretty URLs

Pretty URLs remove the index.php-part in all Nextcloud URLs, for example in sharing links like https://example.org/nextcloud/index.php/s/Sv1b7krAUqmF8QQ, making URLs shorter and thus prettier.

mod_env and mod_rewrite must be installed on your webserver and the .htaccess must be writable by the HTTP user. Then you can set in the config.php two variables:

'overwrite.cli.url' => 'https://example.org/nextcloud',
'htaccess.RewriteBase' => '/nextcloud',

if your setup is available on https://example.org/nextcloud or:

'overwrite.cli.url' => 'https://example.org/',
'htaccess.RewriteBase' => '/',

if it isn’t installed in a subfolder. Finally run this occ-command to update your .htaccess file:

sudo -u www-data php /var/www/nextcloud/occ maintenance:update:htaccess

After each update, these changes are automatically applied to the .htaccess-file.

Enabling SSL

Note

You can use Nextcloud over plain HTTP, but we strongly encourage you to use SSL/TLS to encrypt all of your server traffic, and to protect user’s logins and data in transit.

Apache installed under Ubuntu comes already set-up with a simple self-signed certificate. All you have to do is to enable the ssl module and the default site. Open a terminal and run:

a2enmod ssl
a2ensite default-ssl
service apache2 reload

Note

Self-signed certificates have their drawbacks - especially when you plan to make your Nextcloud server publicly accessible. You might want to consider getting a certificate signed by a commercial signing authority. Check with your domain name registrar or hosting service for good deals on commercial certificates.

Installation wizard

After restarting Apache you must complete your installation by running either the graphical Installation Wizard, or on the command line with the occ command. To enable this, change the ownership on your Nextcloud directories to your HTTP user:

chown -R www-data:www-data /var/www/nextcloud/

Note

Admins of SELinux-enabled distributions may need to write new SELinux rules to complete their Nextcloud installation; see SELinux configuration tips.

To use occ see Installing from command line.

To use the graphical Installation Wizard see Installation wizard.

SELinux configuration tips

See SELinux configuration for a suggested configuration for SELinux-enabled distributions such as Fedora and CentOS.

php.ini configuration notes

Keep in mind that changes to php.ini may have to be configured on more than one ini file. This can be the case, for example, for the date.timezone setting.

php.ini - used by the Web server:

  /etc/php5/apache2/php.ini
or/etc/php5/fpm/php.ini
or ...

php.ini - used by the php-cli and so by Nextcloud CRON jobs:

/etc/php5/cli/php.ini

php-fpm configuration notes

System environment variables

When you are using php-fpm, system environment variables like PATH, TMP or others are not automatically populated in the same way as when using php-cli. A PHP call like getenv('PATH');can therefore return an empty result. So you may need to manually configure environment variables in the appropropriate php-fpm ini/config file.

Here are some example root paths for these ini/config files:

Ubuntu/Mint CentOS/Red Hat/Fedora
/etc/php5/fpm/ or /etc/php/7.0/fpm/ /etc/php-fpm.d/

In both examples, the ini/config file is called www.conf, and depending on the distro version or customizations you have made, it may be in a subdirectory such as pool.d.

Usually, you will find some or all of the environment variables already in the file, but commented out like this:

;env[HOSTNAME] = $HOSTNAME
;env[PATH] = /usr/local/bin:/usr/bin:/bin
;env[TMP] = /tmp
;env[TMPDIR] = /tmp
;env[TEMP] = /tmp

Uncomment the appropriate existing entries. Then run printenv PATH to confirm your paths, for example:

$ printenv PATH
/home/user/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:
/sbin:/bin:/

If any of your system environment variables are not present in the file then you must add them.

Alternatively it is possible to use the environemt variables of your system by modifying

/etc/php/7.0/fpm/pool.d/www.conf

and uncommenting the line

clear_env = no

When you are using shared hosting or a control panel to manage your Nextcloud VM or server, the configuration files are almost certain to be located somewhere else, for security and flexibility reasons, so check your documentation for the correct locations.

Please keep in mind that it is possible to create different settings for php-cli and php-fpm, and for different domains and Web sites. The best way to check your settings is with PHP version and information.

Maximum upload size

If you want to increase the maximum upload size, you will also have to modify your php-fpmconfiguration and increase the upload_max_filesize and post_max_size values. You will need to restart php5-fpm and your HTTP server in order for these changes to be applied.

.htaccess notes for Apache

Nextcloud comes with its own nextcloud/.htaccess file. Because php-fpm can’t read PHP settings in .htaccess these settings and permissions must be set in the nextcloud/.user.ini file.

NextCloud Installation on CentOS 7 server相关推荐

  1. centos directory server

    centos directory server http://www.aliyun.com/zixun/content/3_12_517262.html CentOS系统安装Directory Ser ...

  2. Eclipse+Maven+Nexus+Tomcat远程搭建CentOS web server

    Eclipse+Maven+Nexus+Tomcat远程搭建CentOS web server 工具的使用,参考了很多前辈的资料,虽然不是转载但也算不上原创,仅供自己和大家参考罢了. 笔者的本意是要在 ...

  3. 实现CentOS/Ubuntu server上任务栏固定到桌面下方 - 收藏夹一直显示 - 任务栏在哪里 - 任务栏怎么弹出

    效果图 CentOS Stream 9 固定任务栏到屏幕下方 实现步骤 点击屏幕左上角"活动",开启火狐浏览器 打开 https://extensions.gnome.org/ex ...

  4. Installation Oracle11gR2 RAC on SuSE Linux Enterprise Server 11

    SLES11安装参考我的博文 Installation SUSE Linux Enterprise Server 11 vzwc1:~ # cat /etc/issueWelcome to SUSE ...

  5. CentOS7部署nextcloud最新版本

    Nextcloud 是一个免费专业的私有云存储网盘「开源」项目,Nextcloud开发人员来自owncloud.Nextcloud 跨平台支持 Windows.Mac.Android.iOS.Linu ...

  6. 【系列5】使用Dockerfile创建带weblogic的Centos Docker镜像

    Weblogic是一个基于Java EE架构的中间件(应用服务器),WebLogic由Oracle公司维护. WebLogic是用于开发.集成.部署和管理大型分布式Web应用.网络应用和数据库应用的J ...

  7. 制作openstack Centos镜像 -- Example: CentOS image

    2019独角兽企业重金招聘Python工程师标准>>> Example: CentOS image This example shows you how to install a C ...

  8. linux下装sqlserver安装包,【sqlServer】CentOS7.x 上Microsoft SQL Server for Linux安装和配置...

    SQL Server Documentation https://docs.microsoft.com/en-us/sql/sql-server/sql-server-technical-docume ...

  9. How to Install Snapd and Snap applications on CentOS 7

    转载来源:https://computingforgeeks.com/install-snapd-snap-applications-centos-7/ How to Install Snapd an ...

最新文章

  1. 构建之法第5词作业(12-15章)
  2. Linux下的字符处理命令之tr命令详解
  3. 今日头条Web HTTP请求的白名单
  4. ASP.NET MVC使用Oauth2.0实现身份验证
  5. java数组 0912
  6. 利用Kubernetes名称空间来管理内存和CPU资源(三)
  7. [转]DES加密 java与.net可以相互加密解密两种方法
  8. 老用户们,苹果没有忘了你们!
  9. 将 Exchange 2003 移动到新计算机并保持相同的服务器名
  10. day 03 剑指 Offer 10- I. 斐波那契数列-动态规划
  11. 微信小程序登录界面的实现
  12. html实体注册商标,html 注册商标,html 注册商标代码
  13. RFC5869翻译 HMAC-based Extract-and-Expand Key Derivation Function (HKDF)
  14. 4个单词,谷歌返回16个SQL注入漏洞
  15. 计算机系统基础崔丽群答案,2017届部分优秀教师风采展示——崔丽群
  16. 如何迁移GitGitolite服务器
  17. 关于支付宝申请APP支付和网页支付在申请时需要的材料
  18. PostgreSQL 14和SCRAM认证的改变--应该迁移到SCRAM?
  19. physical examination
  20. MySQL Study之--Mysql数据库备份工具(mysqldump)

热门文章

  1. 淘宝客API网站在这两年里经历了不少次百度K站风波
  2. 超时时间已到,但是尚未从池中获取连接。出现这种情况可能是因为所有池连接均在使用,并且达到了最大池大[转]...
  3. 虚拟空间,域名解析,A记录,MX记录,CNAME记录,TTL 等 更多Web服务器相关名词解释
  4. Intro.js轻松搞定页面引导流程
  5. UITabBarController 标签栏控制器-IOS开发 (实例)
  6. Python实例讲解 -- wxpython 基本的控件 (按钮)
  7. git pull 提示错误,Your local changes to the following files would be overwritten by merge
  8. DIRECTORY_SEPARATOR
  9. Pycharm设置utf-8自动显示
  10. Shell——传递参数