Centos7 安裝LAMP以及nextcloud

2022-06-08 10:09:12 字數 4579 閱讀 3576

第一步:安裝apache  

在centos中 apache叫httpd  

yum update #更新源

yum install httpd #安裝apache

systemctl stop firewalld           #關閉防火牆

systemctl start httpd              #開啟httpd服務

systemctl enable httpd.service     #開啟httpd開機自啟

systemctl status httpd.service     #檢視httpd狀態

第二步:安裝php (見下面)

systemctl start php-fpm.service #啟動

systemctl stop php-fpm.service #關閉

systemctl restart php-fpm.service #重啟

第三步:安裝mariadb (不行就用yum)

()yum install dnf

dnf update -y

install-y mariadb mariadb-server

dnf install -y mariadb mariadb-server

yum -y install mariadb-server mariadb mariadb-client mariadb-devel

啟動資料庫

systemctlenablemariadb.service

systemctlstartmariadb.service

安裝完成以後是沒有設定密碼的,執行下面的命令可以非常方便的配置

mysql_secure_installation

第四步:安裝nextcloud

wget 

)unzip nextcloud-*.zip

解壓後,拷貝專案目錄到 apache 目錄

cp -r nextcloud/ /var/www/html/

建立資料存放目錄,用於存放日誌、檔案等

mkdir /var/www/html/nextcloud/data

設定許可權並重啟

第五步:享受就行了

所有的檔案會儲存在下面的目錄,如果你想存放雲,當然也可以,不過本文就不敘述了

/var/www/html/nextcloud/data/admin/files

其他ip登入編輯/var/www/html/nextcloud/conf/config.php

<?php

$config = array (

'instanceid' => 'oc9ncnswcrlk',

'passwordsalt' => 'rpqltgss+8o5ug5fvn/2sd9owrizho',

'secret' => '8sbjxe8tytnrd2imzjcyp3jc1ch34aguc2xcj+gdzwxy5v+1',

'trusted_domains' =>

array (

0 => '192.168.237.135',

#新增如下程式碼--------------

1 => preg_match('/cli/i',php_sapi_name())?'127.0.0.1':$_server['server_name'],

'datadirectory' => '/var/www/html/nextcloud/data',

'dbtype' => 'sqlite3',

'version' => '18.0.3.0',

'overwrite.cli.url' => '',

'installed' => true,

array (

0 => 'onlyoffice',

解決centos中安裝nextcloud出現「內部伺服器錯誤」

直入正題

這個問題的出現是由於資料夾許可權設定的不到位。

如果直接簡單地去設定許可權,比如:

chown apache:apache nextcloud

chmod 770 nextcloud -rf

那麼你就會得到「內部伺服器錯誤」的提示。

正確的做法是,

1.使用下面的配置指令碼(這個指令碼大概已經是第三遍被貼出來了):

隨便找個地方(不要在nextcloud的程式目錄下),建立乙個shell指令碼:

vim permission.sh

然後把下面的內容貼上進去(在vim中,你需要先按i,然後insert+shift鍵貼上)

注:以下**可能導致系統許可權混亂!!!原因不明!!!慎用!!!(如果你發現錯誤所在請告訴我!!!)

#!/bin/bash

ocpath='/var/www/nextcloud/'   #修改為你nextcloud所放置的目錄

htuser='apache'                #網頁伺服器使用者

htgroup='apache'               #網頁伺服器的組

rootuser='root'

printf "creating possible missing directories\n"

mkdir -p $ocpath/data

mkdir -p $ocpath/assets

mkdir -p $ocpath/updater

printf "chmod files and directories\n"

find $/ -type f -print0 | xargs -0 chmod 0640

find $/ -type d -print0 | xargs -0 chmod 0750

printf "chown directories\n"

chown -r $:$ $/

chown -r $:$ $/assets/

chown -r $:$ $/config/

chown -r $:$ $/data/

chown -r $:$ $/themes/

chown -r $:$ $/updater/

chmod +x $/occ

printf "chmod/chown .htaccess\n"

if [ -f $/.htaccess ]

then

chmod 0644 $/.htaccess

chown $:$ $/.htaccess

fiif [ -f $/data/.htaccess ]

then

chmod 0644 $/data/.htaccess

chown $:$ $/data/.htaccess

fi按esc鍵切換到普通模式,然後輸入:wq儲存退出。

2.關閉或正確地配置selinux(

最直接的方式

)臨時的關閉可以用:

setenforce 0

永久關閉則可以編輯/etc/selinux/config 檔案:

vim /etc/selinux/config

找到selinux=enforcing,將它改為selinux=disabled。

再重新整理頁面,錯誤資訊就消失了:

解決過程

,關掉防火牆、selinux,然後瀏覽器裡訪問,提示錯誤。

如果上述步驟是在debian/ubuntu中做,現在已經可以看到安裝介面了,而這個是什麼情況?!

按提示中所說,錯誤記錄在了日誌裡,於是檢查了一下error.log(一般位於/etc/httpd/logs裡,取決於你的配置),發現了這樣的錯誤資訊:

呃………原來是乙個php函式的報錯。然而,chmod(): no such file or directory???

趕緊看下:

[root@imagineocean nextcloudtest]# ls lib/private/log

errorhandler.php  errorlog.php  file.php  rotate.php  syslog.php

這些檔案明明好好地躺在那裡!

第一反應是selinux在搗鬼,於是檢查了一下:

[root@imagineocean nextcloud]# getenforce

permissive

selinux已關閉。

Centos 7 安裝LAMP環境

一 安裝centos二 安裝apacheyum install httpd 根據提示,輸入y安裝即可成功安裝 systemctl start httpd.service 啟動apache systemctl stop httpd.service 停止apache systemctl restart ...

centos7配置lamp成功安裝過

linux apache mysql mariadb php 首先apache的安裝 yum install httpd 接著mysql mariadb的安裝 yum install mysql mysql server yum install mariadb mariadb server,啟動伺服...

centos(7) 使用yum進行安裝lamp環境

1.用yum安裝apache,mysql,php.1.1安裝apache 安裝完成後,用service httpd start 1.2 安裝mysql 成功安裝之後重啟mysql服務 service mysqld restart 初次安裝mysql是root賬戶是沒有密碼的 設定密碼的方法 mysq...