Install LEMP (Linux, Nginx, MySQL and PHP) Stack on OpenSuse

Exported on 28-Aug-2021 13:27:28

Install LEMP (Linux, Nginx, MySQL and PHP) On OpenSuse Server With Attune Automation

This Blueprint Install LEMP Stack Components On A OpenSuse Server And Creates A PHP Info File To Verify The Installation
Pre-Blueprint Attune setup
  1. On the Inputs tab, create a Linux node for the host you wish to install the stack on.
  2. On the Inputs tab, create Linux credentials to connect to the host you wish to install the stack on.

Parameters

Name Type Script Reference Default Value Comment
server_credential Linux OS Credential server_credential
server_host Linux / Unix Server server_host

1 - Install Nginx Server

We will being by installing Nginx web server.

The connection details have changed from the last step.

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
# Install nginx server
sudo zypper -n in nginx

# Configure and start nginx
sudo systemctl enable nginx
sudo systemctl start nginx

2 - Install MySQL (MariaDB) Server

Installs MySQL database server

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
# Install MariaDB Server and Client
sudo zypper -n in mariadb mariadb-client

# Enable and start MySQL Server
sudo systemctl start mysql
sudo systemctl enable mysql

3 - Install PHP and FPM

Installs PHP version 7.4 and PHP-FPM package which is used as the php interpreter for Nginx.

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
# Install php and fpm
sudo zypper -n in php7 php7-fpm

4 - Upload Nginx Config File

Uploads PHP configuration file, this enable nginx to support php execution with the help of php-fpm socket.

Login as user on node

Connect via SSH
ssh user@hostname
Deploy archive nginx-opensuse.conf.zip to remote path uploads
  1. Locate Files archive "nginx-opensuse.conf.zip", This can be downloaded from Attune
  2. Copy the Files archive to the server
  3. Extract the root of the Files archive to uploads, relative to the home directory
  4. Check that the files are in the correct location

5 - Upload PHP-FPM Config File

Uploads php-fpm configuration files, this sets correct FPM parameters for the LEMP stack environment.

Login as user on node

Connect via SSH
ssh user@hostname
Deploy archive php-fpm-www-opensuse.conf.zip to remote path uploads
  1. Locate Files archive "php-fpm-www-opensuse.conf.zip", This can be downloaded from Attune
  2. Copy the Files archive to the server
  3. Extract the root of the Files archive to uploads, relative to the home directory
  4. Check that the files are in the correct location

6 - Finish Configuration & Create PHPInfo file

Finally, move the configuration files to their respective directories and restart the servers. To test that PHP is working fine with Nginx, a info.php file is created in the root directory of the server.

Visit http://YOUR_IP/info.php , once this step has been completed to verify the installation.

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
# Replace nginx default config file
sudo cp ~/uploads/nginx-opensuse.conf /etc/nginx/nginx.conf

# Replace FPM configuration file
sudo cp ~/uploads/www-opensuse.conf /etc/php7/fpm/php-fpm.d/www.conf
sudo cp /etc/php7/fpm/php-fpm.conf.default /etc/php7/fpm/php-fpm.conf

# Add phpinfo file
echo '<?php phpinfo(); ?>' | sudo tee /srv/www/htdocs/info.php

# Restart servers
sudo service php-fpm restart
sudo service nginx restart