Using Linux and the web server sometimes have to read a lot of tutorials and step-by-step. I can not memorize one by one. So, I wanted to make this post useful for the newbie who wants to create a server with linux.
What is needed is
- Ubuntu 14.04 or above
- Internet connection
This tutorial will discuss
- How to install PHP, MySQLand Apache2 and seting it up
- How to change webroot location to your home directory or where you want
- Install phpmyadmin
- Install wordpress
Ok, lets begin. Open your terminal and get into step one
Install Apache2
Use this command and enter
sudo apt-get update
sudo apt-get install apache2
Install MySQL
sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql
You will get prompt to setting up database. Fill password and enter. Its simple
Install PHP
sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt
After this step your server is ready to battle. Your webroot directory in /var/www/html/
Try to open localhost in your browser. Ok, let go to step two.
Change Webroot Directory
Maybe some of you want to change the webroot directory so as not to touch your linux system. The most convenient way is to move the webroot to your home directory, eg /home/dono/www
We will try to make this easier. There are 2 files that you must change.
- file apache2.conf dengan alamat /etc/apache2/apache2.conf
- file ooo-default.conf dengan alamat /etc/apache2/sites-available/000-default.conf
Edit Apache2.conf
sudo gedit /etc/apache2/apache2.conf
Search this code lines
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
And change as look like this
<Directory /home/dono/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
Save and done
Edit ooo-default.conf
sudo gedit /etc/apache2/sites-available/000-default.conf
And search this line
DocumentRoot /var/www/ and change to DocumentRoot /home/dono/www
Then save.
Fix permission
sudo chmod -R 777 www-data:www-data /home/dono/www
Dont forget to restart your server with this command
sudo service apache2 restart
Install PHPMyAdmin
Ok, just use this command
sudo apt-get install phpmyadmin apache2-utils
You will get prompt to setting your PHPMYadmin configuration. Its simple. Dont forget to include PHPMyAdmin config file to apache config file, in order you can access phpmyadmin with simple URL like this
http://localhost/phpmyadmin
sudo gedit /etc/apache2/apache2.conf
then add this code in apache2.conf file (in below)
Include /etc/phpmyadmin/apache.conf
Then save. Done
Install WordPress
Install wordpress is very simple step. We use wget to downlaod wordpress file
cd /home/dono/www
wget http://wordpress.org/latest.zip
unzip latest.zip
Then install wordpress by http://localhost/wordpress.
Bonus : Fix WordPress Ask FTP account
Sometimes when you want to install a plugin or theme, wordpress ask FTP username and password. Actually, this is not necessary. All you have to do is with a few lines of code to fix this.
sudo chown -hR www-data:www-data /home/dono/www/wordpress
Thanks to narga.net for provide this tricks
That is a short tutorial for setting up a linux server and installing wordpress. I wrote this tutorial to remind myself and help friends all