Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Config Apache HTTP Server for Eclipse

Tags:

eclipse

apache

Maybe this question is silly but I really don't know how to solve.

First, as other server, I want to define new server. So, in Eclipse, I go to: Windows>Preference>Server:

1) When I add new server, in list, no category for Apache HTTP server. Just has Apache Tomcat. So, I click into download additional server adapter-->still don't have in list.

2) So, I search. I point to location I have installed. Good, Eclipse sees that is a HTTP Server. And Eclipse sees folder to put project into for me (because I use LAMP so that folder isn't in Apache folder).

But here is my problem. When I want to run a new PHP Project. Right click, run on server. A new dialog appear take me to choose which server to run. And, in list of server, no HTTP Server, So, I don't know how to choose Apache HTTP Server !!! (because Eclipse doesn't see which server that I have defined, eclipse just find adapter first)

So, if I want to run this project, I must copy all and paste to Apache folder. Too handy !!!

Please help me.

Thanks :)

like image 925
hqt Avatar asked May 01 '12 16:05

hqt


2 Answers

Apache's HTTP server and Eclipse don't communicate with each other. The servers under Windows -> Preference -> Server are Java servers like Tomcat and Glassfish.

What you need to do is define your web project in Eclipse, then define that same directory to the HTTP server in the httpd.conf file. Or, since you're already set up, write an Ant script in Eclipse to copy the PHP files to your HTTP folder.

Edited to add: Here's my Ant script to keep my Eclipse directory and my HTTP directory synchronized. I develop in Windows.

<?xml version="1.0" encoding="UTF-8"?>
<project name="build" default="" basedir=".">
    <description>
       Synchronize the Eclipse folders and the web site folders
    </description>    
    <!-- Relative location of eclipse folder -->
    <property name="eclipse" value="." />
    <!-- Absolute location of web site folder -->
    <property name="website" value="C:/Presbury UMC/" />

    <!-- Copy new web site files -->
    <copy todir="${eclipse}">
        <fileset file="${website}/index.php"/>
    </copy>
    <copy todir="${eclipse}/css">
        <fileset dir="${website}/css"/>
    </copy>
    <copy todir="${eclipse}/images">
        <fileset dir="${website}/images"/>
    </copy>
    <copy todir="${eclipse}/protected">
        <fileset dir="${website}/protected/">
            <exclude name="yiic*"/>
            <exclude name=".htaccess"/>
        </fileset>
    </copy>   
    <copy todir="${eclipse}/themes">
        <fileset dir="${website}/themes"/>
    </copy>

    <!-- Copy new Eclipse files -->
    <copy todir="${website}">
        <fileset file="${eclipse}/index.php"/>
    </copy>
    <copy todir="${website}/css">
        <fileset dir="${eclipse}/css"/>
    </copy>
    <copy todir="${website}/images">
        <fileset dir="${eclipse}/images"/>
    </copy>
    <copy todir="${website}/protected">
        <fileset dir="${eclipse}/protected/"/>
    </copy>   
    <copy todir="${website}/themes">
           <fileset dir="${eclipse}/themes/"/>
    </copy>   
</project>
like image 60
Gilbert Le Blanc Avatar answered Sep 30 '22 10:09

Gilbert Le Blanc


Go to apache>conf>httpd.conf file and open it.Below "ServerName localhost:80" change your document root and directory to your working directory(in eclipse it is workspace).Now you can run your php file/project by typing its full url in any browser or if you want to run it through eclipse you have to configure that run also by synchronizing both server copy and local copy(in this case both are same)in mapping tab.

like image 31
humble_wolf Avatar answered Sep 30 '22 09:09

humble_wolf