{"id":1181,"date":"2026-11-26T18:00:00","date_gmt":"2026-11-26T18:00:00","guid":{"rendered":"https:\/\/vpslake.com\/blog\/?p=1181"},"modified":"2026-11-26T18:00:00","modified_gmt":"2026-11-26T18:00:00","slug":"install-lamp-stack-rocky-linux-10","status":"publish","type":"post","link":"https:\/\/vpslake.com\/blog\/2026\/11\/26\/install-lamp-stack-rocky-linux-10\/","title":{"rendered":"How to Install LAMP Stack on Rocky Linux 10 (Step-by-Step)"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Install LAMP stack on Rocky Linux 10 and you will have Apache serving pages, PHP 8.3 processing dynamic requests, and MariaDB ready for an application in about ten minutes. The setup uses Rocky\u2019s repositories, firewalld, and SELinux-friendly file labels, then leaves you with a local database account and a temporary PHP test.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Rocky Linux 10 changed PHP packaging compared with older Enterprise Linux releases: its AppStream repository supplies PHP 8.3 without the old module-stream commands. That means the base repositories are enough for this first deployment; you do not need to add Remi or EPEL just to build the stack.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n\n<li>A 64-bit Rocky Linux 10 VPS with at least 2 GB of RAM and 10 GB of free disk space.<\/li>\n\n\n<li>A root SSH session, or a standard account that can invoke <code>sudo<\/code> successfully.<\/li>\n\n\n<li>A public IPv4 address for testing Apache and outbound access to Rocky\u2019s BaseOS and AppStream repositories.<\/li>\n\n\n<li>A domain is optional during installation. You need one before issuing a trusted TLS certificate for a production site.<\/li>\n\n\n<li>A <a href=\"https:\/\/vpslake.com\/buy-vps\">VPSLake Linux VPS<\/a> if you need a fresh Rocky Linux server with root access.<\/li>\n\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">These examples assume a non-root SSH login. A root session can omit the <code>sudo<\/code> prefix throughout.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1: Confirm Rocky Linux 10 and update the server<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Checking the release first prevents an EL9 or EL8 package instruction from being applied to this machine, while the upgrade installs current security fixes.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>grep -E '^(PRETTY_NAME|VERSION_ID|ID_LIKE)=' \/etc\/os-release\nuname -m\nsudo dnf upgrade -y<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The release should identify Rocky Linux 10 and the architecture should normally be <code>x86_64<\/code>. The minor release and package versions change over time, so do not hard-code them in later commands.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PRETTY_NAME=\"Rocky Linux 10.x (Red Quartz)\"\nVERSION_ID=\"10.x\"\nID_LIKE=\"rhel fedora\"\nx86_64<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If DNF installs a new kernel, keep this SSH session open until you have confirmed that the VPS can reboot and accept a new connection.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2: Install Apache and open the web ports<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Apache serves the document root, while firewalld limits public traffic to SSH and the HTTP services the server actually needs.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo dnf install -y httpd firewalld curl\nsudo systemctl enable --now firewalld httpd\nsudo firewall-cmd --permanent --zone=public --add-service=ssh\nsudo firewall-cmd --permanent --zone=public --add-service=http\nsudo firewall-cmd --permanent --zone=public --add-service=https\nsudo firewall-cmd --reload\nsudo systemctl is-active httpd firewalld\nsudo firewall-cmd --zone=public --list-services<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Adding SSH before the reload reduces the chance of locking yourself out. If SSH uses a custom port, add that port instead of relying only on the <code>ssh<\/code> service. The service check should print <code>active<\/code> for both units, and the firewalld list should include <code>ssh<\/code>, <code>http<\/code>, and <code>https<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Test Apache locally before testing the public address. A local response proves the daemon is listening even when a provider-level firewall or DNS record is still wrong.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apachectl configtest\ncurl -fsSI http:\/\/127.0.0.1\/<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Syntax OK\nHTTP\/1.1 200 OK\nContent-Type: text\/html; charset=UTF-8<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3: Install PHP 8.3 from AppStream<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Rocky Linux 10\u2019s AppStream repository provides PHP 8.3, and installing the native <code>php<\/code> package connects PHP to Apache through the packaged Apache PHP module. Rocky 10 no longer needs the <code>dnf module enable<\/code> and <code>module install<\/code> pattern used by older releases; see Rocky\u2019s <a href=\"https:\/\/docs.rockylinux.org\/10\/books\/web_services\/03-application-servers\/\" target=\"_blank\" rel=\"noopener\">PHP and PHP-FPM documentation<\/a> for the release-specific packaging notes.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo dnf install -y php php-cli php-mysqlnd php-gd php-curl php-zip php-mbstring php-xml php-opcache\nphp -v\nsudo systemctl restart httpd\nsudo systemctl is-active httpd<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The version line should begin with <code>PHP 8.3<\/code>, and Apache should remain <code>active<\/code>. The package list includes the MySQL-compatible connector and common extensions used by PHP applications without pulling in an external repository.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Create a short-lived endpoint that returns a fixed value. This tests PHP execution without exposing the detailed configuration that <code>phpinfo()<\/code> would reveal.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>printf '%s\\n' '&lt;?php echo \"PHP OK\\\\n\"; ?&gt;' | sudo tee \/var\/www\/html\/health.php &gt; \/dev\/null\ncurl -fsS http:\/\/127.0.0.1\/health.php\nsudo rm -f \/var\/www\/html\/health.php<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The response should be <code>PHP OK<\/code>. Remove the endpoint after the request, as even a small diagnostic script should not remain in a public document root.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PHP OK<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4: Install MariaDB and create a local application database<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">MariaDB supplies the SQL layer, and a user restricted to <code>localhost<\/code> lets a website on this VPS connect without exposing port 3306 to the Internet.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo dnf install -y mariadb-server mariadb\nsudo systemctl enable --now mariadb\nsudo systemctl is-active mariadb\nsudo mariadb-secure-installation<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The security program is interactive. Remove anonymous accounts, reject remote root login, remove the test database, and reload the privilege tables when prompted. Keeping local administrative access through the Unix socket is a sensible default; the application should use its own account. MariaDB explains these choices in the <a href=\"https:\/\/mariadb.com\/docs\/server\/clients-and-utilities\/deployment-tools\/mariadb-secure-installation\" target=\"_blank\" rel=\"noopener\">official <code>mariadb-secure-installation<\/code> reference<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Create a database and a separate login for the application. Replace <code>YOUR_DB_PASSWORD<\/code> with a long, unique secret before running this block; it is a placeholder, not a password to keep.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mariadb &lt;&lt;'SQL'\nCREATE DATABASE lampdb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;\nCREATE USER 'lampuser'@'localhost' IDENTIFIED BY 'YOUR_DB_PASSWORD';\nGRANT ALL PRIVILEGES ON lampdb.* TO 'lampuser'@'localhost';\nFLUSH PRIVILEGES;\nSQL\nsudo mariadb -e \"SHOW DATABASES LIKE 'lampdb';\"<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The final query should return one row named <code>lampdb<\/code>. Keep the real password in your application\u2019s secret configuration, not in a file under <code>\/var\/www\/html<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Verify the LAMP stack<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Run these checks together to confirm that Apache, firewalld, and MariaDB start at boot, PHP has the database connector, and the web server answers a local request.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl is-active httpd firewalld mariadb\nsudo systemctl is-enabled httpd firewalld mariadb\nsudo apachectl configtest\nphp -m | grep -E 'mysqli|mysqlnd|PDO|mbstring|xml'\nsudo mariadb -e \"SELECT VERSION();\"\ncurl -fsSI http:\/\/127.0.0.1\/\nsudo firewall-cmd --zone=public --list-services<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Expect three <code>active<\/code> lines, three <code>enabled<\/code> lines, <code>Syntax OK<\/code>, the PHP module names, a MariaDB version, an HTTP success response, and the three public services.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>active\nactive\nactive\nenabled\nenabled\nenabled\nSyntax OK\nHTTP\/1.1 200 OK\nssh http https<\/code><\/pre>\n\n\n\n<aside class=\"vl-element vl-cta-banner\" aria-label=\"Start your LAMP server\">\n\t<div class=\"vl-cta-banner__content\">\n\t\t<p class=\"vl-cta-banner__eyebrow\">Rocky Linux VPS<\/p>\n\t\t<h3 class=\"vl-cta-banner__title\">Start your LAMP server<\/h3>\n\t\t<p class=\"vl-cta-banner__text\">Get root access for Apache, PHP, and MariaDB on a Rocky Linux VPS.<\/p>\n\t<\/div>\n\t<a class=\"vl-cta-banner__button\" href=\"\/buy-vps\" aria-label=\"View Linux VPS plans\">View Linux VPS plans<\/a>\n<\/aside>\n\n\n\n<h2 class=\"wp-block-heading\">Troubleshooting<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><code>No match for argument: php-mysqlnd<\/code><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The repository metadata may be stale, or the server may not actually be Rocky Linux 10. Confirm the release and refresh Rocky\u2019s enabled repositories before adding any third-party source.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>grep -E '^(PRETTY_NAME|VERSION_ID|ID_LIKE)=' \/etc\/os-release\nsudo dnf clean all\nsudo dnf makecache\nsudo dnf repolist --enabled<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Rocky Linux 10 uses the AppStream PHP package rather than a PHP module stream. Do not run an EL9 module command or install repositories built for another Enterprise Linux major version.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">PHP source appears in the browser<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Apache is serving the <code>.php<\/code> file as text because the PHP Apache module is missing or the web server has not been restarted after installation. Check the loaded modules and package state, then restart Apache.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo dnf reinstall -y php php-cli\nsudo httpd -M | grep php_module\nsudo apachectl configtest\nsudo systemctl restart httpd<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The module check should print a line containing <code>php_module<\/code>. Recreate the temporary <code>health.php<\/code> endpoint from Step 3, test it locally, and remove it again.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>403 Forbidden<\/code> after changing files in <code>\/var\/www\/html<\/code><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Apache may be blocked by an incorrect SELinux label or unreadable file mode. Restore the standard web-content labels and use readable, non-world-writable permissions; do not disable SELinux.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo restorecon -Rv \/var\/www\/html\nsudo find \/var\/www\/html -type d -exec chmod 0755 {} +\nsudo find \/var\/www\/html -type f -exec chmod 0644 {} +\nsudo systemctl reload httpd<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If an application needs uploads, label only its upload directory with the appropriate SELinux policy after checking the application\u2019s requirements instead of making the entire document root writable.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>Access denied for user 'lampuser'@'localhost'<\/code><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The application password differs from the value used when the account was created, or the application is connecting with a different database host. Test the credentials over the local socket before changing grants.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mariadb -u lampuser -p lampdb -e \"SELECT 1;\"<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Enter the real password, not the placeholder. If it is wrong, reset the account from the administrative socket and update the application configuration at the same time.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mariadb -e \"ALTER USER 'lampuser'@'localhost' IDENTIFIED BY 'NEW_DB_PASSWORD';\"<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Hardening<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n\n<li>Keep port 3306 closed in firewalld. A local application can use <code>localhost<\/code> or MariaDB\u2019s Unix socket without public database access.<\/li>\n\n\n<li>Point <code>YOUR_DOMAIN<\/code> to the VPS, issue a trusted TLS certificate, and redirect HTTP to HTTPS before accepting logins or other sensitive data.<\/li>\n\n\n<li>Restore SELinux labels after copying site files, remove temporary health checks, and never place database passwords under <code>\/var\/www\/html<\/code>.<\/li>\n\n\n<li>Apply Rocky Linux updates regularly and back up both the web root and MariaDB databases before major PHP or application changes.<\/li>\n\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">FAQ<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Which PHP version does Rocky Linux 10 use?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Rocky Linux 10\u2019s AppStream repository provides PHP 8.3, with patch updates arriving through normal DNF updates. The exact patch number can change, so the guide checks the installed version rather than pinning one build.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Why does this guide not enable a PHP module stream?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Rocky Linux 10 follows the EL10 packaging change in which the default PHP version comes directly from AppStream. The older <code>dnf module enable php:8.3<\/code> commands belong to releases that still publish PHP as a module stream.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Should I open MariaDB port 3306 for a PHP website?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">No. A PHP application on the same VPS can connect through <code>localhost<\/code> or the Unix socket. Only configure remote database access for a separate host that genuinely needs it, and then restrict the source address and require encryption.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Can I install the stack before I have a domain?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Yes. Apache and the PHP test work with the VPS IP or loopback address. Add the domain later, create a name-based Apache virtual host, and obtain a TLS certificate after DNS points to the server.<\/p>\n\n\n\n<script type=\"application\/ld+json\">{\"@context\": \"https:\/\/schema.org\", \"@type\": \"FAQPage\", \"mainEntity\": [{\"@type\": \"Question\", \"name\": \"Which PHP version does Rocky Linux 10 use?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"Rocky Linux 10\u2019s AppStream repository provides PHP 8.3, with patch updates arriving through normal DNF updates. The exact patch number can change, so the guide checks the installed version rather than pinning one build.\"}}, {\"@type\": \"Question\", \"name\": \"Why does this guide not enable a PHP module stream?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"Rocky Linux 10 follows the EL10 packaging change in which the default PHP version comes directly from AppStream. The older `dnf module enable php:8.3` commands belong to releases that still publish PHP as a module stream.\"}}, {\"@type\": \"Question\", \"name\": \"Should I open MariaDB port 3306 for a PHP website?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"No. A PHP application on the same VPS can connect through `localhost` or the Unix socket. Only configure remote database access for a separate host that genuinely needs it, and then restrict the source address and require encryption.\"}}, {\"@type\": \"Question\", \"name\": \"Can I install the stack before I have a domain?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"Yes. Apache and the PHP test work with the VPS IP or loopback address. Add the domain later, create a name-based Apache virtual host, and obtain a TLS certificate after DNS points to the server.\"}}]}<\/script>\n\n","protected":false},"excerpt":{"rendered":"Install LAMP stack on Rocky Linux 10 with Apache, PHP 8.3, MariaDB, firewalld, and a safe health check for a working VPS in about ten minutes.","protected":false},"author":1,"featured_media":1182,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"csco_singular_sidebar":"","csco_page_header_type":"","csco_page_load_nextpost":"","footnotes":""},"categories":[5,9],"tags":[71,117,73,72,99],"class_list":["post-1181","post","type-post","status-publish","format-standard","has-post-thumbnail","category-guides","category-vps-hosting","tag-apache","tag-lamp-stack","tag-mariadb","tag-php","tag-rocky-linux-10","cs-entry"],"_links":{"self":[{"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/posts\/1181","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/comments?post=1181"}],"version-history":[{"count":1,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/posts\/1181\/revisions"}],"predecessor-version":[{"id":4227,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/posts\/1181\/revisions\/4227"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/media\/1182"}],"wp:attachment":[{"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/media?parent=1181"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/categories?post=1181"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/tags?post=1181"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}