Tag: bitnami

  • How to Upgrade PHP on Bitnami WordPress in AWS Lightsail

    How to Upgrade PHP on Bitnami WordPress in AWS Lightsail

    I have an old Bitnami WordPress server on the Amazon Lightsail server. Bitnami does not support upgrading the PHP version. The recommended solution is to create a new bitnami WordPress instance and migrate the website to the new lightsail instance. Since this server had many websites configured, I do not want to migrate the websites to the new bitnami WordPress instance. Here is how I upgraded the PHP version on bitnami Debian 10 server from PHP 7.3 to PHP 8.1

    What we do is install the PHP version provided by the OS. Then update php.ini to use the non-defult MySQL socket location used by the Bitnami server. Create a php-fpm pool that runs as the “daemon” user. After that, we update the Apache configuration to use the new PHP version.

    First, enable PHP repository

    apt -y install apt-transport-https lsb-release ca-certificates
    wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
    echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list
    

    Install PHP 8.1

    apt update
    apt install -y  php8.1-bcmath php8.1-cli php8.1-common php8.1-curl php8.1-gd php8.1-imap php8.1-intl php8.1-mbstring php8.1-mysql php8.1-readline php8.1-soap php8.1-xml php8.1-xmlrpc php8.1-zip php8.1-fpm
    

    If you need a different version of PHP, change 8.1 with whatever version you need.

    Edit php.ini file

    vi /etc/php/8.1/fpm/php.ini
    

    Find

    [Pdo_mysql]
    ; Default socket name for local MySQL connects.  If empty, uses the built-in
    ; MySQL defaults.
    pdo_mysql.default_socket=
    

    Replace with

    [Pdo_mysql]
    ; Default socket name for local MySQL connects.  If empty, uses the built-in
    ; MySQL defaults.
    pdo_mysql.default_socket= "/opt/bitnami/mysql/tmp/mysql.sock"
    

    Find

    mysqli.default_socket =
    

    Replace with

    mysqli.default_socket = "/opt/bitnami/mysql/tmp/mysql.sock"
    

    Create a php-fpm pool file

    vi /etc/php/8.1/fpm/pool.d/wp.conf
    

    add

    [wordpress]
    listen=/opt/bitnami/php/var/run/ww2.sock
    user=daemon
    group=daemon
    listen.owner=daemon
    listen.group=daemon
    pm=dynamic
    pm.max_children=5
    pm.start_servers=2
    pm.min_spare_servers=1
    pm.max_spare_servers=3
    pm.max_requests=5000
    

    This pool will listen on unix socket “/opt/bitnami/php/var/run/ww2.sock”.

    Enable and restart PHP 8.1 fpm service

    systemctl enable php8.1-fpm
    systemctl restart php8.1-fpm
    

    Edit file

    vi /opt/bitnami/apache2/conf/bitnami/php-fpm.conf
    

    For some installations, file is located at

    vi /opt/bitnami/apache2/conf/php-fpm-apache.conf
    

    Inside you file find

    
      
      
      
        
          SetHandler "proxy:fcgi://www-fpm"
        
      
    

    Find

    www.sock
    

    Replace With

    www2.sock
    

    Restart Apache

    sudo /opt/bitnami/ctlscript.sh restart apache
    

    See Bitnami

  • How to install LetsEncrypt SSL on Bitnami WordPress Server

    How to install LetsEncrypt SSL on Bitnami WordPress Server

    To install a free LetsEncrypt SSL certificate on bitnami WordPress installation, do the following

    log in to the server as user “bitnami” using SSH/putty.

    Run command

    sudo /opt/bitnami/bncert-tool
    

    It will ask for the domain name. Enter domain names separated by space. After that you will be asked if you need to redirect the domain name to www, select the one you prefer for your website. Then it show a summary of tasks, once you confirm it, SSL will be installed.

    Before you do this, make sure the domain name is pointed to server IP and DNS is propagated.

    For more information, check bitnami documentation.

    See bitnami

  • Reset  MySQL root password on Bitnami server

    Reset MySQL root password on Bitnami server

    To reset MySQL root password on Bitnami server, first check MySQL server version you are running.

    mysql --version
    

    Create a file

    vi /tmp/mysql-init
    

    Add following text

    For MySQL 5.7 or MySQL 8

    ALTER USER 'root'@'localhost' IDENTIFIED BY 'NEW_PASSWORD';
    ALTER USER 'root'@'127.0.0.1' IDENTIFIED BY 'NEW_PASSWORD';
    

    For MySQL 5.6

    UPDATE mysql.user SET Password=PASSWORD('NEW_PASSWORD') WHERE User='root';
    FLUSH PRIVILEGES;
    

    In above code, replace NEW_PASSWORD with your new MySQL root password.

    Stop MySQL

    /opt/bitnami/ctlscript.sh stop mysql
    

    Reset MySQL root password by running

    MySQL 5.7/MySQL 8

    /opt/bitnami/mysql/bin/mysqld_safe --pid-file=/opt/bitnami/mysql/data/mysqld.pid --datadir=/opt/bitnami/mysql/data --init-file=/tmp/mysql-init --lower_case_table_names=1 2> /dev/null &
    

    If you are using MySQL 5.6 or older, run

    /opt/bitnami/mysql/bin/mysqld_safe --pid-file=/opt/bitnami/mysql/data/mysqld.pid --datadir=/opt/bitnami/mysql/data --init-file=/tmp/mysql-init 2> /dev/null &
    

    Restart MySQL

    /opt/bitnami/ctlscript.sh restart mysql
    

    Now you should be able to login to MySQL server with command

    mysql -u root -p'NEW_PASSWORD'
    

    See Bitnami, Reset MySQL root Password

  • Disable MySQL bin log on Bitnami

    Disable MySQL bin log on Bitnami

    if you have cloud sevrer with less disk space, it is better disable MySQL bin log as it take approx 3 GB of disk space on bitnami server.

    To disable MySQL binlog, edit mysql config file.

    vi /opt/bitnami/mysql/my.cnf
    

    Find

    [mysqld]
    

    Add below

    disable_log_bin
    

    Here is what i have in the my.cnf

    root@wordpress-vm:~# cat /opt/bitnami/mysql/my.cnf
    
    [mysqladmin]
    user=root
    
    [mysqld]
    disable_log_bin
    basedir=/opt/bitnami/mysql
    datadir="/opt/bitnami/mysql/data"
    port=3306
    socket=/opt/bitnami/mysql/tmp/mysql.sock
    tmpdir=/opt/bitnami/mysql/tmp
    max_allowed_packet=32M
    bind-address=127.0.0.1
    skip-name-resolve=1
    default-authentication-plugin=mysql_native_password
    
    character-set-server=UTF8
    collation-server=utf8_general_ci
    [client]
    port=3306
    socket=/opt/bitnami/mysql/tmp/mysql.sock
    
    default-character-set=UTF8
    [manager]
    port=3306
    socket=/opt/bitnami/mysql/tmp/mysql.sock
    pid-file=/opt/bitnami/mysql/tmp/manager.pid
    default-mysqld-path=/opt/bitnami/mysql/bin/mysqld.bin
    
    
    !include /opt/bitnami/mysql/bitnami/my.cnf
    root@wordpress-vm:~# 
    

    Now restart MySQL

    /opt/bitnami/ctlscript.sh stop mysql
    /opt/bitnami/ctlscript.sh start mysql
    

    You can now remove the file starting with binlog from folder /opt/bitnami/mysql/data

    rm -f /opt/bitnami/mysql/data/binlog.*
    
  • Install LetsEncrypt SSL on Bitnami

    NOTE: bitnami provides a tool to install SSL, it is better to use the tool to install SSL. You can see more info on page How to install LetsEncrypt SSL on Bitnami WordPress Server

    To install LetsEncrypt SSL on bitnami wordpress server, install letsencrypt with

    wget https://raw.githubusercontent.com/serverok/server-setup/master/install/letsencrypt.sh
    sh ./letsencrypt.sh
    

    Stop apache web server with

    /opt/bitnami/ctlscript.sh stop apache
    

    Now get SSL certificate using certbot

    certbot certonly --standalone -d YOUR-DOMAIN.EXT -d www.YOUR-DOMAIN.EXT
    

    Now you have SSL certficate, lets copy it to bitnami folder

    cat /etc/letsencrypt/live/YOUR-DOMAIN.EXT/privkey.pem >  /opt/bitnami/apache2/conf/server.key
    cat /etc/letsencrypt/live/YOUR-DOMAIN.EXT/cert.pem > /opt/bitnami/apache2/conf/server.crt
    cat /etc/letsencrypt/live/YOUR-DOMAIN.EXT/chain.pem >> /opt/bitnami/apache2/conf/server.crt
    

    Start the web server with

    /opt/bitnami/ctlscript.sh start apache
    

    Auto Renew LetsEncrypt

    Create file

    mkdir /usr/serverok
    vi /usr/serverok/ssl-renew
    

    Add following to the file. Replace YOUR-DOMAIN.EXT with your actual domain name.

    #!/bin/bash
    
    /opt/bitnami/ctlscript.sh stop apache
    /usr/bin/certbot renew
    cat /etc/letsencrypt/live/YOUR-DOMAIN.EXT/privkey.pem >  /opt/bitnami/apache2/conf/server.key
    cat /etc/letsencrypt/live/YOUR-DOMAIN.EXT/cert.pem > /opt/bitnami/apache2/conf/server.crt
    cat /etc/letsencrypt/live/YOUR-DOMAIN.EXT/chain.pem >> /opt/bitnami/apache2/conf/server.crt
    sleep 20
    /opt/bitnami/ctlscript.sh restart apache
    

    make the script executable

    chmod 755 /usr/serverok/ssl-renew
    

    Set a cronjob to execute it every month

    30 2 * * 1 /usr/serverok/ssl-renew >> /var/log/le-renew.log
    

    See bitnami

  • Bitnami

    To remove logo from bitnami wordpress, login to SSH as user “bitnami”, then run

    sudo /opt/bitnami/apps/wordpress/bnconfig --disable_banner 1
    

    Now restart web server

    sudo /opt/bitnami/ctlscript.sh restart apache
    

    If you are using Nginx, run

    sudo /opt/bitnami/ctlscript.sh restart nginx
    
  • Kubeapps

    Kubeapps allows you to run bitnami applications in Kubernetes cluster.

  • WordPress bitnami

    Install LetsEncrypt SSL on Bitnami

    To stop/start service use ctlscript.sh

    root@ip-172-31-26-46:~# /opt/bitnami/ctlscript.sh 
    usage: /opt/bitnami/ctlscript.sh help
           /opt/bitnami/ctlscript.sh (start|stop|restart|status)
           /opt/bitnami/ctlscript.sh (start|stop|restart|status) mysql
           /opt/bitnami/ctlscript.sh (start|stop|restart|status) php-fpm
           /opt/bitnami/ctlscript.sh (start|stop|restart|status) apache
    
    help       - this screen
    start      - start the service(s)
    stop       - stop  the service(s)
    restart    - restart or start the service(s)
    status     - show the status of the service(s)
    
    root@ip-172-31-26-46:~# 
    

    To stop MySQL, run

    root@ip-172-31-26-46:~# /opt/bitnami/ctlscript.sh stop mysql
    Unmonitored mysql
    /opt/bitnami/mysql/scripts/ctl.sh : mysql stopped
    root@ip-172-31-26-46:~# 
    

    To disable Banner on WordPress site, run

    /opt/bitnami/apps/wordpress/bnconfig --disable_banner 1
    

    Disable MySQL in Bitnami instance after moving Database to RDS

    /opt/bitnami/ctlscript.sh stop mysql
    mv /opt/bitnami/mysql/scripts/ctl.sh /opt/bitnami/mysql/scripts/ctl.sh.disabled
    mv /opt/bitnami/config/monit/conf.d/mysql.conf /opt/bitnami/config/monit/conf.d/mysql.conf.disabled
    

    Apache Config

    VirtualHost entry for wordpress is available on file

    vi /opt/bitnami/apache2/conf/bitnami/bitnami.conf