接着将MariaDB设为系统服务,在/usr/lib/systemd/system/下创建一个名为mysql.service的脚本,内容如下
[Unit] Description=MariaDB database server After=network.target [Service] Type=simple User=mysql Group=mysql ExecStart=/usr/local/mysql/bin/mysqld_safe TimeoutSec=300 PrivateTmp=true [Install] WantedBy=multi-user.target修改脚本权限,添加、启动服务,然后运行管理工具
chmod 755 /usr/lib/systemd/system/mysql.service systemctl daemon-reload systemctl enable mysql.service systemctl start mysql.service /usr/local/mysql/bin/mysql_secure_installationmysql_secure_installation的输入如下,牢记自己的数据库root密码
Set root password? [Y/n] Y New password: Re-enter new password: Remove anonymous users? [Y/n] Y Disallow root login remotely? [Y/n] Y Remove test database and access to it? [Y/n] Y Reload privilege tables now? [Y/n] Y登录到mysql shell为Nextcloud创建用户和数据库。
/usr/local/mysql/bin/mysql -u root -p验证root密码后,在mysql shell执行
create database nextcloud_db; create user nextclouduser@localhost identified by 'nextclouduser@'; grant all privileges on nextcloud_db.* to nextclouduser@localhost identified by 'nextclouduser@'; flush privileges; exit这样就创建了一个nextcloud_db数据库和nextclouduser用户,用户密码为’nextclouduser@’。
三、安装Nginx首先编译安装Nginx
wget https://ftp.pcre.org/pub/pcre/pcre-8.41.tar.gz tar -zxvf pcre-8.41.tar.gz wget http://www.zlib.net/zlib-1.2.11.tar.gz tar -zxvf zlib-1.2.11.tar.gz wget https://www.openssl.org/source/openssl-1.0.2l.tar.gz tar -zxvf openssl-1.0.2l.tar.gz wget http://nginx.org/download/nginx-1.13.4.tar.gz tar -zxvf nginx-1.13.4.tar.gz cd nginx-1.13.4 ./configure --with-http_ssl_module --with-pcre=../pcre-8.41 --with-zlib=../zlib-1.2.11 --with-openssl=../openssl-1.0.2l --with-http_v2_module make && make install ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/ useradd nginx mkdir /var/www chown -R nginx:nginx /var/www然后将Nignx设为系统服务,在/usr/lib/systemd/system/下创建一个名为nginx.service的脚本,内容如下
[Unit] Description=nginx - high performance web server After=network.target remote-fs.target nss-lookup.target [Service] Type=forking PIDFile=/usr/local/nginx/logs/nginx.pid ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf ExecReload=/usr/local/nginx/sbin/nginx -s reload ExecStop=/usr/local/nginx/sbin/nginx -s stop [Install] WantedBy=multi-user.target修改脚本权限,开启Nginx服务
chmod 755 /usr/lib/systemd/system/nginx.service systemctl daemon-reload systemctl enable nginx.service systemctl start nginx.service使用nginx -s reload可以重载配置而不需要重启nginx
开放防火墙HTTP、HTTPS端口
firewall-cmd --permanent --add-service=http firewall-cmd --permanent --add-service=https systemctl restart firewalld 四、安装PHP