Linux – Need help configuring Apache, MySQL, PHP on Centos Linux

apache-2.2linuxMySQLPHPweb-server

I am new to Linux (CentOS) and have been trying to setup
up this web application https://github.com/craigrodway/printmaster on CentOS for the
last couple hours.

The instruction from the author is a bit vague for a newbie like me:

  • Create directory on webserver to store files (configure as virtual
    host or subdir)
  • Copy all Print Master files to the folder you just created
  • Create a new directory called session where you extracted the files and make it writeable
  • Create a new username and database in MySQL
  • Import the printmaster.sql file into the new database
  • Edit the
    $db line in inc/init.php to reflect your database details Invent your
    own security (.htaccess, integrated Windows authentication…)

I try to follow the instruction from guide in the wiki section but still could not get it to work: https://github.com/craigrodway/printmaster/wiki/Installation-on-Linux

Here is a history of what I did

  1. Installed / configured Apache Server following this instruction:
    http://dev.antoinesolutions.com/apache-server (Visited localhost
    in the web browser and saw an Apache Test Page)
  2. Installed / configured PHP following this intruction:
    http://dev.antoinesolutions.com/php (Visited localhost/phpinfo in
    the web browser, and there's the phpinfo output. So it works!)
  3. Installed / configured MySQL

— FILES —

[root@localhost ~]# cd /tmp
[root@localhost ~]# wget [url]
https://github.com/craigrodway/printmaster/tarball/master[/url] --no-check-certificate
[root@localhost ~]# tar zxvf master
[root@localhost ~]# mv craigrodway-printmaster-af9843d/* /root/Desktop/printmaster/

Created 'session' directory is in the printmaster directory, made it writable

[root@localhost ~]# mkdir session
[root@localhost ~]# chmod 755 session

— DATABASE —

mysql -u root -p

(enter the password for root user)

mysql> CREATE USER 'printers'@'localhost' IDENTIFIED BY 'printersPASS';
Query OK, 0 rows affected (0.00 sec)

mysql> CREATE DATABASE printers;
Query OK, 1 row affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON printers.* TO 'printers'@'localhost';
Query OK, 0 rows affected (0.00 sec)

mysql> quit;

— IMPORT SQL FILE —

Import the printmaster.sql as instructed

[root@localhost ~]# mysql -u root -p printers < printmaster.sql

Open init.php and edit the $db line

[root@localhost ~]# vi inc/init.php

Change $db to:

$db = new fDatabase('mysql', 'printers', 'printers', 'printersPASS', 'localhost');

— Now I set up VirtualHost on httpd —
First of all, do I even need to set up virtual host?

Created the file /etc/httpd/conf.d/testprintmaster.conf with the following text:

<VirtualHost *:80>
  DocumentRoot /root/Desktop/printmaster
  ServerName testprintmaster
  ServerAlias [url]www.testprintmaster.com[/url]
</VirtualHost>

Restart Apache

[root@localhost ~]# service httpd restart

— RESULT —

That's it! But when I visit www.testprintmaster.com on firefox, Apache directs it to a search page … WTF!?

I check the syntax check on VirtualHost configuration

[root@localhost ~]# /usr/sbin/httpd -S

VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
_default_:443   localhost.localdoman (/etc/httpd/conf.d/ssl.conf:81)
*:80        is a NameVirtualHost
    default server testprintmaster (/etc/httpd/conf.d/testprintmaster.conf:2)
    port 80 namevhost testprintmaster (/etc/httpd/conf.d/testprintmaster.conf:2)
Syntax OK

What did I do wrong? Any idea?

Best Answer

Why are you visiting www.printmaster.com? It sounds like you're configuring your server locally, so you should make sure testprintmaster resolves to your localhost (i.e. ping testprintmaster succeeds). If it doesn't you should add 127.0.0.1 testprintmaster record to /etc/hosts and then try accessing it via http://testprintmaster.