Community

How to install Linux, Apache, MySQL, PHP (LAMP) stack for phpListings on an Ubuntu 22.04 server.

Showing 1 - 2 of 2
How to install Linux, Apache, MySQL, PHP (LAMP) stack for phpListings on an Ubuntu 22.04 server.
by Nicholas
1 month ago
N

Nicholas

Support Dept.

Step 1: Update the System

First, update your package index and upgrade your system to the latest versions.

sudo apt update
sudo apt upgrade

Step 2: Install Apache

Install Apache, which is the web server that will serve your directory website content.

sudo apt install apache2

Start Apache.

sudo systemctl start apache2

Step 3: Install MySQL

Install MySQL, which is the database management system for your phpListings data.

sudo apt install mysql-server

Secure your MySQL installation by running the security script.

sudo mysql_secure_installation

Follow the prompts to configure the security settings for MySQL. You will set a root password, remove anonymous users, disallow root login remotely, remove the test database, and reload privilege tables.

Note: You may encounter an error when running the mysql_secure_installation script without extra configuration. This error occurs because the script attempts to set a password for the root MySQL account, but on default Ubuntu installations, this account is not configured to use a password for connections. Perform the following commands to set the correct authentication method:

sudo mysql

In the MySQL prompt, alter the authentication method of the root user (replace 'password' with the actual root user password you are going to use for phpListings to access the MySQL database:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
exit

now you can continue and run the mysql_secure_installation tool.

Step 4: Install PHP and necessary extensions

sudo apt install php libapache2-mod-php php-mysql

You must also install all the required PHP extensions for the phpListings software.

sudo apt install php-curl php-json php-gd php-mbstring php-xml php-intl php-zip

Step 5: Obtain a free SSL Certificate with Certbot

You can obtain a free SSL certificate from Let's Encrypt using the Certbot tool.

First, install Certbot.

sudo apt install certbot python3-certbot-apache

Run Certbot to obtain and install the SSL certificate for your domain.

sudo certbot --apache

Follow the prompts to enter your email address, agree to the terms of service, and select the domain for which you want to enable HTTPS.

Step 6: Enable HTTP/2 protocol support in Apache Configuration

sudo a2enmod http2

Edit the Apache default SSL configuration file to enable HTTP/2.

sudo nano /etc/apache2/sites-enabled/domainname-le-ssl.conf

Add the following line within the `<VirtualHost _default_:443>` block:

Protocols h2 http/1.1

Also, make sure the SSL configuration points to the right certificates (Certbot will handle this if you're using Let's Encrypt).

Step 7: Configure MySQL and create a new database for phpListings

Secure MySQL and create a database and user.

Log in to MySQL as the root user.

sudo mysql -u root -p

Create a database and user, then grant privileges:

CREATE DATABASE your_database;
CREATE USER 'your_user'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON your_database.* TO 'your_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Replace `your_database`, `your_user`, and `your_password` with your actual database name, username, and password.

Step 8: Restart Apache

Restart Apache to apply all the changes.

sudo systemctl restart apache2

Step 9: Verify the Installation

Check the status of Apache to make sure it is running correctly.

sudo systemctl status apache2

You should also verify that HTTP/2 and SSL are enabled. You can use online tools such as:

https://tools.keycdn.com/http2-test to verify HTTP/2.
https://www.ssllabs.com/ssltest to check your SSL configuration.

Re: How to install Linux, Apache, MySQL, PHP (LAMP) stack for phpListings on an Ubuntu 22.04 server.
by Nicholas
1 month ago
N

Nicholas

Support Dept.

Here are sample Apache virtualhost configuration files you may find useful:

HTTP:

<VirtualHost *:80>
        ServerAdmin info@example.com
        ServerName example.com

        DocumentRoot /var/www/public

        <Directory /var/www/public>
                Options FollowSymLinks
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>
</VirtualHost>

HTTPS without Certbot alterations included:

<IfModule mod_ssl.c>
    <VirtualHost *:443>
        ServerAdmin info@example.com
        ServerName example.com

        DocumentRoot /var/www/public

        <Directory /var/www/public>
                Options FollowSymLinks
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

        Protocols h2 h2c http/1.1
        H2Push on
        H2PushPriority * after
        H2PushPriority text/css before
        H2PushPriority image/jpg after 32
        H2PushPriority image/jpeg after 32
        H2PushPriority image/png after 32
        H2PushPriority application/javascript interleaved
    </VirtualHost>
</IfModule>

HTTPS with Certbot alterations included:

<IfModule mod_ssl.c>
    SSLStaplingCache shmcb:/var/run/apache2/stapling_cache(128000)

    <VirtualHost *:443>
        ServerAdmin info@example.com
        ServerName example.com

        DocumentRoot /var/www/public

        <Directory /var/www/public>
                Options FollowSymLinks
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

        Protocols h2 h2c http/1.1
        H2Push on
        H2PushPriority * after
        H2PushPriority text/css before
        H2PushPriority image/jpg after 32
        H2PushPriority image/jpeg after 32
        H2PushPriority image/png after 32
        H2PushPriority application/javascript interleaved

        Include /etc/letsencrypt/options-ssl-apache.conf
        SSLUseStapling on
        Header always set Content-Security-Policy upgrade-insecure-requests
        SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
    </VirtualHost>
</IfModule>

 

Showing 1 - 2 of 2
pixel image