Dexter Evil Clone.

Alchemiclabs.ca


Welcome Demo

If you want to use Nginx instead of Apache as the web server while keeping MariaDB, follow the steps below:

Step 1: Install Debian

  • Follow the same steps as mentioned earlier to install Debian on your server.

Step 2: Update the System

  • Update and upgrade the system as before:
    sudo apt update
    sudo apt upgrade

Step 3: Install Nginx

  • Install Nginx using the package manager:

    sudo apt install nginx
  • Start the Nginx service and enable it to start on boot:

    sudo systemctl start nginx
    sudo systemctl enable nginx

Step 4: Install MariaDB Database Server

  • If you have not installed MariaDB yet, install it using the following commands:

    sudo apt install mariadb-server mariadb-client
  • During the installation, you will be prompted to set the root password for MariaDB. Choose a strong password and remember it.

  • Start the MariaDB service and enable it to start on boot:

    sudo systemctl start mariadb
    sudo systemctl enable mariadb
  • Secure your MariaDB installation by running the security script:

    sudo mysql_secure_installation

Step 5: Install PHP-FPM

  • Install PHP-FPM and necessary modules:

    sudo apt install php-fpm php-mysql
  • Configure PHP-FPM to work with Nginx:

    sudo nano /etc/php/7.x/fpm/pool.d/www.conf

    Inside the file, find the line that starts with listen = and change it to:

    listen = /run/php/php7.x-fpm.sock
  • Restart PHP-FPM to apply the changes:

    sudo systemctl restart php7.x-fpm

Step 6: Test PHP

  • Create a PHP info file to check if PHP is working correctly:

    echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/phpinfo.php
  • Open a web browser and access http://your_server_ip/phpinfo.php. You should see the PHP info page displaying various PHP configuration details.

Step 7: Configure Nginx

  • Create a new Nginx server block (virtual host) for your website:

    sudo nano /etc/nginx/sites-available/example.com

    Replace example.com with your domain name or server IP address.

  • Paste the following configuration into the file:

    server {
        listen 80;
        server_name example.com;
        root /var/www/html;
    
        location / {
            index index.php index.html index.htm;
        }
    
        location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/run/php/php7.x-fpm.sock;
        }
    }
  • Create a symbolic link to enable the site:

    sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
  • Test the Nginx configuration for syntax errors:

    sudo nginx -t
  • If the test is successful, reload Nginx to apply the changes:

    sudo systemctl reload nginx

Step 8: Configure Firewall (Optional)

  • If you have a firewall installed (e.g., UFW), open port 80 (HTTP) and 443 (HTTPS) to allow web traffic:
    sudo ufw allow 80/tcp
    sudo ufw allow 443/tcp
    sudo ufw enable

Step 9: Optional Steps

  • You may want to install additional PHP modules or other tools, depending on your specific requirements. Common modules include php-cli, php-gd, php-curl, etc.

That's it! With these steps, you have now set up a LEMP server (Linux, Nginx, MariaDB, PHP) using Debian. You can proceed to deploy web applications or host websites on your server. Remember to keep your system and software up-to-date and maintain security best practices.