Author: lama-adm

  • Hello world!

    WordPress へようこそ。こちらは最初の投稿です。編集または削除し、コンテンツ作成を始めてください。

  • Setup Neovim on Manjaro Linux

    Install Neovim

    First of all, install neovim

    $ sudo pacman -S neovim

    Install Languages Providers

    Install Programing Languages

    $ sudo pacman -S ruby nodejs perl

    Install Python provider

    $ sudo pacman -S python-pynvim

    Install Ruby provider

    $ yay -S ruby-neovim

    Edit .profile in home directory and add a gem path.

    $ vim ~/.profile
    # Add Ruby Gem Path
    export PATH=$PATH:$HOME/.local/share/gem/3.0.0/bin

    Reload .profile file.

    $ source ~/.profile

    Install Node.js provider

    $ yay -S nodejs-neovim

    Edit Environment Variables for Perl provider

    Edit .profile on your home directory.

    $ vim ~/.profile
    # Add Perl Environment Variables
    export PERL_MB_OPT="--install_base $HOME/perl5"
    export PERL_MM_OPT="INSTALL_BASE=$HOME/perl5"
    export PERL_LOCAL_LIB_ROOT=$HOME/perl5
    export PERL5LIB="$$PERL5LIB:$HOME/perl5/lib/perl5"
    export PATH="$PATH:$HOME/perl5/bin"

    Reload .profile file.

    $ source ~/.profile

    Install Perl provider

    $ sudo pacman -S cpanminus
    $ sudo pacman -S perl-local-lib
    $ cpanm -n Neovim::Ext

    Install Clipboard

    $ sudo pacman -S xclip

    Enable Clipboard

    Edit ~/.config/nvim/init.vim

    set clipboard+=unnamed,unnamedplus

    Chack health

    Open neovim and type following command.

    :checkhealth

    Note:

    If you have installed Perl host provider(Neovim::Ext) and still checkhealth warning appears, delete ~/perl5 directory, and reinstall Neovim::Ext.

    $ rm -rf ~/perl5
    $ cpanm -n Neovim::Ext
  • Install Memory Cache

    To enhance performance of Nextcloud, Install memory cache. Redis is a key-value memory cache.

    Install Redis

    $ sudo pacman -S redis

    Configure Redis

    Enable socket communications to Redis for perfomance.

    $ sudo vi /etc/redis/redis.conf
    ...
    port 0
    unixsocket /run/redis/redis.sock
    unixsocketperm 700
    ...
    $ sudo systemctl start redis
    
    $sudo systemctl enable redis

    Check socket communications

    $ sudo redis-cli -s /run/redis/redis.sock
    > monitor

    If this command returns OK, the socket communication is established properly.

    Restart and Enable Redis

    $ sudo systemctl restart redis
    $ sudo systemctl enable redis
  • Tune up php.ini file

    For performance, tune up php.ini file.

    Edit php.ini

    $ sudo vi /etc/php/php.ini
    ...
    memory_limit=512M
    upload_max_filesize=5G
    post_max_size=5G
    
    cgi.fix_pathinfo=0
    
    zend_extenson=opcache
    
    [opcache]
    opcache.enable=1
    opcache.intend_string_buffer=8
    opcache.max_accelerated_files=10000
    opcache.memory_consumption=128
    opcache.save_comments=1
    opcache.revalidate_freq=2
    ...

    Restart PHP-FPM

    $ sudo systemctl restart php-fpm
  • SSL

    Install Certbot

    You can use free SSL certification by Let’s Encrypt. First, you should install certbot to use Let’s Encrypt.

    $ sudo pacman -S certbot certbot-nginx

    Certificate sites

    To certificate domain www.lama-lab.mydns.jp/ and nc.lama-lab.mydns.jp, type

    $ sudo certbot --nginx --agree-tos --domain www.lama-lab.mydns.jp/ --domain nc.lama-lab.mydns.jp --email 'msguardian06@gmail.com' --no-eff-email

    Configure Firewall

    $ sudo ufw allow https
    $ sudo ufw reload

    Scheduling Certification renew

    The certification will be expired every 3 months. So you should renew the certification automatically.

    $ sudo vi /etc/cron.daily/certbot-renew
    #!/bin/sh
    certbot renew --post-hook "systemctl reload nginx"

    Change the permission of the script.

    $sudo chmod 755 /etc/cron.daily/certbot-renew

    Note: How to delete a certification

    To delete a certification, type

    $ sudo certbot delete --cert-name www.lama-lab.mydns.jp/
  • Setup Nextcloud

    Download and extract Nextcloud

    $ wget https://download.nextcloud.com/server/releases/latest.tar.bz2
    $ sudo mv latest.tar.bz2 /misc/extHDD/
    $ sudo tar xvjf latest.tar.bz2
    $ sudo mv /misc/extHDD/nextcloud /misc/extHDD/nc.lama-lab.mydns.jp
    $ sudo chown http:http /misc/extHDD/nc.lama-lab.mydns.jp

    Accomplish Setup

    Visit

    http://nc.lama-lab.mydns.jp

    And input all database infomation. Then all is done!!

  • Create Database for Nextcloud

    Database Infomation

    • Database name : nextcloud_db
    • User name : nextcloud_user
    • Character set : utf8mb4
    • Password : XXXXXXXX

    Create Database

    $ sudo mysql -u root -p
    > CREATE DATABASE nextcloud_db DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
    > GRANT ALL PRIVILLEGES ON nextcloud_db.* TO 'nextcloud_user'@'localhost' IDENTIFIED BY 'XXXXXXXX';
    > FLUSH PRIVILLEGES;
    > EXIT;
  • Setup WordPress

    Download and extract WordPress

    $ wget https://wordpress.org/latest.tar.gz
    $ sudo mv latest.tar.gz /misc/extHDD/
    $ sudo tar xvzf latest.tar.gz
    $ sudo mv /misc/extHDD/wordpress /misc/extHDDwww.lama-lab.mydns.jp/
    $ sudo chown http:http /misc/extHDDwww.lama-lab.mydns.jp/ -R

    Accomplish Setup

    Visit

    http://www.lama-lab.mydns.jp

    And input all database infomation. Then all is done!!

  • Configure Nginx for WordPress

    Deploy config files

    WordPress config file

    $ sudo vi /etc/nginx/global/wordpress.conf
    location / {
    	# This is cool because no php is touched for static content.
    	# include the "?$args" part so non-default permalinks doesn't break when using query string
    	try_files $uri $uri/ /index.php?$args;
    }
    
    location ~ \.php$ {
    	#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
    	include fastcgi_params;
    	fastcgi_intercept_errors on;
    	fastcgi_pass php;
    	#The following parameter can be also included in fastcgi_params file
    	fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
    
    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
    	expires max;
    	log_not_found off;
    }

    Site specific config file

    $ sudo vi /etc/nginx/sites-available/www.lama-lab.mydns.jp.conf
    # Redirect everything to the main site. We use a separate server statement and NOT an if statement - see http://wiki.nginx.org/IfIsEvil
     
    server {
            server_name  _;
            return 302 $scheme://www.lama-lab.mydns.jp$request_uri;
    }
     
    server {
        server_name www.lama-lab.mydns.jp/;
        root /misc/extHDDwww.lama-lab.mydns.jp/;
     
        access_log /var/log/nginx/www.lama-lab.mydns.jp.access.log;
        error_log /var/log/nginx/www.lama-lab.mydns.jp.error.log;
    
        index index.php;
     
        include global/restrictions.conf;
     
        # Additional rules go here.
     
        # Only include one of the files below.
         include global/wordpress.conf;
    #    include global/wordpress-ms-subdir.conf;
    #    include global/wordpress-ms-subdomain.conf;
    
        listen 80;
        listen [::]:80;
    }

    Enable the Web site

    $ sudo ln -s /etc/nginx/sites-available/www.lama-lab.mydns.jp.conf /etc/nginx/sites-enabled/www.lama-lab.mydns.jp.conf
    $ sudo systemctl restart nginx
    $ sudo systemctl restart php-fpm