I finally managed to run PHP files using Apache in FireFox but please donīt ask me how! I myself am not sure how I could do it since I have employed so many methods to get a solution that now I donīt remember which method did the trick. Nevertheless some questions are still lingering in my mind. Can someone answer them?
The first few times when PHP scripts were not running, I configured both Apache & PHP using just
./configure without any flags. At this time, the root directory of PHP was
usr/local/apache-2.2.4/htdocs. In other words, if a PHP file resided in the
htdocs directory, I could access that PHP file with this URL:
http://localhost/Try.php
Itīs a different matter that I could just see the source code of the PHP file in the browser. The bottomline is the root was
usr/local/apache-2.2.4/htdocs. The
httpd.conf file resided in
usr/local/apache-2.2.4/conf. In this file, PHP was told to
listen to port 80. When I started Apache by executing the following command:
/usr/local/apache-2.2.4/bin/apachectl -k start
Apache used to start.
Since the PHP files were not running in the browser, I again configured Apache & PHP this time running
./configure with a host of flags like
--with-apxs2=/usr/local/apache-2.2.4/bin/apxs,
--with-apache-2.2.4=/usr/local/apache-2.2.4,
--with-mssql=/usr,
--with-mysql,
--enable-ftp,
--enable-ctype etc. for Apache and
--enable-so,
--enable-module=all,
--enable-alias,
--enable-asis,
--enable-dir etc. for PHP. In fact, I did the configuration of Apache & PHP more than once using many flags but with slight differences here & there.
Now when I tried to start Apache by executing the above command (in blue), the following error got generated:
(98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
After going through a no. of posts to overcome this error, I changed the
Listen port in
httpd.conf from 80 to some other port number. Now when I started Apache, it started successfully but strangely,
usr/local/apache-2.2.4/htdocs which was the root directory earlier no longer remained the root directory. Rather the root directory changed to
var/www/html. I discovered this change in root directory by running the PHP file
Try.php (which resides in
usr/local/apache-2.2.4/htdocs) in FireFox. The output was
File not found since thereīs no file named
Try.php in
var/www/html but when I copied
Try.php from
usr/local/apache-2.2.4/htdocs to
var/www/html, then the PHP file was rendered successfully in FireFox.
Actually thereīs another
httpd.conf file which resides in
etc/httpd/conf. I didnīt notice the existence of this
httpd.conf file when I configured Apache & PHP without any flags; so I am not sure whether this
httpd.conf file existed from the very beginning or not i.e. when I configured Apache & PHP for the first time without any flags or did this
httpd.conf file get created after I configured Apache & PHP with the flags. But both the
httpd.conf files had different values for the same directive like for e.g. the value of the directive
DocumentRoot in the
httpd.conf file which resides in
usr/local/apache-2.2.4/conf is
/usr/local/apache-2.2.4/htdocs whereas the value of this directive in the
httpd.conf file existing in
etc/httpd/conf is
var/www/html. Similarly, the value of the directive
ServerRoot in one of the
httpd.conf files is
/usr/local/apache-2.2.4 whereas the value of this directive in the other
httpd.conf file is
/etc/httpd.
Now which of the 2
httpd.conf files will Apache use to process PHP scripts? Also why are the values of the same directives in the 2
httpd.conf files different?
Moreover why did Apache generate the above error (in red) & refused to start when I configured Apache & PHP with a plethora of flags? Finally what could have prompted the root directory to change from
usr/local/apache-2.2.4/htdocs to
var/www/html?
Thanks,
Regards,
Ron