Cara menggunakan php-apcu install ubuntu

APCu (APC User Cache) is an in-memory key value store for PHP which provide better performance. It is a drop in replacement for APC.

How to download APCu

Latest stable release of APCu (in tgz format) can be downloaded from php.net website : https://pecl.php.net/get/APCu

Click on the below URL to check APC user cache documentation on php.net website :

http://php.net/manual/en/book.apcu.php


Steps to install APCu PHP extension

Do the below steps to install APCu on Ubuntu Server

1. Log into your Ubuntu server as ‘root’ user or login as any user with sudo privileges

2. Run the below command to check whether php APCu is already installed and enabled on the server

root@server:~# php -m | grep -i apcu

If APCu isn’t installed, the above command won’t return any output.

3. Run the command ‘pecl install apcu’ to install APCu on the server.


# pecl install apcu

WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
downloading apcu-5.1.16.tgz ...
Starting to download apcu-5.1.16.tgz (94,032 bytes)
.....................done: 94,032 bytes
38 source files, building
running: phpize
Configuring for:
PHP Api Version: 20151012
Zend Module Api No: 20151012
Zend Extension Api No: 320151012
Enable internal debugging in APCu [no] :
building in /tmp/pear/temp/pear-build-rootxU5reS/apcu-5.1.16
running: /tmp/pear/temp/apcu/configure --with-php-config=/usr/bin/php-config --enable-apcu-debug=no

Build process completed successfully
Installing '/usr/include/php/20151012/ext/apcu/apc_cache.h'
Installing '/usr/include/php/20151012/ext/apcu/apc_lock_api.h'
Installing '/usr/include/php/20151012/ext/apcu/apc.h'
Installing '/usr/include/php/20151012/ext/apcu/apc_serializer.h'
Installing '/usr/include/php/20151012/ext/apcu/php_apc.h'
Installing '/usr/include/php/20151012/ext/apcu/apc_lock.h'
Installing '/usr/include/php/20151012/ext/apcu/apc_mutex.h'
Installing '/usr/include/php/20151012/ext/apcu/apc_iterator.h'
Installing '/usr/include/php/20151012/ext/apcu/apc_stack.h'
Installing '/usr/include/php/20151012/ext/apcu/apc_arginfo.h'
Installing '/usr/include/php/20151012/ext/apcu/apc_globals.h'
Installing '/usr/include/php/20151012/ext/apcu/apc_cache_api.h'
Installing '/usr/include/php/20151012/ext/apcu/apc_api.h'
Installing '/usr/include/php/20151012/ext/apcu/apc_sma_api.h'
Installing '/usr/include/php/20151012/ext/apcu/apc_sma.h'
Installing '/usr/lib/php/20151012/apcu.so'
install ok: channel://pecl.php.net/apcu-5.1.16
You should add "extension=apcu.so" to php.ini


4. Append the line “extension=apcu.so” to the end of php configuration file

run the command ‘php --ini’ to check the Loaded PHP Configuration File

echo “extension=apcu.so” >> /etc/php/7.0/cli/php.ini

5. Now run the command “php -m | grep -i apc” to check whether it is enabled.

root@server:~# php -m | grep -i apc
apcu

This is a short guide to installing ownCloud on a fresh installation of Ubuntu 20.04. Run the following commands in your terminal to complete the installation.

This guide can not go into details and has its limits by nature. If you experience issues like with dependencies of PHP or other relevant things like the operating system, web server or database, look at the for more information.

Prerequisites and Notes

  • A fresh installation of Ubuntu 20.04 with SSH enabled.

  • This guide assumes that you are working as the root user.

  • Your ownCloud directory will be located in

    apt update && \
      apt upgrade -y
    5.

  • php 7.4 is the default version installable with Ubuntu 20.04.

  • Use the correct .

  • Read the notes which are important when planning to use encryption.

Preparation

Set Your Domain Name

my_domain="Your.Domain.tld"
echo $my_domain

hostnamectl set-hostname $my_domain
hostname -f

Generate Strong Passwords

sec_admin_pwd=$(openssl rand -base64 18)
echo $sec_admin_pwd > /etc/.sec_admin_pwd.txt

sec_db_pwd=$(openssl rand -base64 18)
echo $sec_db_pwd > /etc/.sec_db_pwd.txt

Update Your System

First, ensure that all the installed packages are entirely up to date and that PHP is available in the APT repository. To do so, follow the instructions below:

apt update && \
  apt upgrade -y

Create the occ Helper Script

Create a helper script to simplify running occ commands:

FILE="/usr/local/bin/occ"
cat <<EOM >$FILE
#! /bin/bash
cd /var/www/owncloud
sudo -E -u www-data /usr/bin/php /var/www/owncloud/occ "\$@"
EOM

Make the helper script executable:

chmod +x $FILE

Install the Required Packages

apt install -y \
  apache2 libapache2-mod-php \
  mariadb-server openssl redis-server wget php-imagick \
  php-common php-curl php-gd php-gmp php-bcmath php-imap \
  php-intl php-json php-mbstring php-mysql php-ssh2 php-xml \
  php-zip php-apcu php-redis php-ldap php-phpseclib

Install smbclient php Module

If you want to connect to external storage via SMB you need to install the smbclient php module.

First install the required packages:

apt-get install -y libsmbclient-dev php-dev php-pear

Then install smblclient php module using pecl:

pecl channel-update pecl.php.net
mkdir -p /tmp/pear/cache
pecl install smbclient-stable
echo "extension=smbclient.so" > /etc/php/7.4/mods-available/smbclient.ini
phpenmod smbclient
systemctl restart apache2

Check if it was successfully activated:

php -m | grep smbclient

This should show the following output:

libsmbclient
smbclient

Additional useful tools helpful for debugging:

sec_admin_pwd=$(openssl rand -base64 18)
echo $sec_admin_pwd > /etc/.sec_admin_pwd.txt

sec_db_pwd=$(openssl rand -base64 18)
echo $sec_db_pwd > /etc/.sec_db_pwd.txt
0

Configure Apache

Create a Virtual Host Configuration

sec_admin_pwd=$(openssl rand -base64 18)
echo $sec_admin_pwd > /etc/.sec_admin_pwd.txt

sec_db_pwd=$(openssl rand -base64 18)
echo $sec_db_pwd > /etc/.sec_db_pwd.txt
1

Enable the Virtual Host Configuration

sec_admin_pwd=$(openssl rand -base64 18)
echo $sec_admin_pwd > /etc/.sec_admin_pwd.txt

sec_db_pwd=$(openssl rand -base64 18)
echo $sec_db_pwd > /etc/.sec_db_pwd.txt
2

Configure the Database

It’s recommended to execute

apt update && \
  apt upgrade -y
6 to secure the mariadb installation and set a strong password for the database user.

Ensure transaction-isolation level is set and performance_schema on.

sec_admin_pwd=$(openssl rand -base64 18)
echo $sec_admin_pwd > /etc/.sec_admin_pwd.txt

sec_db_pwd=$(openssl rand -base64 18)
echo $sec_db_pwd > /etc/.sec_db_pwd.txt
3

It is recommended to run mysqltuner script to analyse database configuration after running with load for several days.

Enable the Recommended Apache Modules

sec_admin_pwd=$(openssl rand -base64 18)
echo $sec_admin_pwd > /etc/.sec_admin_pwd.txt

sec_db_pwd=$(openssl rand -base64 18)
echo $sec_db_pwd > /etc/.sec_db_pwd.txt
4

Installation

Download ownCloud

sec_admin_pwd=$(openssl rand -base64 18)
echo $sec_admin_pwd > /etc/.sec_admin_pwd.txt

sec_db_pwd=$(openssl rand -base64 18)
echo $sec_db_pwd > /etc/.sec_db_pwd.txt
5

Install ownCloud

Remember to set a strong password for your owncloud admin user and provide the previously set password for the database user as the

apt update && \
  apt upgrade -y
7 argument.

sec_admin_pwd=$(openssl rand -base64 18)
echo $sec_admin_pwd > /etc/.sec_admin_pwd.txt

sec_db_pwd=$(openssl rand -base64 18)
echo $sec_db_pwd > /etc/.sec_db_pwd.txt
6

Configure ownCloud’s Trusted Domains

sec_admin_pwd=$(openssl rand -base64 18)
echo $sec_admin_pwd > /etc/.sec_admin_pwd.txt

sec_db_pwd=$(openssl rand -base64 18)
echo $sec_db_pwd > /etc/.sec_db_pwd.txt
7

Configure the cron Jobs

Set your background job mode to cron:

sec_admin_pwd=$(openssl rand -base64 18)
echo $sec_admin_pwd > /etc/.sec_admin_pwd.txt

sec_db_pwd=$(openssl rand -base64 18)
echo $sec_db_pwd > /etc/.sec_db_pwd.txt
8

Configure the execution of the cron job to every 15 min and the cleanup of chunks every night at 2 am:

sec_admin_pwd=$(openssl rand -base64 18)
echo $sec_admin_pwd > /etc/.sec_admin_pwd.txt

sec_db_pwd=$(openssl rand -base64 18)
echo $sec_db_pwd > /etc/.sec_db_pwd.txt
9

If you need to sync your users from an LDAP or Active Directory Server, add this additional Cron job. Every 4 hours this cron job will sync LDAP users in ownCloud and disable the ones who are not available for ownCloud. Additionally, you get a log file in

apt update && \
  apt upgrade -y
8 for debugging.

apt update && \
  apt upgrade -y
0

Configure Caching and File Locking

apt update && \
  apt upgrade -y
1

Configure Log Rotation

apt update && \
  apt upgrade -y
2

Finalize the Installation

Make sure the permissions are correct:

apt update && \
  apt upgrade -y
3

ownCloud is now installed. You can confirm that it is ready to enable HTTPS (for example using Let’s Encrypt) by pointing your web browser to your ownCloud installation.

To check if you have installed the correct version of ownCloud and that the occ command is working, execute the following: