In this guide we will go through howto install a basic wordpress site using Minstall to minimize the memory footprint by removing unnecessary services.
I will be using a a OpenVZ vps with 256 mb RAM to show you the steps needed.
Lets start fresh with a reinstall from your provider’s control panel. In this case I choose a 32-bit debian minimal installation.
When the reinstall is ready, log into your vps and as root download Minstall from Github by running this:
1 |
cd ~; rm -rf minstall; mkdir minstall; cd minstall; wget --no-check-certificate -O minstall.tar.gz http://www.github.com/downloads/KnightSwarm/Minstall/Latest.tar.gz; tar zxvf minstall.tar.gz; rm minstall.tar.gz |
Now it’s time to update the sources file, remove all packages that are not needed and install nginx/php/mysql.
Not to forget, since we are cleaning up the installed packages, we will end up without a SSH Daemon so that will also be installed.
There is a post about an Introduction to Minstall, read that if you are interested to know more about what you can do with this script. I will only use the necessary commands here to reach our goal.
Time to clean up the vps some more:
1 |
bash minstall.sh clean-packages |
This will take some time and when it’s done you will see this warning:
1 2 |
All SSH Servers have been uninstalled! Be sure to install an SSH server again using the modules provided (install-dropbear or install-ssh)! Also, it is recommended that you restart your server after installing an SSH server to ensure everything is functional (due to kernel updates and such) and to ensure that all changes are loaded. |
Ok, No SSH Server is installed, lets install Dropbear since it uses less memory then the more common OpenSSHD:
1 |
bash minstall.sh install-dropbear |
Answer (Y)es on all question asked and when the installation is done, connect to your server with another session, just to make sure that you haven’t locked yourself out.
Lets add some extra repositories so we can run the latest PHP version among other things.
1 |
bash minstall.sh install-extra-repositories |
Same thing here again, answer (Y)es on all questions.
Lets add some extra packages which will allow us to use some usefull commands later on.
1 |
bash minstall.sh install-extra-packages |
I think you all know it by know :), answer (Y) on all question asked.
Some general configuration
1 |
bash minstall.sh configure-general |
This time you will need to read (and hopefully understand) all questions asked. Taking that the default option (N)0 on some questions.
Accept the proposed value and set your timezone. Since I’m Swedish, I chose Europe/Stocholm as my time zone.
Why would we set the time zone to our local time zone instead of the time zone where the server is located? Since I have servers all over the world, in my mind it is easier to read logs with my local time in them instead of remembering in what time zone this server is and how is that different from where I am now.
Moving on!
Installing the NginX, MySQL, PHP and Exim
We will install the foundation by running these commands (Using the suggested answer to all presented questions):
1 2 3 4 5 |
bash minstall.sh http-install-nginx bash minstall.sh http-install-php bash minstall.sh http-install-php-extra bash minstall.sh http-install-exim bash minstall.sh http-install-mysql |
When it comes to the last command in the code box above (installing mySQL) you will be promted to set a mySQL root password. Make sure you use a secure password.
INFO: I use Keepass to generate new passwords wherever it’s needed
We need to configure both mySQL and nginX before we are done and as usual, accept the proposed answer to all asked questions.
1 2 |
bash minstall.sh http-configure-mysql bash minstall.sh http-configure-nginx |
Now that we are done with the foundation we are ready to create the first (of many?) wordpress sites on this server.
Adding a user
Every domain or Virtual Host that we want to add to this server needs to be run under a user account, so the first step is to create a user account.
1 |
bash minstall.sh manage-add-user |
In this guide I have decided to call my user: webber1.
When the user is created you will see that a http folder has been created in that users home directory. In that http folder is a hosts folder and this is where all your sites running under this user will be located.
Adding a Virtual Host
Now that we got that sorted, lets add the Virtual Host or domain name that we will be using.
1 |
bash minstall.sh manage-add-host |
The first question you will be asked for when running the above command is: Please enter a user name.
Remember the name of the user we created above? Enter that users name and press Enter.
Next question is, Please enter the virtual host (e.g. www.example.com)
the domain name I use in this example will be u00r.com, so I type that in and press Enter.
Do you want to enable PHP for this virtual host? (Y/n)
We will be running WordPress, so the answer is (Y)es.
Do you want to enable SSL for this virtual host? (Y/n)
Why not, the answer will be (Y)es.
Do you want to set this virtual host as the default host? (y/N)
No, if we decide to add more sites on this server and someone enters the IP of the server, this would be showing. Lets stick with the default nginX page instead. The answer is therefor (N)o.
At this point we can update the domain name on the DNS servers pointing it to this server and we would have a working site. It would not run WordPress at this moment but we will add that in a minute.
Adding a mySQL user and database
As you probably already know, WordPress needs a database to run and we need to create it.
We will do this using mysql-cli, enter this and press Enter. You will be promted for your root mySQL password. Do you remember it from when we installed the mySQL Server above?
1 |
mysql -u root -p |
To create the database we need to think of a name for the database, I have decided to call mine webber1_wpdb.
1 |
create database webber1_wpdb; |
Next step is to create a mySQL user that will be used to access this database.
If you read my previous post about initial wordpress security you will know why I don’t create the user with ALL privileges to the database.
1 |
GRANT SELECT, CREATE, INSERT, UPDATE, DELETE ON webber1_wpdb.* TO sqlwebber1@'localhost' IDENTIFIED BY 'arandomsecurepassword'; |
Almost done, all we need to do is to flush the privileges to make sure they are updated.
1 |
FLUSH PRIVILEGES; |
Now exit the mysql-cli and install WordPress.
1 |
exit |
Installing WordPress
Step one is to change to the Virtual host directory and then su into our newly created user.
1 2 |
cd /home/webber1/http/hosts/u00r.com su webber1 |
Now its time to download the latest version of wordpress and unpack it.
1 2 3 4 |
wget http://wordpress.org/latest.tar.gz tar -zxf latest.tar.gz mv ./wordpress/* ./ rm -rf ./wordpress |
Now open your favourite web browser and enter your domain name in the address field and press enter. Viola! You should now see the first step in configuring your WordPress site.
If you don’t see it, did you remember to update the DNS Server entry for your domain?
Any other errors, post your questions in the comment section and I will try to answer them.
Follow the simple steps presented to you, the important part is to enter the database connection details as we created them earlier.
Look at the screenshot over the connection details and notice that I changed the default table prefix. That is also a recommendation from this post.
You should also use some other username then the default admin. Chose something that is easy for you to remember but noone else would be able to guess.
Also remember to use a strong password for this account.
Finish the wizard and we have only one thing left before we can enjoy our newly installed WordPress and that is to change the Authentication Unique Keys and Salts.
To do that we need to go back to our terminal window and as our Virtual Host user (in my case webber1) edit the wp-config.php file.
1 |
nano wp-config.php |
Find the section about Authentication Unique Keys and Salts and then copy the URL that you find there into your web browser.
This will create random unique phrases for you to use on your installation.
Copy the result from the webpage into your wp-config.php file, OVERWRITING or DELETING the default values.
Tip: You can use CTRL+K to delete a row in nano.
Save and Close with CTRL+X and we are all done!
Log into your wordpress installation and configure it with the templates and plugins you like. Fill it with content that you feel important and last but not least, enjoy being a blogger.
Final words
There we have it, a working WordPress site using Minstall to create the foundation.
If you want to add more sites to this server, perhaps even more WordPress sites, you need to decide if you want to run the new site under the same user as your previous site or not (I recommend that you create a new user for each site).
After that decision is made, all you have to do is to go back in this guide and read the following headings:
- Adding a user
- Adding a Virtual Host
- Adding a mySQL user and database
- Installing WordPress
remember to only use a user/password or database name once. Always use different SECURE passwords.
Thanks for sharing, mate.
One question:
Can we activate friendly URL automatically?
Thanks.
With friendly URL I guess you mean pretty permalinks?
When using nginx and pretty permalinks with wordpress you have to make some changes in your sites config file.
What to update is best described in this post: http://nginxlibrary.com/wordpress-permalinks/
Before reloading your configuration, read the first comment on that post. WordPress has changed since the original post and the correct format is listed in that comment.
Hope it helps you to create a wonderful site!
Hi. Thats an excellent guide. I have recently used Tuxlite script and didnt go with minstall because of its not very clear documentation. But this guide is excellent. I have saved this for future reference. Can you please explain a bit about this command.
cd /home/webber1/http/hosts/u00r.com
su webber1
Shouldnt we first create a /wordpress directory in u00r.com and then run the next wget http://wordpress.org/latest.tar.gz command.
And secondly can you please explain a bit what this command does : mv ./wordpress/* ./ , Does it move the the wordpress to the root of u00r.com in this case or to the root of the user.
I am sorry if my questions appear noob. I am not a Linux expert. Just learning.
When you extract the files downloaded from the WordPress site, the wordpress directory is created.
we then change user to webber1 with the command: su webber1
The mv ./wordpress/* ./ command moves all files from the wordpress sub-directory into the root folder.
You can skip this step if you want to have your blog in a sub-directory. I find it easier to have it in the root directory.
I find your question legitimate, the guide could have explained it better.
I’m having an issue with “bash minstall.sh http-install-mysql” and it said ” mysql-server : Depends: mysql-server-5.5 but it is not going to be installed
E: Unable to correct problems, you have held broken packages.” What could be the issue ? this is on Debian 7
Tried again on Debian 6 and it works fine 🙂
Minstall is not compatible with Debian 7 yet. 🙁
hi i wan ask
how to add subdomain?
example blog.domain.com
where i must extract my old wordpress file?
FYI i succes create subdomain, blog.domain.com i try to open n its works but my old wp not running
thanks
sorry my stupid english
In the section “Adding a Virtual Host” enter your sub-domain instead of the domain name.
That’s pretty much it. You do however need to update your DNS to point to your new sub-domain.
Feel free to ask any questions, I’ll try to answer them all.
thanks bro
one more question
how to direct domain.com to http://www.domain.com
where to replace .htaccess
thank alot
Sorry for the late reply, you will probably have found the solution.
You should edit your nginx conf file for your site. The conf files for your sites are located in /etc/nginx/hosts.d/ and are named according to the sitename you set when creating the website with MINSTALL.
in the server section add something like this :
server {
server_name domain.com;
return 301 $scheme://www.domain.com$request_uri;
}
You need to have a config file for your http://www.domain.com also, this can be the same conf file that you are editing.
just change the server_name parameter to :
server_name www.domain.com domain.com
and it will reply to either one. If you also add this part
return 301 $scheme://www.domain.com$request_uri;
you will always redirect to http://www.domain.com and serve your pages.HOpe this reply helps you out somewhat.
one more, i want install phpmyadmin
but file one /etc/nginx/sites-available/default not exists,
where I can add syntax like this tutorial
hxxp://www.debian-tutorials.com/how-to-run-phpmyadmin-on-nginx#more-2872
thanks 😀
all sites config files are here: /etc/nginx/hosts.d/
After installing this i am unable to use openVPN using this tutorial:
http://yaui.me/how-to-set-up-openvpn-in-30-seconds-or-less/
Any help?
Oh! sorry please delete the above and this, i had to reenable TUN/TAP from solus to get it working,
Sometimes Solus acts up and even if you click enable it isn’t enabled.
After few hours of trial and error i was able to get moodle 2.6 working on this script using only one hack:
https://moodle.org/mod/forum/discuss.php?d=234656
i get an error using this, when trying to install on a LES box,
# bash minstall.sh http-configure-mysql
>> HTTP Configure: MySQL Database Server <<
This module requires the mysql-server package to be installed, please install it using the http-install-mysql module and try again!
root@nl2:~/minstall#
even thou i just ran the script to install MySQL, thou it did not ask to set up a sql password…
this is on a fresh server.
Did you get the latest version of minstall?
I never got that working properly on debian 7. Never tried it on on debian 7.5, guess it would feturn the same result.
Max also said that he has very little time to develop the script even more, which is sad because I really liked it.
I’ve been trying tuxlite ( http://www.tuxlite.com ) lately and used it to build the LowendSpirit wiki. ( wiki.lowendguide.com ).
Will write a few words about tuxlite in a later guide.