
OpenBSD 7, Nginx, PHP-FPM (FastCGI Process Manager), and MySQL (OEMP) work as a collection to form a web stack that makes it possible to run dynamic applications on a server. Nginx runs as the web server, FastCGI process manager (PHP-FPM) adds dynamic processing for PHP scripts, and MySQL works as the database server.
In this article, you will install Nginx, PHP with PHP-FPM, and MariaDB as the drop-in replacement MySQL on OpenBSD 7.
Deploy a Vultr OpenBSD 7 server and SSH to the server as root. Then, update the server.
By default, Nginx is available in the openBSD7 repository packages. Install it with the following command:
Enable Nginx to start at boot time.
Start the Nginx web server.
Install PHP.
Select your preferred version based on applications you intend to run. For system-wide compatibility, install PHP 7.4 (option 2).
PHP-FPM is automatically installed with the PHP package. Next, you have to start it up and allow it to run when the server starts.
Enable PHP-FPM to run at boot time.
Start PHP-FPM.
Install the necessary modules for PHP to connect to the MySQL server.
Output:
You can also install other PHP modules commonly required by most web applications.
Enable PHP modules.
Install Nano or your favorite text editor.
Edit the main Nginx configuration file.
Within the server { block, add the following lines of code for Nginx to pass all PHP processing to the PHP-FPM socket.
Save and close the file.
Test the Nginx configuration.
Output:
Edit the main PHP-FPM configuration file.
Confirm that PHP-FPM connects through the socket /var/www/run/php-fpm.sock, and also runs with the user, group www.
Install the MariaDB service.
Initialize the database server to create necessary binaries and system tables.
Start the MySQL daemon.
Secure MySQL by setting a new root password and removing insecure defaults.
You will receive multiple prompts, accept decisively to tighten your database server security.
Enable MySQL to start at boot time.
By default, Nginx uses the /var/www/htdocs directory as webroot. Create a new PHP sample file in that directory to test the web server.
Paste the following PHP code:
Enter your server's public IP address in a web browser and load the test.php file. Your output should be similar to:
Congratulations, you have successfully installed Nginx, MySQL, and PHP-FPM on your OpenBSD 7 server.
0 Comments
Be the first to comment and share your perspective with the community.