LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   php with apache (https://www.linuxquestions.org/questions/slackware-14/php-with-apache-4175417647/)

mitusf 07-19-2012 01:19 PM

php with apache
 
I tried to set up httpd to work with php module, so i've followed the rules from http://connie.slackware.com/~mrgobli...ware-lamp2.php and then i created the index.php file containing the phpinfo() function, and when i accessed it from the browser it just lists it and not interprets it through php module. I can't find the problem. Anyone can help? Thanks.

Kustom42 07-19-2012 01:26 PM

What distro are you using here? Do you have php installed? You should be able to run the below command to get your php version.

Code:

/usr/bin/php -v
apachectl -t -D DUMP_MODULES


NoStressHQ 07-19-2012 01:30 PM

edit and read /etc/httpd/httpd.conf...

You should find a line to uncomment to enable php, but it worth having a view of the whole file, so take time to read it.

Cheers.

Kustom42 07-19-2012 01:32 PM

It really depends upon the module being used here NoStressHQ. Apache can parse PHP in several methods, the apachectl command will show us what apache currently has loaded for modules to help better point the OP in the right direction.


I think you're a couple steps ahead in telling them to go into the httpd.conf and start removing comments. mitusf let's get the output of what you currently have running before we start changing anything.

mitusf 07-19-2012 02:10 PM

@NoStressHQ: yes, i've uncommented the php line in /etc/httpd/httpd.conf, like the web page that i've indicated requests.

Here is the output of the commands that Kustom42 indicated:


root@darkstar:~# /usr/bin/php -v
PHP 5.3.14 (cli) (built: Jul 4 2012 20:12:22)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies

root@darkstar:~# apachectl -t -D DUMP_MODULES
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
Loaded Modules:
core_module (static)
mpm_prefork_module (static)
http_module (static)
so_module (static)
authn_file_module (shared)
authn_dbm_module (shared)
authn_anon_module (shared)
authn_dbd_module (shared)
authn_default_module (shared)
authn_alias_module (shared)
authz_host_module (shared)
authz_groupfile_module (shared)
authz_user_module (shared)
authz_dbm_module (shared)
authz_owner_module (shared)
authnz_ldap_module (shared)
authz_default_module (shared)
auth_basic_module (shared)
auth_digest_module (shared)
file_cache_module (shared)
cache_module (shared)
disk_cache_module (shared)
mem_cache_module (shared)
dbd_module (shared)
dumpio_module (shared)
reqtimeout_module (shared)
ext_filter_module (shared)
include_module (shared)
filter_module (shared)
substitute_module (shared)
deflate_module (shared)
ldap_module (shared)
log_config_module (shared)
log_forensic_module (shared)
logio_module (shared)
env_module (shared)
mime_magic_module (shared)
cern_meta_module (shared)
expires_module (shared)
headers_module (shared)
ident_module (shared)
usertrack_module (shared)
unique_id_module (shared)
setenvif_module (shared)
version_module (shared)
proxy_module (shared)
proxy_connect_module (shared)
proxy_ftp_module (shared)
proxy_http_module (shared)
proxy_scgi_module (shared)
proxy_ajp_module (shared)
proxy_balancer_module (shared)
mime_module (shared)
dav_module (shared)
status_module (shared)
autoindex_module (shared)
asis_module (shared)
info_module (shared)
cgi_module (shared)
dav_fs_module (shared)
vhost_alias_module (shared)
negotiation_module (shared)
dir_module (shared)
imagemap_module (shared)
actions_module (shared)
userdir_module (shared)
alias_module (shared)
rewrite_module (shared)
php5_module (shared)
Syntax OK


Thanks for your answers.

Kustom42 07-19-2012 02:36 PM

Ok, so it looks like your PHP is loaded correctly into Apache.

Let's look at your virtual host records and the options passed to it.

So by default your virtual host records should be in your /etc/httpd/httpd.conf or a similar config file. If you are using a control panel like plesk or cpanel this will be different.

The first thing to look at is the ExecCGI option as this can have some effect on the way PHP is processed.


So, since you are the one who setup the virtual host for the domains you should know where they are contained.


Can you please locate the virtual host record for the domain in question and let us know what you are passing to your "Options" directive.

If you are not sure what this is you can post the entire syntax of your virtual host.

If you are not sure where your virtual host record is at you can use the following command:

Code:

apachectl -t -D DUMP_VHOSTS
This will tell you what file and what line number it is contained in.

mitusf 07-19-2012 03:13 PM

root@darkstar:/etc/httpd/extra# apachectl -t -D DUMP_VHOSTS
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
VirtualHost configuration:
Syntax OK

That's all it says, i've noticed a Virtual hosts entry in /etc/httpd/httpd.conf, like this:

# Virtual hosts
#Include /etc/httpd/extra/httpd-vhosts.conf

So, this being commented, i don't know about other entry.

Kustom42 07-19-2012 03:19 PM

You do not have a virtual host setup. How are you accessing the site in your browser. Are you using an IP or a dns name?

mitusf 07-19-2012 03:26 PM

I'm accessing it either with 127.0.0.1, localhost, or hostname.domain

mitusf 07-19-2012 03:29 PM

The hostname and domain name are just for local use, not registered through dns, just mentioned in /etc/hosts, you know...

Kustom42 07-19-2012 03:39 PM

OK, well you need to setup a namevirtualhost record and setup a default virtual host.

Check out:
http://www.thegeekstuff.com/2011/07/...-virtual-host/
http://httpd.apache.org/docs/2.2/vhosts/examples.html
http://httpd.apache.org/docs/2.2/vhosts/name-based.html

If you have any questions let us know. When you setup your virtual host, under the "Options" directive set "+ExecCGI".

NoStressHQ 07-19-2012 04:05 PM

Quote:

Originally Posted by Kustom42 (Post 4732936)
It really depends upon the module being used here NoStressHQ.

Alright... Sorry for the misleading :)...

Cheers.

mitusf 07-19-2012 04:21 PM

ok, i created a virtualhost like this, in /etc/httpd/extra/httpd-vhosts.conf (also uncommented the corresponding line in httpd.conf):


<VirtualHost *:80>
ServerAdmin webmaster@hostname.domain
DocumentRoot "/var/www/htdocs"
ServerName hostname.domain
ServerAlias www.hostname.domain
ErrorLog "/var/log/httpd/hostname.domain.ro-error_log"
CustomLog "/var/log/httpd/hostname.domain-access_log" common
</VirtualHost>

and when i tried to access the index.php file, i only get a

Forbidden
You don't have permission to access /index.php on this server.

Also, i didn't see any Option directive under VH, should i create one with "+ExecCGI" value?

Kustom42 07-19-2012 04:34 PM

Yes, just add the line:

Options +ExecCGI


What are the permissions on the folder: /var/www/htdocs?

mitusf 07-19-2012 04:43 PM

ok, the perms are 755. I've added the Options line to VirtualHost but has no effect, i still get the same forbidden message.


All times are GMT -5. The time now is 01:12 AM.