Now type in the public IP address of your Ubuntu 17.10 server in the browser address bar. You should see “It works!” Web page, which means Apache Web server is running properly. If you are installing LAMP on your local Ubuntu 17.10 computer, then type 127.0.0.1 or localhost in the browser address bar.

Now we need to set www-data (Apache user) as the owner of document root. By default it’s owned by the root user.

sudo chown www-data:www-data /var/www/html/ -R

Step 3: Install MariaDB Database Server

MariaDB is a drop-in replacement for MySQL. Enter the following command to install it on Ubuntu 17.10.

sudo apt install mariadb-server mariadb-client

After it’s installed, MariaDB server should be automatically stared. Use systemctl to check its status.

When it asks you to enter MariaDB root password, press Enter key as the root password isn’t set yet. Then enter y to set the root password for MariaDB server.

Next, you can press Enter to answer all remaining questions, which will remove anonymous user, disable remote root login and remove test database. This step is a basic requirement for MariaDB database security.

By default, the MaraiDB package on Ubuntu uses unix_socket to authenticate user login, which basically means you can use username and password of the OS to log into MariaDB console. So you can run the following command to login without providing MariaDB root password.

To test PHP scripts with Apache server, we need to create a info.php file in the document root directory.

sudo nano /var/www/html/info.php

Paste the following PHP code into the file.

<?php phpinfo(); ?>

Save and close the file. Now in the browser address bar, enter server-ip-address/info.php. Replace sever-ip-address with your actual IP. If you follow this tutorial on your local computer, then type 127.0.0.1/info.php or localhost/info.php.

You should see your server’s PHP information. This means PHP scripts can run properly with Apache web server.

Congrats! You have successfully installed Apache, MariaDB and PHP7.1 on Ubuntu 17.10. For your server’s security, you should delete info.php file now to prevent prying eyes.

sudo rm /var/www/html/info.php

That’s it! I hope this tutorial helped you install LAMP stack on Ubuntu 17.10. As always, if you found this post useful, then subscribe to our free newsletter to get new tutorials.