Well this post is for anyone setting up virtual servers with Debian and I also need to remind myself how to do it because its not something you do everyday and I quite like using Linux.
So here we go how to setup wordpress on Debian LAMP server
WordPress install on a debian LAMP server
- Open a terminal application
- Enter command:
su
enter the root password- Enter Command:
apt-get update -y && sudo apt-get upgrade –y- Enter command:
apt-get install wordpress –y- Enter command:
nano /etc/wordpress/htaccess- Update the text as follows:
- Uncomment these two lines by removing the hash symbol:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /- Add these 2 lines:
RewriteCond %{HTTP_HOST} ^www.(.+) [NC]
RewriteRule ^.*$ http://%1%{REQUEST_URI} [QSA,R=301,L]- Uncomment these 4 lines:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</ifModule>- Save the file by pressing CTRL+O, then accepting the filename by pressing Enter
- Exit nano by pressing CTRL+Z, you will be returned to the command prompt
- To setup apache, use nano to edit this file: /etc/apache2/sites-available/[your domain name]
e.g. if your site is called prawnsalad.com, type this command, followed by Enter:
nano /etc/apache2/sites-available/prawnsalad.com- Paste this text into your new file, but change the ip and email address and domain name:
<VirtualHost 192.168.1.2:80>
ServerName prawnsalad.com
ServerAdmin me@example.com
DocumentRoot /var/www/prawnsalad.com
DirectoryIndex index.php
<Directory /var/www/prawnsalad.com>
AllowOverride All
Order Deny,Allow
Allow from all
</Directory>
</VirtualHost>- Save the file and exit nano
- Create another file in nano with the same content as before but add the www. In front of your domain name in the “Server name” line. name the file: “/etc/apache2/sites-available/www.prawnsalad.com” remember to change the file name to match your domain name.
- Now create a link (shortcut) from your www directory to your wordpress files which are in a different directory. Enter these commands:
cd /var/www/
ln -s /usr/share/wordpress prawnsalad.com- Now instruct apache to use these 2 new sites you have created. Enter these commands:
a2ensite www.prawnsalad.com
a2ensite prawnsalad.com
/etc/init.d/apache2 restart
on some systems to restart apache, you may need this command instead:
service apache2 restart- Next we need to setup the wordpress database, change directory to:
cd /usr/share/doc/wordpress/examples/
then run the setup-mysql script by entering this command:
bash ./setup-mysql –n prawnsalad prawnsalad.com
the first variable is the mysql database name followed by the domain name- Now open a browser on the debian server and browse to http://prawnsalad.com/wordpress to setup wordpress
If you have not yet pointed your domain name at your server, you may need to add/update an entry in your server’s hosts file by following these steps:
- Open Terminal
- Enter this command to raise your privileges to root:
su
enter password when prompted- Enter this command to open the hosts file for editing:
nano /etc/hosts- Find the line that reads “127.0.0.1 localhost”. Move your cursor to the end of that line and add a space, then type your domain name. e.g.
127.0.0.1 localhost prawnsalad.com- Save by pressing CTRL+O, press the Y key to confirm overwriting the file
- To exit nano, press CTRL+Z
- Now browse to your domain name and you should land on the local server.
Hope all goes well