How to create a local server for running php scripts in your Ubuntu machine?


Step 1: Open Terminal.

Step 2: Type exactly the same thing as mentioned below:
$ sudo apt-get install mysql-client mysql-server apache php php5-mysql phpmyadmin php5-gd

Follow the terminal instructions, as this command will download and install the required packages.

Step 3: Make sure that you are currently in the Home directory of your current profile, if not, change the current directory to your Home directory. Then type:
$ mkdir www

This will create a new folder under your Home directory called “www”.

Step 4: Type:
$ sudo ln -s /home/yourusername/www /var/www/yourusername

Step 5: Type:
$ echo "<h1>Hello World! Local server is online!! :-) </h1>" > www/index.html

This will print the sentence “Hello World! Local server is online!! :-)” is a file named “index.html”, which is the default index page of the local server that you are going to use from your current account in which you are logged in.

Step 6: Type:
$ sudo ln -s /usr/share/phpmyadmin /var/www/phpmyadmin

Step 7: Type:
$ sudo /etc/init.d/apache2 restart

This command restarts the apache2 software that has been installed just now.

Step 7: Type:
$ sudo /etc/init.d/mysql restart

This command restarts the mysql software that has been installed just now.

Step 8: Now go to your web browser and type:

This shows you the default page of the installed local server.


This shows you the default page of the local server that you are using from the account from which you are currently logged in.

Type:

This shows you the login page of the phpMyAdmin. The default username is “root” (without the inverted-commas) and the password is the one which you provided while installing phpMyAdmin in the Terminal.


That's it!! This is how you can create your own local server in your ubuntu based Linux machine.

Comments