{"id":16435,"date":"2024-11-01T10:15:05","date_gmt":"2024-11-01T10:15:05","guid":{"rendered":"https:\/\/truehost.com\/support\/?post_type=docs&#038;p=16435"},"modified":"2024-11-01T12:12:12","modified_gmt":"2024-11-01T12:12:12","password":"","slug":"setting-up-a-lamp-stack-linux-apache-mysql-php-on-ubuntu","status":"publish","type":"docs","link":"https:\/\/truehost.com\/support\/knowledge-base\/setting-up-a-lamp-stack-linux-apache-mysql-php-on-ubuntu\/","title":{"rendered":"Setting Up a LAMP Stack (Linux, Apache, MySQL, PHP) on Ubuntu"},"content":{"rendered":"\n<p>The LAMP stack (Linux, Apache, MySQL, PHP) is a collection of software used to serve dynamic web pages and PHP applications.<\/p>\n\n\n\n<p>It consists of a Linux operating system, the Apache web server, a MySQL database for data storage, and PHP for handling dynamic content.<\/p>\n\n\n\n<p>This guide will walk you through setting up a LAMP stack on a server running Ubuntu 22.04. With Ubuntu managing the Linux component, we\u2019ll cover how to configure each of the remaining parts of the stack.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A server with Ubuntu installed. I will use Ubuntu 22.04<\/li>\n\n\n\n<li>A user account with admin or sudo access<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1: Installing the Apache Web Server<\/h2>\n\n\n\n<p>Apache is a popular, efficient web server that we&#8217;ll use to serve pages to our visitors. Begin by updating your server\u2019s package index:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"877\" height=\"107\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image.png\" alt=\"\" class=\"wp-image-16383\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image.png 877w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-300x37.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-768x94.png 768w\" sizes=\"auto, (max-width: 877px) 100vw, 877px\" \/><\/figure>\n\n\n\n<p>Then install apache:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install apache2 -y<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"333\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-24-1024x333.png\" alt=\"\" class=\"wp-image-16442\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-24-1024x333.png 1024w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-24-300x98.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-24-768x250.png 768w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-24.png 1215w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Check if Apache installed correctly by checking the Apache service status:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo service apache2 status<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"334\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-25-1024x334.png\" alt=\"\" class=\"wp-image-16443\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-25-1024x334.png 1024w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-25-300x98.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-25-768x251.png 768w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-25.png 1042w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Allowing Apache Through the Firewall<\/strong><\/h4>\n\n\n\n<p>If you\u2019re using UFW (Uncomplicated Firewall), you\u2019ll need to allow HTTP traffic through it. Check available UFW application profiles with:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo ufw app list<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"891\" height=\"120\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-27.png\" alt=\"\" class=\"wp-image-16445\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-27.png 891w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-27-300x40.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-27-768x103.png 768w\" sizes=\"auto, (max-width: 891px) 100vw, 891px\" \/><\/figure>\n\n\n\n<p>Ensure the&nbsp;<strong>Apache Full<\/strong>&nbsp;profile allows the traffic on ports&nbsp;<strong>80<\/strong>&nbsp;and&nbsp;<strong>443<\/strong>&nbsp;by running the command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo ufw app info \"Apache Full\"<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"945\" height=\"185\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-28.png\" alt=\"\" class=\"wp-image-16446\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-28.png 945w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-28-300x59.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-28-768x150.png 768w\" sizes=\"auto, (max-width: 945px) 100vw, 945px\" \/><\/figure>\n\n\n\n<p>To verify that Apache is running, open your server\u2019s public IP or domain in a web browser. If unsure about your public IP, run one of the following commands to see it.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ip addr show\n\nhostname -I<\/code><\/pre>\n\n\n\n<p>In your browser, navigate to:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>http:&#47;&#47;server_domain_or_ip_address<\/code><\/pre>\n\n\n\n<p>This should display the Apache default landing page.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"743\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-29-1024x743.png\" alt=\"\" class=\"wp-image-16447\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-29-1024x743.png 1024w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-29-300x218.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-29-768x558.png 768w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-29.png 1270w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2: Installing MySQL<\/h2>\n\n\n\n<p>With Apache installed, we\u2019ll move on to installing MySQL, which will manage and store site data.<\/p>\n\n\n\n<p>You can also use MariaDB. Please refer to <strong><a href=\"https:\/\/truehost.com\/support\/knowledge-base\/how-to-install-mariadb-on-ubuntu-22-04\/\" target=\"_blank\" rel=\"noreferrer noopener\">these steps<\/a><\/strong> on how to install MariaDB database on Ubuntu <\/p>\n\n\n\n<p>For MySQL, run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install mysql-server -y<\/code><\/pre>\n\n\n\n<p>After installing MySQL, it is a good idea to run a security script included with it<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mysql_secure_installation<\/code><\/pre>\n\n\n\n<p>You\u2019ll be prompted to configure the VALIDATE PASSWORD PLUGIN\u2014type Y for yes or any other key to continue without enabling it.<\/p>\n\n\n\n<p>If you select \u201cyes,\u201d you\u2019ll be prompted to choose a level of password validation. I prefer that you choose level 1. <\/p>\n\n\n\n<p>It is fine to select yes fort he rest of the prompts, but then you can also choose differently according to your preference.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"627\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-5.png\" alt=\"\" class=\"wp-image-16394\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-5.png 800w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-5-300x235.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-5-768x602.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/figure>\n\n\n\n<p>Once done, check if you can log in to the MySQL console:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mysql<\/code><\/pre>\n\n\n\n<p>This command connects to the MySQL server using the administrative database user root, indicated by sudo. The expected output is as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"909\" height=\"262\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-4.png\" alt=\"\" class=\"wp-image-16392\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-4.png 909w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-4-300x86.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-4-768x221.png 768w\" sizes=\"auto, (max-width: 909px) 100vw, 909px\" \/><\/figure>\n\n\n\n<p>You may then run the command below to exit the console;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>exit<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"635\" height=\"114\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-6.png\" alt=\"\" class=\"wp-image-16395\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-6.png 635w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-6-300x54.png 300w\" sizes=\"auto, (max-width: 635px) 100vw, 635px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3: Installing PHP<\/h2>\n\n\n\n<p>Next, install PHP to generate dynamic content. Apache uses <strong>PHP-FPM<\/strong> (FastCGI Process Manager) for this purpose. Install PHP and the PHP MySQL extension with:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install php libapache2-mod-php php-mysql -y<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4: Configuring Apache to Use PHP<\/h2>\n\n\n\n<p>We\u2019ll configure apache to handle PHP requests. By default, Apache uses the directory <code>\/var\/www\/html<\/code> for its root web directory. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo vi \/etc\/apache2\/mods-enabled\/dir.conf<\/code><\/pre>\n\n\n\n<p>Modify the line so index.php is first:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;IfModule mod_dir.c&gt;\n    DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm\n&lt;\/IfModule&gt;<\/code><\/pre>\n\n\n\n<p>Also, we\u2019ll create a new directory for our website and set up a configuration file.<\/p>\n\n\n\n<p>In the steps below, remember to replace <em>your_domain<\/em> with your actual domain or subdomain. I will use <em>doll.tke.co.ke<\/em><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Create the web root directory:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mkdir \/var\/www\/<em>doll.tke.co.ke<\/em><\/code><\/pre>\n\n\n\n<p>   2. Assign ownership of the directory to the current user:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo chown -R $USER:$USER \/var\/www\/<em>doll.tke.co.ke<\/em><\/code><\/pre>\n\n\n\n<p>   3. Open a new configuration file in the <strong>sites-available<\/strong> directory:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo vi \/etc\/apache2\/sites-available\/<em>doll.tke.co.ke<\/em>.conf<\/code><\/pre>\n\n\n\n<p>  4. Add the following configuration:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;VirtualHost *:80&gt;\n    ServerName doll.tke.co.ke\n    ServerAlias www.doll.tke.co.ke\n    DocumentRoot \/var\/www\/your_domain\n\n    &lt;Directory \/var\/www\/your_domain&gt;\n        Options Indexes FollowSymLinks\n        AllowOverride All\n        Require all granted\n    &lt;\/Directory&gt;\n\n    DirectoryIndex index.php index.html index.htm\n\n    ErrorLog ${APACHE_LOG_DIR}\/error.log\n    CustomLog ${APACHE_LOG_DIR}\/access.log combined\n\n    &lt;FilesMatch \"\\.php$\"&gt;\n        SetHandler application\/x-httpd-php\n    &lt;\/FilesMatch&gt;\n\n    # Deny access to .htaccess files\n    &lt;FilesMatch \"^\\.ht\"&gt;\n        Require all denied\n    &lt;\/FilesMatch&gt;\n&lt;\/VirtualHost&gt;\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"439\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-33-1024x439.png\" alt=\"\" class=\"wp-image-16459\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-33-1024x439.png 1024w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-33-300x129.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-33-768x329.png 768w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-33.png 1176w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Below is what each of the directives do<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>ServerName and ServerAlias<\/strong>: Define the domain names for this virtual host.<\/li>\n\n\n\n<li><strong>DocumentRoot<\/strong>: Points to the directory where your website files are stored.<\/li>\n\n\n\n<li><strong>Directory Directive<\/strong>: Sets permissions for the document root.<\/li>\n\n\n\n<li><strong>DirectoryIndex<\/strong>: Specifies which files to serve when a directory is requested.<\/li>\n\n\n\n<li><strong>ErrorLog and CustomLog<\/strong>: Directives to log errors and access requests.<\/li>\n\n\n\n<li><strong>FilesMatch<\/strong>: Applies a handler for PHP files.<\/li>\n\n\n\n<li><strong>Deny access to .htaccess files<\/strong>: Prevents access to <code>.ht<\/code> files for security.<\/li>\n<\/ul>\n\n\n\n<p>5. Save and close the file (in <strong>vi<\/strong>, press <strong>Esc<\/strong>, type <code>:wq<\/code>, and press <strong>Enter<\/strong>).<\/p>\n\n\n\n<p>6. Enable your configuration by running the following command<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo a2ensite doll.tke.co.ke.conf\n\nsudo ln -s \/etc\/apache2\/sites-available\/<em>doll.tke.co.ke<\/em>.conf \/etc\/apache2\/sites-enabled\/<\/code><\/pre>\n\n\n\n<p>7. Unlink the default configuration:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo a2dissite 000-default.conf<\/code><\/pre>\n\n\n\n<p>8.  Test your configuration for syntax errors:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apachectl configtest<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"98\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-31-1024x98.png\" alt=\"\" class=\"wp-image-16457\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-31-1024x98.png 1024w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-31-300x29.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-31-768x73.png 768w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-31.png 1245w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>9. Restart Apache to apply the changes:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart apache2<\/code><\/pre>\n\n\n\n<p>10. Add a sample <strong>index.html<\/strong> file to verify that your new server block works:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vi \/var\/www\/<em>doll.tke.co.ke<\/em>\/index.html<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"797\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-9-1024x797.png\" alt=\"\" class=\"wp-image-16400\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-9-1024x797.png 1024w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-9-300x234.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-9-768x598.png 768w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-9.png 1246w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>11. Visit <code>http:\/\/<em>doll.tke.co.ke<\/em><\/code> in your browser to confirm.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"702\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-10-1024x702.png\" alt=\"\" class=\"wp-image-16401\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-10-1024x702.png 1024w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-10-300x206.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-10-768x526.png 768w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-10.png 1261w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Step 5: Testing PHP with Apache<\/h2>\n\n\n\n<p>To test PHP, create a file called <strong>info.php<\/strong> in your document root:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vi \/var\/www\/<em>doll.tke.co.ke<\/em>\/info.php<\/code><\/pre>\n\n\n\n<p>Add the following code:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\nphpinfo();\n?&gt;<\/code><\/pre>\n\n\n\n<p>Access this page by navigating to:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>http:\/\/<em>doll.tke.co.ke<\/em>\/info.php<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"590\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-11-1024x590.png\" alt=\"\" class=\"wp-image-16403\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-11-1024x590.png 1024w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-11-300x173.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-11-768x443.png 768w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-11.png 1275w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>After confirming, delete the file to avoid exposing sensitive information:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo rm \/var\/www\/<em>doll.tke.co.ke<\/em>\/info.php<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 6: Testing Database Connection from PHP<\/h2>\n\n\n\n<p>Create a test database and user in MySQL:<\/p>\n\n\n\n<p><strong>Log in to MySQL:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mysql<\/code><\/pre>\n\n\n\n<p><strong>Create a new database:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Replace test_db with your preferred database name<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>CREATE DATABASE test_db;<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"850\" height=\"54\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-14.png\" alt=\"\" class=\"wp-image-16409\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-14.png 850w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-14-300x19.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-14-768x49.png 768w\" sizes=\"auto, (max-width: 850px) 100vw, 850px\" \/><\/figure>\n\n\n\n<p><strong>Add a new user:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Replace test_user with your preferred user name<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>CREATE USER 'test_user'@'%' IDENTIFIED WITH mysql_native_password BY 'password';<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"893\" height=\"44\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-13.png\" alt=\"\" class=\"wp-image-16408\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-13.png 893w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-13-300x15.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-13-768x38.png 768w\" sizes=\"auto, (max-width: 893px) 100vw, 893px\" \/><\/figure>\n\n\n\n<p><strong>Note:<br><\/strong>When running the command you may get this error ERROR 1819 (HY000): Your password does not satisfy the current policy requirements<br>In that case, just ensure that your password has a mixture of special characters, numbers, uppercase and lowercase characters, then re-run it.<\/p>\n\n\n\n<p><strong>Grant the user privileges on the new database:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GRANT ALL ON test_db.* TO 'test_user'@'%';<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"552\" height=\"102\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-12.png\" alt=\"\" class=\"wp-image-16406\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-12.png 552w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-12-300x55.png 300w\" sizes=\"auto, (max-width: 552px) 100vw, 552px\" \/><\/figure>\n\n\n\n<p><strong>Exit MySQL:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>exit<\/code><\/pre>\n\n\n\n<p>To confirm that the new user has the correct permissions, log into the MySQL console again using the custom user credentials. <\/p>\n\n\n\n<p>Be sure to include the <code>-p<\/code> flag in the command, as it will prompt for the password set when creating the &#8220;test_user&#8221; user.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql -u test_user -p<\/code><\/pre>\n\n\n\n<p>Enter your password and confirm to access test_DB.<\/p>\n\n\n\n<p>You can then check the databases available;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SHOW DATABASES;<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"433\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-15-1024x433.png\" alt=\"\" class=\"wp-image-16412\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-15-1024x433.png 1024w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-15-300x127.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-15-768x325.png 768w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-15.png 1093w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Let\u2019s now create a test table named \u201c<strong>tech_list<\/strong>.\u201d Execute the following statement from the MySQL console:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CREATE TABLE test_db.tech_list (tech_id INT AUTO_INCREMENT,technology VARCHAR(255),PRIMARY KEY(tech_id));<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"187\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-16-1024x187.png\" alt=\"\" class=\"wp-image-16413\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-16-1024x187.png 1024w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-16-300x55.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-16-768x140.png 768w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-16.png 1081w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>You may now insert values into the table by running multiple inatances of the command below<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>INSERT INTO test_db.tech_list (technology) VALUES (\"IOT\");\nINSERT INTO test_db.tech_list (technology) VALUES (\"Cloud\");\nINSERT INTO test_db.tech_list (technology) VALUES (\"DevOPs\");\nINSERT INTO test_db.tech_list (technology) VALUES (\"ML\");\nINSERT INTO test_db.tech_list (technology) VALUES (\"Networking\");<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"258\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-17-1024x258.png\" alt=\"\" class=\"wp-image-16414\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-17-1024x258.png 1024w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-17-300x76.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-17-768x194.png 768w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-17.png 1213w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>You could  check the entries using the command below;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT * FROM test_db.tech_list;<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"1009\" height=\"256\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-18.png\" alt=\"\" class=\"wp-image-16419\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-18.png 1009w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-18-300x76.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-18-768x195.png 768w\" sizes=\"auto, (max-width: 1009px) 100vw, 1009px\" \/><\/figure>\n\n\n\n<p>You may exit the MySQL console using the <strong>exit<\/strong> command.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Test MySQL Connection<\/h2>\n\n\n\n<p>To test, create a PHP script to connect to MySQL:<\/p>\n\n\n\n<p>Open a file called <strong>testlist.php<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vi \/var\/www\/doll.tke.co.ke\/testlist.php<\/code><\/pre>\n\n\n\n<p>Add PHP code to connect and query. In the code below, remember to replace the <strong>dummy database <\/strong>details with <strong>your own<\/strong>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n$conn = new mysqli(\"localhost\", \"test_user\", \"password\", \"test_db\");\n\nif ($conn-&gt;connect_error) {\n    die(\"Connection failed: \" . $conn-&gt;connect_error);\n}\n\n$sql = \"SELECT * FROM tech_list\";\n$result = $conn-&gt;query($sql);\n\nif ($result-&gt;num_rows &gt; 0) {\n    while($row = $result-&gt;fetch_assoc()) {\n        echo $row&#91;\"tech_id\"] . \": Technology: \" . $row&#91;\"technology\"] . \"&lt;br&gt;\";\n    }\n} else {\n    echo \"0 results\";\n}\n\n$conn-&gt;close();\n?&gt;\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"965\" height=\"373\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-21.png\" alt=\"\" class=\"wp-image-16422\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-21.png 965w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-21-300x116.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-21-768x297.png 768w\" sizes=\"auto, (max-width: 965px) 100vw, 965px\" \/><\/figure>\n\n\n\n<p>Access this script:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>http:&#47;&#47;doll.tke.co.ke\/testlist.php<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"1008\" height=\"366\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-22.png\" alt=\"\" class=\"wp-image-16423\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-22.png 1008w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-22-300x109.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/image-22-768x279.png 768w\" sizes=\"auto, (max-width: 1008px) 100vw, 1008px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Author&#8217;s final word<\/h2>\n\n\n\n<p>Congratulations! You\u2019ve successfully set up a LAMP stack on Ubuntu 20.04, creating a powerful foundation to host PHP-based applications. This configuration, combining Apache and MySQL, is optimized for speed and security in dynamic web hosting environments.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The LAMP stack (Linux, Apache, MySQL, PHP) is a collection of software used to serve dynamic web pages and PHP applications. It consists of a Linux operating system, the Apache web server, a MySQL database for data storage, and PHP for handling dynamic content. This guide will walk you through setting up a LAMP stack [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":16495,"comment_status":"open","ping_status":"closed","template":"","meta":{"_eb_attr":"","_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"doc_category":[1820,1824,1879,2128],"doc_tag":[],"class_list":["post-16435","docs","type-docs","status-publish","has-post-thumbnail","hentry","doc_category-cloud-servers-in-kenya","doc_category-dedicated-servers","doc_category-servers","doc_category-vps-servers"],"year_month":"2026-06","word_count":1454,"total_views":0,"reactions":{"happy":0,"normal":0,"sad":0},"author_info":{"name":"Eugene","author_nicename":"eugene","author_url":"https:\/\/truehost.com\/support\/author\/eugene\/"},"doc_category_info":[{"term_name":"Cloud servers in Kenya","term_url":"https:\/\/truehost.com\/support\/docs-category\/cloud-servers-in-kenya\/"},{"term_name":"dedicated servers","term_url":"https:\/\/truehost.com\/support\/docs-category\/dedicated-servers\/"},{"term_name":"Servers","term_url":"https:\/\/truehost.com\/support\/docs-category\/servers\/"},{"term_name":"VPS-Servers","term_url":"https:\/\/truehost.com\/support\/docs-category\/vps-servers\/"}],"doc_tag_info":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Setting Up a LAMP Stack (Linux, Apache, MySQL, PHP) on Ubuntu -<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.truehost.com\/support\/knowledge-base\/setting-up-a-lamp-stack-linux-apache-mysql-php-on-ubuntu\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Setting Up a LAMP Stack (Linux, Apache, MySQL, PHP) on Ubuntu -\" \/>\n<meta property=\"og:description\" content=\"The LAMP stack (Linux, Apache, MySQL, PHP) is a collection of software used to serve dynamic web pages and PHP applications. It consists of a Linux operating system, the Apache web server, a MySQL database for data storage, and PHP for handling dynamic content. This guide will walk you through setting up a LAMP stack [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.truehost.com\/support\/knowledge-base\/setting-up-a-lamp-stack-linux-apache-mysql-php-on-ubuntu\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T12:12:12+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.truehost.com\/support\/wp-content\/uploads\/2024\/11\/apache.jpeg\" \/>\n\t<meta property=\"og:image:width\" content=\"448\" \/>\n\t<meta property=\"og:image:height\" content=\"346\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/knowledge-base\\\/setting-up-a-lamp-stack-linux-apache-mysql-php-on-ubuntu\\\/\",\"url\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/knowledge-base\\\/setting-up-a-lamp-stack-linux-apache-mysql-php-on-ubuntu\\\/\",\"name\":\"Setting Up a LAMP Stack (Linux, Apache, MySQL, PHP) on Ubuntu -\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/knowledge-base\\\/setting-up-a-lamp-stack-linux-apache-mysql-php-on-ubuntu\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/knowledge-base\\\/setting-up-a-lamp-stack-linux-apache-mysql-php-on-ubuntu\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2024\\\/11\\\/apache.jpeg\",\"datePublished\":\"2024-11-01T10:15:05+00:00\",\"dateModified\":\"2024-11-01T12:12:12+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/knowledge-base\\\/setting-up-a-lamp-stack-linux-apache-mysql-php-on-ubuntu\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.truehost.com\\\/support\\\/knowledge-base\\\/setting-up-a-lamp-stack-linux-apache-mysql-php-on-ubuntu\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/knowledge-base\\\/setting-up-a-lamp-stack-linux-apache-mysql-php-on-ubuntu\\\/#primaryimage\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2024\\\/11\\\/apache.jpeg\",\"contentUrl\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2024\\\/11\\\/apache.jpeg\",\"width\":448,\"height\":346},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/knowledge-base\\\/setting-up-a-lamp-stack-linux-apache-mysql-php-on-ubuntu\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/truehost.com\\\/support\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Setting Up a LAMP Stack (Linux, Apache, MySQL, PHP) on Ubuntu\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#website\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/\",\"name\":\"\",\"description\":\"Help In a Click\",\"publisher\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/truehost.com\\\/support\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#organization\",\"name\":\"Truehost Kenya\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/cropped-image_2026-04-16_174808866.png\",\"contentUrl\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/cropped-image_2026-04-16_174808866.png\",\"width\":240,\"height\":48,\"caption\":\"Truehost Kenya\"},\"image\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#\\\/schema\\\/logo\\\/image\\\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Setting Up a LAMP Stack (Linux, Apache, MySQL, PHP) on Ubuntu -","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.truehost.com\/support\/knowledge-base\/setting-up-a-lamp-stack-linux-apache-mysql-php-on-ubuntu\/","og_locale":"en_US","og_type":"article","og_title":"Setting Up a LAMP Stack (Linux, Apache, MySQL, PHP) on Ubuntu -","og_description":"The LAMP stack (Linux, Apache, MySQL, PHP) is a collection of software used to serve dynamic web pages and PHP applications. It consists of a Linux operating system, the Apache web server, a MySQL database for data storage, and PHP for handling dynamic content. This guide will walk you through setting up a LAMP stack [&hellip;]","og_url":"https:\/\/www.truehost.com\/support\/knowledge-base\/setting-up-a-lamp-stack-linux-apache-mysql-php-on-ubuntu\/","article_modified_time":"2024-11-01T12:12:12+00:00","og_image":[{"width":448,"height":346,"url":"https:\/\/www.truehost.com\/support\/wp-content\/uploads\/2024\/11\/apache.jpeg","type":"image\/jpeg"}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.truehost.com\/support\/knowledge-base\/setting-up-a-lamp-stack-linux-apache-mysql-php-on-ubuntu\/","url":"https:\/\/www.truehost.com\/support\/knowledge-base\/setting-up-a-lamp-stack-linux-apache-mysql-php-on-ubuntu\/","name":"Setting Up a LAMP Stack (Linux, Apache, MySQL, PHP) on Ubuntu -","isPartOf":{"@id":"https:\/\/truehost.com\/support\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.truehost.com\/support\/knowledge-base\/setting-up-a-lamp-stack-linux-apache-mysql-php-on-ubuntu\/#primaryimage"},"image":{"@id":"https:\/\/www.truehost.com\/support\/knowledge-base\/setting-up-a-lamp-stack-linux-apache-mysql-php-on-ubuntu\/#primaryimage"},"thumbnailUrl":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/apache.jpeg","datePublished":"2024-11-01T10:15:05+00:00","dateModified":"2024-11-01T12:12:12+00:00","breadcrumb":{"@id":"https:\/\/www.truehost.com\/support\/knowledge-base\/setting-up-a-lamp-stack-linux-apache-mysql-php-on-ubuntu\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.truehost.com\/support\/knowledge-base\/setting-up-a-lamp-stack-linux-apache-mysql-php-on-ubuntu\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.truehost.com\/support\/knowledge-base\/setting-up-a-lamp-stack-linux-apache-mysql-php-on-ubuntu\/#primaryimage","url":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/apache.jpeg","contentUrl":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/11\/apache.jpeg","width":448,"height":346},{"@type":"BreadcrumbList","@id":"https:\/\/www.truehost.com\/support\/knowledge-base\/setting-up-a-lamp-stack-linux-apache-mysql-php-on-ubuntu\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/truehost.com\/support\/"},{"@type":"ListItem","position":2,"name":"Setting Up a LAMP Stack (Linux, Apache, MySQL, PHP) on Ubuntu"}]},{"@type":"WebSite","@id":"https:\/\/truehost.com\/support\/#website","url":"https:\/\/truehost.com\/support\/","name":"","description":"Help In a Click","publisher":{"@id":"https:\/\/truehost.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/truehost.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/truehost.com\/support\/#organization","name":"Truehost Kenya","url":"https:\/\/truehost.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/truehost.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2026\/04\/cropped-image_2026-04-16_174808866.png","contentUrl":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2026\/04\/cropped-image_2026-04-16_174808866.png","width":240,"height":48,"caption":"Truehost Kenya"},"image":{"@id":"https:\/\/truehost.com\/support\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/16435","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/comments?post=16435"}],"version-history":[{"count":16,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/16435\/revisions"}],"predecessor-version":[{"id":16493,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/16435\/revisions\/16493"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/media\/16495"}],"wp:attachment":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/media?parent=16435"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/doc_category?post=16435"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/doc_tag?post=16435"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}