centos7部署nextcloud

关闭selinux

sudo sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config && \
sudo setenforce 0

更新系统

sudo yum update && sudo yum install wget vim -y

安装remi repos

sudo yum install  https://mirrors.tuna.tsinghua.edu.cn/remi/enterprise/remi-release-7.rpm 
sudo yum-config-manager --enable remi-php72

#安装阿里云epel(安装remi的时候会自动安装epel,使用阿里云覆盖epel安装源是为了速度)
sudo mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.bak
sudo wget -O /etc/yum.repos.d/epel.repo  http://mirrors.aliyun.com/repo/epel-7.repo 

添加MariaDB repository

sudo sh -c 'cat > /etc/yum.repo.d/mariadb.repo << EOF
[mariadb]
name = MariaDB
baseurl =  http://yum.mariadb.org/10.3/centos7-amd64 
gpgkey= https://yum.mariadb.org/RPM-GPG-KEY-MariaDB 
gpgcheck=1
EOF'

安装依赖项

sudo yum install unzip curl bash-completion policycoreutils-python mlocate bzip2 -y

安装LAMP

sudo yum install http mariadb-server mariadb-client php php-cli php-common php-curl php-gd php-mbstring php-mysqlnd php-process php-xml php-zip php-opcache php-pecl-apcu php-intl php-pecl-redis -y

配置虚拟主机

sudo cp -v /usr/share/doc/http-2.4.6/*.conf /etc/httpd/conf.d/
sudo rm /etc/httpd/conf.d/{welcome.conf,proxy-html.conf}

vi /etc/httpd/conf.d/httpd-vhosts.conf

<VirtualHost>
  DocumentRoot /var/www/html/nextcloud
  ServerName  lcoalhost

<Directory>
  Require all granted
  AllowOverride All
  Options FollowSymLinks MultiViews
</Directory>
</VirtualHost>

配置PHP

sudo sed -i 's/memory_limit = 128M/memory_limit = 512M/g' /etc/php.ini
sudo sed -i 's/;date.timezone =/date.timezone = Asia/Shanghai/g' /etc/php.ini

开启服务

sudo systemctl start httpd && sudo systemctl enable httpd
sudo systemctl enable mariadb && sudo systemctl start mariadb

初始化数据库

expect << EOF

spawn mysql_secure_installation
expect "Enter current password for root (enter for none):"
send "\r"

expect "Set root password"
send "y\r"

expect "New password:"
send "123456\r"

expect "Re-enter new password:"
send "123456\r"

expect "Remove anonymous users? "
send "\r"

expect "Disallow root login remotely?"
send "\r"

expect "Remove test database and access to it?"
send "\r"

expect "Reload privilege tables now?"
send "\r"

expect eof
EOF

创建用户及所属数据库

sudo mysql -uroot -p123456 << EOF
create database joomla_db;
create user joomla_u identified by '123456';
grant all privileges on joomla_db.* to joomla_u@'localhost' identified by '123456';
flush privileges;
quit
EOF

下载nextcloud

wget  https://download.nextcloud.com/server/releases/nextcloud-14.0.4.zip 
unzip nextcloud-*.zip 
sudo mv nextcloud /var/www/html/

cd /var/www/html/
sudo chown -R apache:apache *
sudo chmod -R 775 *

添加防火墙

sudo firewall-cmd --add-service=http --permanent && \
sudo firewall-cmd --reload

安装nextcloud

记得选择“存储&数据库”为Mariadb

使用短连接/Pretty URLs

cd /var/www/html/nextcloud

sudo vim config/config.php
  'overwrite.cli.url' => ' http://192.168.30.231/ ', #内网测试,默认没有最后的/,需要加上
  'htaccess.RewriteBase' => '/', #新添加的一行
#执行
sudo -u apache php occ maintenance:update:htaccess

[hai@hv-centos7 nextcloud]$ sudo -u apache php occ maintenance:update:htaccess
The current PHP memory limit is below the recommended value of 512MB.
Error updating .htaccess file, not enough permissions or "overwrite.cli.url" set to an invalid URL?
#overwrite.cli.url地址最后没有加"/"就会报错

[hai@hv-centos7 nextcloud]$ sudo -u apache php occ maintenance:update:htaccess
The current PHP memory limit is below the recommended value of 512MB.
.htaccess has been updated
#成功
Pretty URLs
http://192.168.30.231/s/3eiTTKxeJnLEqeC

You may also like...

发表评论

电子邮件地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据