# Debian安装nextcloud URL: https://chengjinfang.com/posts/2018/install-ntxtcloud/ Author: 程锦方 Date: 2018-06-21 Tags: #install Summary: 在 Debian 上部署 Nextcloud,记录数据库、防火墙和 HTTPS 配置。 ------------------------------------------------------------------------ (初步安装未做安全优化) ## 安装步骤 ```sh apt-get update apt-get upgrade apt-get vim zip sudo apt-get install apache2 mariadb-server libapache2-mod-php7.0 apt-get install php7.0-gd php7.0-json php7.0-mysql php7.0-curl php7.0-mbstring apt-get install php7.0-intl php7.0-mcrypt php-imagick php7.0-x`ml php7.0-zip ``` ```sh systemctl start apache2 systemctl enable apache2 systemctl start mysql systemctl enable mysql reboot ``` 配置MariaDB ```sh mysql_secure_installation ``` ### 设置数据库 ```sh mysql -u root -p ``` 创建名为nextclouddb的数据库 ```sql MariaDB [(none)]>CREATE DATABASE nextclouddb; ``` 创建nextcloud用户名和密码 ```sql MariaDB [(none)]>CREATE USER 'nextcloud'@'localhost' IDENTIFIED BY 'password'; ``` ```sql MariaDB [(none)]>GRANT ALL PRIVILEGES ON nextclouddb.* TO 'nextcloud'@'localhost'; ``` 重新加载MariaDB权限 ```sql MariaDB [(none)]>FLUSH PRIVILEGES; ``` 退出 ```sql MariaDB [(none)]>\q ``` ### 安装NextCloud ```sh wget https://download.nextcloud.com/server/releases/nextcloud-13.0.4.zip unzip nextcloud-13.0.4.zip mv nextcloud /var/www/html/ chown -R www-data:www-data /var/www/html/nextcloud ``` 设置配置 ```sh vi /etc/apache2/sites-available/nextcloud.conf ``` ```text Alias / "/var/www/nextcloud/" Options +FollowSymlinks AllowOverride All Dav off SetEnv HOME /var/www/nextcloud SetEnv HTTP_HOME /var/www/nextcloud ``` 链接配置 ```sh ln -s /etc/apache2/sites-available/nextcloud.conf /etc/apache2/sites-enabled/nextcloud.conf ``` 关闭默认配置 ```sh a2dissite 000-default a2ensite nextcloud ``` 其他 ```sh a2enmod rewrite a2enmod headers a2enmod env a2enmod dir a2enmod mime a2enmod setenvif ``` 重启apache2 ```sh systemctl restart apache2 ``` ### ufw使用 启用 ```sh ufw enable ``` 使用方法 ```sh ufw allow 80 ``` ### ssl ```sh a2enmod ssl a2ensite default-ssl service apache2 reload ``` ### 配置php 找到php.ini文件地址 ```sh php -i | grep "Loaded Configuration File" ``` 添加 ```ini opcache.enable=1 opcache.enable_cli=1 opcache.interned_strings_buffer=8 opcache.max_accelerated_files=10000 opcache.memory_consumption=128 opcache.save_comments=1 opcache.revalidate_freq=1 ``` ## 错误 起因 service apache2 restart ```text Job for apache2.service failed. See "systemctl status apache2.service" and "journalctl -xe" for details. ``` 解决方法 ```sh cd /etc/apache2 apache2ctl configtest ``` ------------------------------------------------------------------------ Site: https://chengjinfang.com/ · All Index: https://chengjinfang.com/all/ · RSS: https://chengjinfang.com/rss.xml