Basic Apache help needed

Soldato
Joined
18 May 2010
Posts
22,941
Location
London
Hi guys.

My first go at getting a website to run in Apache.

I'm trying to deploy GLPI. Both for training purposes and for deploying at work.

I've set up a LAMP server running on Centos.

The test page works for Apache.

I copied the GLPI directory with all the files to the /var/www/html/glpi directory

When I browse to localhostip/glpi it just lists the content of the directory rather than launching the page.

I get the feeling I haven't install php properly. It's installed (yum install php php-mysql) but I get the feeling it's not working properly because surly by browsing to that directory should launch site not give me a directory listing.

Have I put the files in to the right directory to begin with?

The documentation just says:

Install the application files on the server

Install the application files on the server to host GLPI.
Unzip the downloaded archive. The directory name is obtained glpi.
Copy this directory in the web tree of files to make it accessible..
Give write access to the web service on the folders /files and /config.

I also dont know what to do for the last line. what would the username be of the web service?
 
create a .php file with

Code:
<?php
phpinfo();
?>

browse to it and see

if that works then you're probably not redirecting properly with mod_rewrite

quick google picks up http://linuxadmin.melberi.com/2010/07/glpi-installation-guide-step-by-step.html which includes steps for the httpd.conf file, might be a bit dated but seems to include more info than one you've followed.

also www-data or apache is the typical username for apache you can run "cat /etc/passwd" to list the users
 
Last edited:
Last edited:
Use this buddy.

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/install-LAMP.html

Basically identical to centos.

I would also do vhosts to make it a bit nicer...if its listing directories then something is odd. Its not picking up index.php or index.HTML or as someone rightly said it can be a mod rewrite issue.

If mod rewrite is enabled then I'll put my money on htaccess allow overrides not being set properly :)
 
create a .php file with

Code:
<?php
phpinfo();
?>

browse to it and see

if that works then you're probably not redirecting properly with mod_rewrite

quick google picks up http://linuxadmin.melberi.com/2010/07/glpi-installation-guide-step-by-step.html which includes steps for the httpd.conf file, might be a bit dated but seems to include more info than one you've followed.

also www-data or apache is the typical username for apache you can run "cat /etc/passwd" to list the users


I got stuck. :p In the following that guide you linked too I got up to restarting the apache service and it fails.

Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.

If I run: systemctl status httpd.service -l

I get:

May 22 15:29:37 centos7.andrew.com systemd[1]: Starting The Apache HTTP Server...
May 22 15:29:37 centos7.andrew.com httpd[29121]: httpd: Syntax error on line 356 of /etc/httpd/conf/httpd.conf: /etc/httpd/conf/httpd.conf:366: <> was not closed.\n/etc/httpd/conf/httpd.conf:364: <> was not closed.\n/etc/httpd/conf/httpd.conf:362: <> was not closed.\n/etc/httpd/conf/httpd.conf:356: <> was not closed.
May 22 15:29:37 centos7.andrew.com systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
May 22 15:29:37 centos7.andrew.com kill[29136]: kill: cannot find process ""
May 22 15:29:37 centos7.andrew.com systemd[1]: httpd.service: control process exited, code=exited status=1
May 22 15:29:37 centos7.andrew.com systemd[1]: Failed to start The Apache HTTP Server.
May 22 15:29:37 centos7.andrew.com systemd[1]: Unit httpd.service entered failed state.
May 22 15:29:37 centos7.andrew.com systemd[1]: httpd.service failed.


Then I ran this: apachectl configtest

and it tells me:

httpd: Syntax error on line 356 of /etc/httpd/conf/httpd.conf: /etc/httpd/conf/httpd.conf:366: <> was not closed.\n/etc/httpd/conf/httpd.conf:364: <> was not closed.\n/etc/httpd/conf/httpd.conf:362: <> was not closed.\n/etc/httpd/conf/httpd.conf:356: <> was not closed.


The <VirtualHost> entry I added as shown in the example I just added to the end of the httpd.conf file. Was this incorrect?
 
I removed this:

< VirtualHost 192.168.1.89:* >
DocumentRoot /var/www/html/glpi
ServerName support.example.com
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
< Directory "/var/www/html/glpi" >
DirectoryIndex index.php
< /Directory >
Options ExecCGI
< /VirtualHost >

from the end of the httpd.conf file and then ran apachectl configtest and it returns successful.

So the question is, where do I put the above?

* And the service is now restart-able.
 
Try it without the spaces in the tags as below:

Code:
<VirtualHost 192.168.1.89:*>
  DocumentRoot /var/www/html/glpi
  ServerName support.example.com
  RewriteEngine on
  RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
  RewriteRule .* - [F]
  <Directory "var/www/html/glpi">
    DirectoryIndex index.php
  </Directory>
  Options ExecCGI
</VirtualHost>

I believe it should skip the spaces but worth a try, never in my life added extra spacing to the tags so no idea.

The end of the file should be fine.
 
Woo success!!

---

Yep all working.

Thanks!!

I had to disable SELiux and add some exceptions in to get it to work.

setsebool -P httpd_can_network_connect on
setsebool -P httpd_can_network_connect_db on
setsebool -P httpd_can_sendmail on

Is this a normal thing in a production environment or should I of really got it working with SELinux on?
 
Last edited:
Is this a normal thing in a production environment or should I of really got it working with SELinux on?

Should keep SELinux on tbh, it's the security system lol.

I've been in the same boat, it's easier to leave it off and not learn... but isn't that bad once you know how to use it.
 
Back
Top Bottom