安装了个NextCloud私有云盘,装了ocdownload插件启动时遇到错误。什么错误也没说,很无奈啊。
之前用的nginx,网上说换成apache就没毛病了。
添加虚拟主机配置文件
放在conf.d目录下,取名xxx.conf,因为httpd.conf中有IncludeOptional conf.d/*.conf的作用是把此目录中文件包含进去
<VirtualHost *:80> <Directory "/var/www/html"> #针对目录,允许符号连接,允许重写 Options FollowSymLinks Allowoverride All </Directory> ServerName zerlong.com ServerAlias www.zerlong.com DocumentRoot "/var/www/html/" </VirtualHost> <VirtualHost *:80> <Directory "/var/www/nextcloud"> #针对目录,允许符号连接,允许重写 Options FollowSymLinks Allowoverride All </Directory> ServerName cloud.zerlong.com DocumentRoot "/var/www/nextcloud/" </VirtualHost>
别忘了把httpd.conf中的有冲突项注释掉,比如含有DocumentRoot “/var/www/html”、<Directory “/var/www/html”>。。。</Directory>这些和你上边的冲突就注释掉。
根目录的访问注释下边这行,或全注释掉,不注释会出现所有网站access denied
<Directory />
AllowOverride none
#Require all denied
</Directory>
访问出现php源码
原因为apache无法解析php,添加MIME类型,编辑httpd.conf文件
AddType application/x-httpd-php .php DirectoryIndex index.php index.htm index.html
启用SSL
https证书配置,编辑conf.d/ssl.conf,配置<VirtualHost _default_:443>区块
去掉DocumentRoot、ServerName的注释,换成你的网站目录与域名。
别忘了设置目录权限。不然会出现You don’t have permission to access / on this server.
例如
<VirtualHost _default_:443> # General setup for the virtual host, inherited from global configuration DocumentRoot "/var/www/html" ServerName zerlong.com:443 <Directory "/var/www/html"> #针对目录,允许符号连接,允许重写 Options FollowSymLinks Allowoverride All </Directory> # Use separate log files for the SSL virtual host; note that LogLevel # is not inherited from httpd.conf.
下边配证书文件是抄的阿里云上边的。
1. 证书文件214081901230951.pem,包含两段内容,请不要删除任何一段内容。
2. 如果是证书系统创建的CSR,还包含:证书私钥文件214081901230951.key、证书公钥文件public.pem、证书链文件chain.pem。
( 1 ) 在Apache的安装目录下创建cert目录,并且将下载的全部文件拷贝到cert目录中。如果申请证书时是自己创建的CSR文件,请将对应的私钥文件放到cert目录下并且命名为214081901230951.key;
( 2 ) 打开 apache 安装目录下 conf 目录中的 httpd.conf 文件,找到以下内容并去掉“#”:
#LoadModule ssl_module modules/mod_ssl.so (如果找不到请确认是否编译过 openssl 插件) #Include conf/extra/httpd-ssl.conf
( 3 ) 打开 apache 安装目录下 conf/extra/httpd-ssl.conf 文件 (也可能是conf.d/ssl.conf,与操作系统及安装方式有关), 在配置文件中查找以下配置语句:
# 添加 SSL 协议支持协议,去掉不安全的协议 SSLProtocol all -SSLv2 -SSLv3 # 修改加密套件如下 SSLCipherSuite HIGH:!RC4:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!EXP:+MEDIUM SSLHonorCipherOrder on # 证书公钥配置 SSLCertificateFile cert/public.pem # 证书私钥配置 SSLCertificateKeyFile cert/214081901230951.key # 证书链配置,如果该属性开头有 '#'字符,请删除掉 SSLCertificateChainFile cert/chain.pem
( 4 ) 重启 Apache。
其他
如果出现Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:443
检查httpd.conf中可能也写了Listen 443,然后ssl.conf中也写了这行就冲突了,把httpd中的去掉即可。