草庐IT

Nextcloud去掉URL中的index.php以及强制https(Win10子系统WSL)

fengxingke 2023-05-14 原文

一、Nextcloud去掉URL中的index.php

1、启用相关模块

cd /var/www/nextcloud   #进入程序目录

sudo chmod -R 777 .htaccess  #设置.htaccess文件权限可读写

sudo a2enmod env

audo a2enmod rewrite  #启用rewrite模块

2、修改nextcloud配置文件

vim /var/www/nextcloud/config/config.php

# 在配置文件中添加以下参数
'overwrite.cli.url' => 'http://test.com:1234',
'htaccess.RewriteBase' => '/',

overwrite.cli.url后面设置为你的访问域名;

htaccess.RewriteBase后面设置为你的网站目录;(如果你的网站目录就是nextcloud,那么就是/,如果是下面的子目录,那么就是/子目录名)

3、开启apached的Rewrite模块

(1)http访问配置

vim /etc/apache2/apache2.conf
# 在配置文件中增加以下内容
<Directory /var/www/nextcloud/> 
	Require all granted 
	AllowOverride All 
	Options FollowSymLinks MultiViews
</Directory>

注意事项

​ 本人在/etc/apache2/sites-available目录下增加了针对nextcloud的配置文件“nextcloud.conf”,在其中增加上述代码,但不生效,不知是何原因,之前是搞.net开发的,apache不熟悉。
最终还是把上述代码加到apache2的根配置文件中。

<VirtualHost *:80>
	DocumentRoot /var/www/nextcloud
	ServerName 192.168.1.1

	Alias /nextcloud "/var/www/nextcloud"

	ErrorLog ${APACHE_LOG_DIR}/nextcloud.error
	CustomLog ${APACHE_LOG_DIR}/nextcloud.access combined

	<Directory /var/www/nextcloud/>
#       		Require all granted
#       		Options FollowSymlinks MultiViews
#       		AllowOverride All
#       		DirectoryIndex index.php index.htm index.html
#      
		<IfModule mod_dav.c>
			Dav off
		</IfModule>

      		SetEnv HOME /var/www/nextcloud
      		SetEnv HTTP_HOME /var/www/nextcloud
      		Satisfy Any

	</Directory>

</VirtualHost>

(2)https访问配置

 vim /etc/apache2/sites-available/default-ssl.conf

4、更新.htaccess文件

sudo -u www-data php /var/www/nextcloud/occ maintenance:update:htaccess
(1)报错

An unhandled exception has been thrown:
Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: could not find driver in /var/www/nextcloud/lib/private/DB/Connection.php:139

问题原因

安装了多个PHP,有php7.4、php8.0,未指定以哪个版本运行。

解决方法
# 解决方法:指定php版本
sudo -u www-data php8.0 occ maintenance:update:htaccess
(2)报错

An unhandled exception has been thrown:
OCP\HintException: [0]: Memcache \OC\Memcache\APCu not available for local cache (Is the matching PHP module installed and enabled?)

解决方法
# 解决方法:在php.ini文件末尾加上:apc.enable_cli=1
vim /etc/php/8.0/cli/php.ini

5、重启apache2

sudo apachectl configtest		#检查apache2配置

sudo service apache2 reload		#重新加载配置

sudo service apache2 restart	#重启apache2

6、刷新网页

刷新网页,url中已经没有index.php了。

参考博文:https://www.frank9.com/pretty-urls-for-nextcloud.html

二、http强制转https

vim /var/www/nextcloud/config/config.php

添加一下代码:
‘overwriteprotocol’ => ‘https’,

重启apache2

sudo service apache2 restart	#重启apache2

有关Nextcloud去掉URL中的index.php以及强制https(Win10子系统WSL)的更多相关文章

  1. ruby-on-rails - rails : save file from URL and save it to Amazon S3 - 2

    从给定URL下载文件并立即将其上传到AmazonS3的更直接的方法是什么(+将有关文件的一些信息保存到数据库中,例如名称、大小等)?现在,我既不使用Paperclip,也不使用Carrierwave。谢谢 最佳答案 简单明了:require'open-uri'require's3'amazon=S3::Service.new(access_key_id:'KEY',secret_access_key:'KEY')bucket=amazon.buckets.find('image_storage')url='http://www.ex

  2. ruby - 如何使用 Ruby aws/s3 Gem 生成安全 URL 以从 s3 下载文件 - 2

    我正在编写一个小脚本来定位aws存储桶中的特定文件,并创建一个临时验证的url以发送给同事。(理想情况下,这将创建类似于在控制台上右键单击存储桶中的文件并复制链接地址的结果)。我研究过回形针,它似乎不符合这个标准,但我可能只是不知道它的全部功能。我尝试了以下方法:defauthenticated_url(file_name,bucket)AWS::S3::S3Object.url_for(file_name,bucket,:secure=>true,:expires=>20*60)end产生这种类型的结果:...-1.amazonaws.com/file_path/file.zip.A

  3. ruby-on-rails - Ruby url 到 html 链接转换 - 2

    我正在使用Rails构建一个简单的聊天应用程序。当用户输入url时,我希望将其输出为html链接(即“url”)。我想知道在Ruby中是否有任何库或众所周知的方法可以做到这一点。如果没有,我有一些不错的正则表达式示例代码可以使用... 最佳答案 查看auto_linkRails提供的辅助方法。这会将所有URL和电子邮件地址变成可点击的链接(htmlanchor标记)。这是文档中的代码示例。auto_link("Gotohttp://www.rubyonrails.organdsayhellotodavid@loudthinking.

  4. ruby-on-rails - 如何生成传递一些自定义参数的 `link_to` URL? - 2

    我正在使用RubyonRails3.0.9,我想生成一个传递一些自定义参数的link_toURL。也就是说,有一个articles_path(www.my_web_site_name.com/articles)我想生成如下内容:link_to'Samplelinktitle',...#HereIshouldimplementthecode#=>'http://www.my_web_site_name.com/articles?param1=value1¶m2=value2&...我如何编写link_to语句“alàRubyonRailsWay”以实现该目的?如果我想通过传递一些

  5. ruby - Rack:如何将 URL 存储为变量? - 2

    我正在编写一个简单的静态Rack应用程序。查看下面的config.ru代码:useRack::Static,:urls=>["/elements","/img","/pages","/users","/css","/js"],:root=>"archive"map'/'dorunProc.new{|env|[200,{'Content-Type'=>'text/html','Cache-Control'=>'public,max-age=6400'},File.open('archive/splash.html',File::RDONLY)]}endmap'/pages/search.

  6. Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting - 2

    1.错误信息:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:requestcanceledwhilewaitingforconnection(Client.Timeoutexceededwhileawaitingheaders)或者:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:TLShandshaketimeout2.报错原因:docker使用的镜像网址默认为国外,下载容易超时,需要修改成国内镜像地址(首先阿里

  7. ruby-on-rails - Rails - 使用/自定义 URL : '/dashboard' 指定根路径 - 2

    如何使此根路径转到:“/dashboard”而不仅仅是http://example.com?root:to=>'dashboard#index',:constraints=>lambda{|req|!req.session[:user_id].blank?} 最佳答案 您可以通过以下方式实现:root:to=>redirect('/dashboard')match'/dashboard',:to=>"dashboard#index",:constraints=>lambda{|req|!req.session[:user_id].b

  8. ruby-on-rails - Sphinx - 何时对字段使用 'has' 和 'indexes' - 2

    我几天前在我的ruby​​onrails2.3.2上安装了Sphinx和Thinking-Sphinx,基本搜索效果很好。这意味着,没有任何条件。现在,我想用一些条件过滤搜索。我有公告模型,索引如下所示:define_indexdoindexestitle,:as=>:title,:sortable=>trueindexesdescription,:as=>:description,:sortable=>trueend也许我错了,但我注意到只有当我将:sortable=>true语法添加到这些属性时,我才能将它们用作搜索条件。否则它找不到任何东西。现在,我还在使用acts_as_tag

  9. ruby-on-rails - 使用 Dragonfly 从 URL 分配图像 - 2

    我正在使用Dragonfly在Rails3.1应用程序上处理图像。我正在努力通过url将图像分配给模型。我有一个很好的表格:{:multipart=>true}do|f|%>RemovePicture?Dragonfly的文档指出:Dragonfly提供了一个直接从url分配的访问器:@album.cover_image_url='http://some.url/file.jpg'但是当我在控制台中尝试时:=>#ruby-1.9.2-p290>picture.image_url="http://i.imgur.com/QQiMz.jpg"=>"http://i.imgur.com/QQ

  10. 由于 libgmp.10.dylib 的问题,Ruby 2.2.0 无法运行 - 2

    我刚刚安装了带有RVM的Ruby2.2.0,并尝试使用它得到了这个:$rvmuse2.2.0--defaultUsing/Users/brandon/.rvm/gems/ruby-2.2.0dyld:Librarynotloaded:/usr/local/lib/libgmp.10.dylibReferencedfrom:/Users/brandon/.rvm/rubies/ruby-2.2.0/bin/rubyReason:Incompatiblelibraryversion:rubyrequiresversion13.0.0orlater,butlibgmp.10.dylibpro

随机推荐