Categories
Uncategorized

Install Ubuntu 18.4, Apache2, PHP 7.3 and Percona 5.7

Update system repositories

sudo apt update

Install Apache 2

Install Apache 2 with the apt command

sudo apt install apache2

Allow Apache on UFW and verify its status

sudo ufw allow 'Apache'

Install PHP 7.3

Update system repositories

sudo apt update
sudo apt upgrade

Add PPA for PHP 7.3

sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update

Install PHP 7.3 for Apache

sudo apt install php7.3

Install PHP 7.3 Extensions

Install extensions through:

sudo apt install php7.3-extension_name

sudo apt install php7.3-common php7.3-mysql php7.3-xml php7.3-xmlrpc php7.3-curl php7.3-gd php7.3-imagick php7.3-cli php7.3-dev php7.3-imap php7.3-mbstring php7.3-opcache php7.3-soap php7.3-zip php7.3-intl

Adjust php.ini file

sudo nano /etc/php/7.3/apache2/php.ini

upload_max_filesize = 100M
post_max_size = 48M
memory_limit = 512M
max_execution_time = 600
max_input_vars = 3000
max_input_time = 1000

Restart Apache2 and PHP services

sudo systemctl restart apache2.service

Test PHP7.3 and Apache2 install

sudo nano /var/www/html/phpinfo.php

Add the following line and save

<?php phpinfo( ); ?>

Load web browser with localhost/phpinfo.php

The following is ONLY for dev environment

Add current user to group that owns /var/www/html folder

sudo usermod -a -G GROUPNAME USERNAME

Reboot system

Change group permissions to rwx

sudo chmod -R g+rwx /var/ww/html

Install Persona 5.7

Source: https://www.percona.com/doc/percona-server/5.7/installation/apt_repo.html

Update max_allowed_packet in mysqld.cnf to 32M to prevent Mysql went away message when doing large imports like: “ERROR 2006 (HY000) at line XXXX: MySQL server has gone away”

sudo nano /etc/mysql/percona-server.conf.d/mysqld.cnf

[mysqld]
max_allowed_packet=32M

sudo service mysql restart

Install PHPMyAdmin

sudo apt update && sudo apt install phpmyadmin

For WordPress installation /

Enable mod_rewrite

sudo a2enmod rewrite

sudo systemctl restart apache2

By default, Apache prohibits using an .htacess file to apply rewrite rules.

sudo nano /etc/apache2/sites-available/000-default.conf

Add the following code between <VirtualHost *:80>

<Directory /var/www/html>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
    </Directory>

sudo systemctl restart apache2

Create a .htaccess file in the web root folder

sudo nano /var/www/html/.htaccess

Add default WordPress .htaccess file contents:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Source: https://vitux.com/how-to-install-and-configure-apache-web-server-on-ubuntu/

Source: https://www.cloudbooklet.com/how-to-install-php-7-3-on-ubuntu-18-04/

Source: https://websiteforstudents.com/install-php-7-3-php-7-3-fpm-with-apache2-nginx-on-ubuntu-16-04-18-04-18-10/