Learn how to Install LEMP Stack with MySQL 8 on Fedora 30/Fedora 29 by following through this guide.
Installing LEMP Stack with MySQL 8 on Fedora
Run system update;
dnf update
dnf upgrade
Next, install LEMP stack. Installation of different components of LEMP stack (Nginx, MySQL and PHP) have been covered on different guides. See the links below;
Install Nginx Web Server on Fedora 30/Fedora 29
Install MySQL 8 on Fedora 30/Fedora 29
Install PHP 7.3.4 on Fedora 30/Fedora 29
Assuming the above components have been installed, proceed to do the configuration.
Configure PHP
This is a number of PHP extensions that are required for the functionality of Nginx. In our basic setup, this guide installs PHP MySQL native driver and FastCGI Process Manager (php-mysqlnd and php-fpm) extensions.
dnf install php-mysqlnd php-fpm
If your application requires other PHP extensions, you can always install them on Fedora 30/29 by running the command below
dnf install php-[extension]
Next, you need to set the Unix user/group of PHP processes to nginx. This can be done by editing the file, and replacing apache user/group with nginx.
vim /etc/php-fpm.d/www.conf
...
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
; RPM: apache user chosen to provide access to the same directories as httpd
user = nginx
; RPM: Keep a group allowed to write in log dir.
group = nginx
...
Next, set ownership permissions for unix socket to nginx user/group defined above.
...
listen.owner = nginx
listen.group = nginx
...
Save the configuration file and restart and enable PHP-FPM to run on system boot.
systemctl restart php-fpm
systemctl enable php-fpm
Configuring Nginx
Now that Nginx has been installed, create your site configuration file with the following basic settings.
vim /etc/nginx/conf.d/kifarunix-demo.conf
server {
listen 80;
server_name kifarunix-demo.com;
root /usr/share/nginx/html/kifarunix-demo.com;
index index.php;
access_log /var/log/nginx/kifarunix-demo.com.access.log;
error_log /var/log/nginx/kifarunix-demo.com.error.log;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Set the bucket size for the types hash tables to 4096.
sed -i 's/types_hash_max_size 2048;/types_hash_max_size 4096;/' /etc/nginx/nginx.conf
Create the web root directory defined above.
mkdir /usr/share/nginx/html/kifarunix-demo.com
Save the configuration file and run the command below to verify Nginx syntax.
nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Restart Nginx if there is no syntactical error.
systemctl restart nginx
Test Nginx PHP Processing
To confirm that Nginx PHP-FPM is working, create a PHP test page as shown below and test it by accessing it from the browser.
echo "<?php phpinfo(); ?>" > /usr/share/nginx/html/kifarunix-demo.com/php-test.php
Now, access the URL http://kifarunix-demo.com/php-test.php. Replace your site domain accordingly.
Well, seems everything is fine. You can now remove the PHP test page.
rm -rf /usr/share/nginx/html/kifarunix-demo.com/php-test.php
That is all on our demo on how to install LEMP Stack with MySQL 8 on Fedora.
Other related tutorials;
Install LAMP Stack on Fedora 30
Install LAMP Stack on Debian 9
How To Install LAMP (Linux, Apache, MySQL, PHP) Stack on Fedora 28/29
How to Install LAMP Stack (Apache,MariaDB, PHP 7.2) on Ubuntu 18.04 LTS