Help with Installation of PHP and MySQL

Asked By 10 points N/A Posted on -
qa-featured

Hi everyone

I want to install PHP and MySQL but I don’t know how to host my website while using a domain like http://www.mysite.com/ on my computer.

Still, I am wishing to use Linux.

Thanks

SHARE
Best Answer by lee hung
Best Answer
Best Answer
Answered By 75 points N/A #97015

Help with Installation of PHP and MySQL

qa-featured

Hello Gibb,

To use PHP and MySql to host your site, you will need to install a program called xampp or wamp on your computer.

Xampp comes with both PHP and MySQL and therefore when you install it you will just need to start these services by clicking on the xampp icon that will be on your desktop. You will also need to start the Apache web service.

After that type http://localhost in the address bar of you browser and press enter, and then locate PHPmyAdmin in the page that will open.

You can now create and edit databases in MySQL from here.

Regards
Lee Hung

Answered By 0 points N/A #97016

Help with Installation of PHP and MySQL

qa-featured

HI Hctgibbs

 
Here I would like to help you out by providing guidance about your question regarding hosting your website on your Linux Computer.
 
I wish you had a little pre-req knowledge about Linux regarding basic commands.
 
The first and most important thing when talking about hosting a site on your computer is if you want to browse the site only on your system or you want to make it publicly available.
 
If you want to make it locally available and don't want to access your site out of your LAN then there is no need to register the domain otherwise if you want to access it publicly then definitely you need to register this domain first.
 
The better I will recommend to visit www.godaddy.com and register your required domain there say mysite.com.
 
For your ease, I  am creating here possible scenarios:
 
Case 1: (Website need to be accessible only on LAN)
 
I wish your Linux system is ready, installed and available on the network for the further setup
 
Now the first thing is to decide which webserver you want to use for serving your PHP code.
 
The most well known webserver on Linux platform is Apache and the daemon is known as 'httpd'
 
You can visit the site here to see the latest updates and documentation.
 
There are others as well like nginx and lighttpd
 
The straight and easy way to install Apache on your system is to use yum (in case of Fedora, redhat) or apt-get (in case of Ubuntu or Debian)
 
yum install httpd
 
Or
 
apt-get install apache2
 
Once the installation is successful you can start the webserver by issuing
 
service httpd start
 
You can test the webserver is up and running by issuing following command and you will see the test page.
 
elinks http://localhost
 
Similarly you can install PHP and mysql
 
yum install php
 
Or
 
apt-get install php5
 
apt-get install libapache2-mod-php5
 
yum install mysql mysql-server
 
Or
 
apt-get install mysql-client mysql-server
 
 
 
You can start mysql in different ways like
 
service mysqld start
 
Or
 
/etc/init.d/mysql start
 
Now load your schema into my SQL DB.
 
Now place your PHP code in the default document root and point your browser to localhost. If all goes well you can change the default hostname of your machine as follows
 
hostname www.mysite.com
 
Or update /etc/hosts file
 
Case 2: (Website need to be accessible publicly)
 
In this case your computer must have a public IP address available from your internet link provider.
 
You can update your hosted DNS with A record having name at www for domain mysite.com
 
www record should point to the public IP address of your computer.
 
Remaining procedure will remain same as in case 1
 
Hope this all helpful for you. For any further questions you can come back to me and I will try to be more helpful.
 
Hasan Jamal

Related Questions