- Install LAMP on a virtual machine
- Install WordPress to the LAMP environment, change the theme.
I’m installing a new virtual machine for this assignment. I’m going to use Mint 17 distribution.
Step 1. Apache
Let’s start with installing Apache web server to our fresh virtual machine.
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install apache2
To check if installation was successful, we can type in “localhost” to our browser’s URL field.
Seems like everything worked out.
To create a website use this path:
/home/LAMP/public_html ##replace LAMP as your computer's name
Create a file called
index.html into the
After this you’ll need to activate the userdir -module in order for your own site to work in browser:
sudo a2enmod userdir
After this restart Apache:
sudo service apache2 restart
Some security configurations might be necessary here. Apache needs to know what to do and what not to do. For this we can look into the configuration file again. Located in
In here you can see a great deal of configuration possibilities in detail. I’m not going to go thorough all them here, but one configuration that is easy to do and improves security a lot is AllowOverride None -setting. This prevents the use of
.htaccess files in all directories apart from those specifically enabled.
Add the following lines to the conf -file inside the directory tags.
One more important security improving step is to setup permission for the ServerRoot directories. The commands vary depending on where you wish to setup ServerRoot, I chose to do as the good folk at Apache do it, and set it up in /usr/ -directory. In most cases, Apache is not started by the root user, so this sort of a solution works better in real life situations.
The commands needed are listed as follows:
mkdir bin conf logs
chown 0 . bin conf logs
chgrp 0 . bin conf logs
chmod 755 . bin conf logs
This will change the permissions settings in the files.
More info on the security tips for Apache can be found here: http://httpd.apache.org/docs/2.2/misc/security_tips.html
Step 2. MySQL
The first two are somewhat setup now from the LAMP acronym. Linux and Apache. Next comes MySQL.
sudo apt-get install mysql-server
Typing out this command will also include necessary extra packages to the installation. I recommend using this, makes your life easier.
During the installation process, the installation wizard will ask for a MySQL root password.
Creating users in MySQL is done as follows. However, as a security tip, mind the permissions here as well.
To create a user, we first need to open up the software as root.
mysql -u root -p
Creating users is done by the
CREATE USER -command. The first problem here is that plain text passwords are a big no-no. As is runnign MySQL as root, but eh.
So, create a user as you wish. For testing purposes I did not encrypt the pw, just went by:
CREATE USER juho IDENTIFIED BY 'password'
Anyway, creating databases is done with:
CREATE DATABASE testdb;
After this, the database has been created. In order to use it we need to grant some permissions, this is done with the following command:
GRANT ALL PRIVILEGES ON testdb.* TO juho@localhost IDENTIFIED BY ‘password';
After this, logging in with the user “juho” should be possible:
mysql -u juho -p testdb;
SHOW DATABASES; should list our testdb.
Step 3. PHP
Install Apache PHP-plugins:
sudo apt-get install libapache2-mod-php5filter
sudo apt-get install libapache2-mod-suphp
index.html -file should be renamed as
After this restart Apache again. The changes should now apply.
I created a small app for demonstration purposes. Here you can see the code:
And here you can see, how it looks like in the browser:
It also works btw:
LAMP is now successfully installed. However, all of the security configurations are not online here.
ERRORS – WORK IN PROGRESS || Installing software to LAMP -environment – WordPress
DigitalOcean has a nice guide on installing WordPress on Ubuntu: https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04
I will follow the guide here and post what I did.
First, let’s login to our MySQL -client and make a database for WordPress:
mysql -u root -p
CREATE DATABASE wordpress;
Let’s make a new account for WordPress:
CREATE USER juhowordpress@localhost IDENTIFIED BY 'password';
Aaaand grant privileges as done already above:
GRANT ALL PRIVILEGES ON wordpress.* TO juhowordpress@localhost;
Exit the MySQL -client and proceed to the next step.
Next we need to download WordPress. What I did was follow the instructions and use these commands:
tar xzvf latest.tar.gz
WordPress directory will be created in your home directory. The instructions recommend downloading a few packages as well. We’ve downloaded a few php- packages while installing and setting up our LAMP -environment, so you may already have these:
sudo apt-get update
sudo apt-get install php5-gd libssh2-php
Configuring WordPress for MySQL
Next, time to configure WordPress. I will just faithfully follow the instructions here and turn the sample file into actual conf- file.
cp wp-config-sample.php wp-config.php
Then, open up a text editor, and make the following changes to you conf-file.
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
/** MySQL database username */
/** MySQL database password */
That should do it, next step!
Copying files to Document Root
Again, following the instructions. Transfer files for /wordpress/ to the /var/www/html/ using
sudo rsync -avP ~/wordpress/ /var/www/html/
Now if we navigate to the /html/ folder, we can see that the WordPress stuff has moved there:
Next, let’s change some permission settings:
sudo chown -R juho:www-data *
We will also need an uploads folder and set permissions to it as well, so run the commands as the instructions say:
sudo chown -R :www-data /var/www/html/wp-content/uploads