Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I get all my php files run on a Linux server? I copied all PHP files to my Linux server under /www and I did change config settings like the following. Also I created an error log file under /logs.

But when I run mytest.example.com in browser, it is not working and the page shows:

Oops! Google Chrome could not find mytest.example.com

I think I need to change or add something.

I use Putty to access the Centos and use WinSCP as FTP.

<VirtualHost *:80>
ServerName mytest.example.com
DocumentRoot /www/allphpfile/
ErrorLog logs/my_test_error_log
</VirtualHost>
share|improve this question
    
did you tried putting a phpinfo file? added php modules in http.conf? are you getting the default apache web page? –  Renju Chandran chingath Jul 19 '13 at 5:23
    
Do nslookup mytest.example.com in command line. Does that show your IP address? Do you have a DNS server set up for that (I don't think you're the owner of example.com domain, right)? lol –  Ashtray Jul 19 '13 at 6:24
    
Also make sure your files are in /var/www and not /www – there's no reason to put them into a folder at the root level of your file system. –  slhck Jul 19 '13 at 6:29
    
@slhck Actually, these days something like /srv/www might be a more appropriate place. –  Michael Kjörling Jul 19 '13 at 12:56
    
@MichaelKjörling True, good to know, but if the OP is using a default LAMP install, I guess /var/www should do. –  slhck Jul 19 '13 at 12:57

3 Answers 3

You can not connect to a service under example.com unless you are the owner of that domain. You need three things to host PHP content;

  1. PHP enabled web server (e.g Apache).
  2. PHP modules for that server.
  3. A computer (or VM) with a public IP address.

Technically speaking, you don't need any of that to "run a PHP file". You can install the interpreter using the package manager and invoke it on a file:

php /home/moo/somescript.php

Another user suggested that it is actually possible to use the example domain if it is configured locally. To enable the local machine to resolve an arbitrary domain, you can associate that arbitrary domain with an arbitrary IP address in /etc/hosts like so:

/etc/hosts:

 # local
 10.3.0.1        monger.lan      mon.lan monger   mon   ruter
 10.3.0.3        tryggve.lan     try.lan tryggve  try
 # remote
 xx.zz.yy.185  caracal
 xx.zz.yy.184  gaupe
 xx.zz.yy.175  login.pvv.org pvv
 # example
 127.0.0.1     mytest.example.org

(xx.zz.yy must be actual numbers)

share|improve this answer

Solution: configure LAMP server in centos followed by few step, reference url for configuration https://library.linode.com/lamp-guides/centos-6 and also install phpmyadmin for database management refrence url https://library.linode.com/lamp-guides/centos-6

share|improve this answer
2  
Instead of just posting links to complete LAMP configuration tutorials, you should attempt to address the specific issue the OP has, namely not being able to connect to example.com – for obvious reasons. –  slhck Jul 19 '13 at 6:20
  1. Install php package through rpm or yum.

  2. Then first we need to know what kind of hosting user require(dedicated hosting or virtual hosting)

  3. Install mysql package on server

  4. make changes in httpd>conf>httpd.conf file if you wants to get any change regarding the apache service port No and all that

  5. To provide the virtual hosting through a single service & singla IP. Kindly refer below DocumentRoot /var/www/.html ServerName example.com

  6. start httpd service service httpd start

  7. Now try to host any of website by providing the ip of apache installed system at DNS for or rev files.

  8. Enjoy the day

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.