Creating a web site on LAMP environment (Linux Apache MySQL PHP)



Creating a web site on LAMP environment (Linux Apache MySQL PHP)

Hi guys,

I am using Zend studio as my development environment and I would like to show you how to configure your local environment to run a web site on your local machine. I assume you have install Apache as web server, php and mysql on your machine. ;) oky here we go....

First of all create your php project in your local path. On may computer my path is /home/asoka/Zend/workspaces/Defaultworkspaces/testwebsite

now add a index.php file and add below code in the file . Echo “Hi.. my test web site is working....” . Now the index.php page should looks like below.

echo “Hi.. my test web site is working....”;

now open a (linux) terminal. In my environment it locates Applications > Accessories > Terminal. Type the below command on terminal.

vi /etc/apache2/sites-available/testwebsite

hit enter and the terminal displays empty file and hit insert button on your keyboard and add the below lines in the file.
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName testwebsite.loc
ServerAlias www.testwebsite.loc
DocumentRoot /home/asoka/Zend/workspaces/Defaultworkspaces/testwebsite
<Directory /home/asoka/Zend/workspaces/Defaultworkspaces/testwebsite/>
Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all

ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined
hit shift+: and type wq. Hit enter. Now type the below command in terminal.
a2ensites testwebsite. It will create link to sites-enabled folder.

Again type the below few lines on your terminal. (lot of commands right? I love terminal so much. :D)

cd /etc/ hit enter
vi hosts
it should looks like below sobiz5 # Added by NetworkManager localhost.localdomain localhost
::1 sobiz5 localhost6.localdomain6 localhost6 asoka-Aspire-4741 sobiz10.loc www.sobiz10.loc emobile.loc www.emobile.loc testwebsite.loc www.testwebsite.loc
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

in that file I have added below line. (it has bolded) testwebsite.loc www.testwebsite.loc

hit shift+: and type wq. Hit enter. Now again on terminal enter the below few lines

/etc/init.d/apache2 restar. If it fails to restart saying Failed, log in to the terminal as a root by typing su
enter. Enter the root password and try to restart the apache by typeing /etc/init.d/apache2 restart.

We have almost done the configuration part. Now open your browser and type www.testwebsite.loc. If the browser displays “Hi.. my test web site is working....” means your web site is working. If it doesn't happen drop an email to to assist you. Happy coding !


Post a Comment

පරිගණක උදවු ගැන ඔබේ අදහස

There was an error in this gadget

PCWorld නවතම පුවත්