Setting up Linux for Mutall Projects

1. Start with System Update

Keep your system up-to-date:

sudo apt update
sudo apt upgrade -y

2. Install PHP and Required Extensions

Add the PHP PPA and install PHP 8.1 along with necessary extensions:

sudo add-apt-repository ppa:ondrej/php -y
sudo apt update
sudo apt install php8.1 php8.1-dev php8.1-mysql php8.1-cli php-pear build-essential php8.1-common php8.1-zip php8.1-gd php8.1-mbstring php8.1-curl php8.1-xml php8.1-bcmath -y

3. Install Apache and Integrate with PHP

Install Apache and configure it for PHP:

sudo apt install apache2 libapache2-mod-php
sudo apt install mysql-server
sudo a2enmod rewrite
sudo a2enmod php8.1
sudo apache2ctl configtest
sudo systemctl restart apache2

Update the default Apache configuration file:

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

Add the following inside the <VirtualHost *:80> block:

<Directory /home/user_name/mutall_projects>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

DocumentRoot /home/user_name/mutall_projects

Set permissions for the project directory:

sudo chown -R www-data:www-data /home/user_name/mutall_projects
sudo chmod -R 755 /home/user_name/mutall_projects

4. Install PECL Extensions

sudo pecl install ds
sudo pecl install pdo_mysql

5. Edit php.ini to Enable Extensions

Edit the PHP configuration files:

sudo nano /etc/php/8.1/apache2/php.ini
sudo nano /etc/php/8.1/cli/php.ini

Uncomment these lines:

extension=pdo_mysql
extension=ds.so

6. Install phpMyAdmin

sudo apt-get install phpmyadmin

If needed, enable Apache configuration:

sudo a2enconf phpmyadmin
sudo systemctl restart apache2

If phpMyAdmin is not accessible, add the alias:

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

Add inside <VirtualHost *:80>:

Alias /phpmyadmin /usr/share/phpmyadmin

Restart Apache:

sudo systemctl restart apache2

7. Configure MySQL for phpMyAdmin

Access MySQL:

sudo mysql

Run these SQL commands:

CREATE USER 'phpmyadmin'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;

Secure the installation:

sudo mysql_secure_installation

8. Restart Services

sudo systemctl restart php8.1-fpm
sudo systemctl restart apache2

9. Test the Setup

Create a test PHP file:

echo "" | sudo tee /home/user_name/mutall_projects/test.php

Access the file in your browser: http://localhost/test.php