Apache configuration

Added by Priato about 5 years ago

Hello,

I have troubles with my apache configuration. When I restart my apache server (sudo /etc/init.d/apache2 restart), I have no problem, but when I try to connect to http://localhost:40916/login/r2_login.php, the r2_login.php is downloaded from my internet browser (firefox).
When I try to connect to http://localhost:40916/ , I have a #403 error: Forbidden, You don't have permission to access / on this server. Apache/2.2.14 (Ubuntu) Server at localhost Port 40916

When I try to connect to http://localhost/admin/index.php , I have an error 404 : Not found

When I try to connect to http://localhost/ , I download a *.phtml.part file

Sorry for this newbie question, but maybe some other user/developer have the same problem.
My last experience with apache and PHP was in 2006 with windows, and I hadn't problem, but it was with a very simple php server...

my "hosts" file:

127.0.0.1    localhost    priato
#127.0.0.1    localhost.localdomain    localhost    priato

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

my "httpd.conf" file:

Listen 40916
NameVirtualHost *:40916
ServerName priato
<VirtualHost *:40916>
  <Directory "/home/priato/dev/code/ryzom/tools/server/">
     Options -Indexes FollowSymLinks MultiViews
     IndexOptions FancyIndexing FoldersFirst NameWidth=*
     AllowOverride All
     Order allow,deny
     Allow from all
  </Directory> 
  ServerAdmin admin@localhost
  DocumentRoot /home/priato/dev/code/ryzom/tools/server/www
  ServerName localhost
</VirtualHost>

my "/etc/apache2/sites-available/default" :

<VirtualHost *:80>
  <Directory "/home/priato/dev/code/ryzom/tools/server/">
     Options -Indexes FollowSymLinks MultiViews
     IndexOptions FancyIndexing FoldersFirst NameWidth=*
     AllowOverride All
     Order allow,deny
     Allow from all
  </Directory> 
  ServerAdmin admin@localhost
  DocumentRoot /home/priato/dev/code/ryzom/tools/server/admin
  ServerName localhost
</VirtualHost>

original "ports.conf" file has been kept

Thank you for any help for this.


Replies (22)

RE: Apache configuration - Added by Nerocon about 5 years ago

Add this between <directory></directory> to clear up the first issue.

AddType text/html .php .phps
AddHandler application/x-httpd-php .php
AddHandler application/x-httpd-php-source .phps

As for the permission issues, check your permission for "/server", "/server/www", and "/server/admin" folders. They need to be writeable by apache. I am not sure what the permission need to be exactly but if your just testing things and not going to open this box up to the wild, you can temp fix this with

sudo chmod 775 /home/priato/dev/code/ryzom/tools/server
sudo chmod 775 /home/priato/dev/code/ryzom/tools/server/www
sudo chmod 775 /home/priato/dev/code/ryzom/tools/server/admin

Restart apache.

I am also pretty sure you only need to declare your virtual hosts in ports.conf, you should get conflicts on apache restart complaining about a conflict. Someone please correct me, or point out a better way as I am working with this issue as well.

RE: Apache configuration - Added by Priato about 5 years ago

Thanks a lot for your fast answer, but the both issue stay the same.

I had conflict before when I restarted apache with following "httpd.conf":

Listen 40916
<VirtualHost *:40916>
  <Directory "/home/priato/dev/code/ryzom/tools/server/">
     Options -Indexes FollowSymLinks MultiViews
     IndexOptions FancyIndexing FoldersFirst NameWidth=*
     AllowOverride All
     Order allow,deny
     Allow from all
  </Directory> 
  ServerAdmin admin@localhost
  DocumentRoot /home/priato/dev/code/ryzom/tools/server/www
  ServerName localhost
</VirtualHost>
<VirtualHost *:80>
  <Directory "/home/priato/dev/code/ryzom/tools/server/">
     Options -Indexes FollowSymLinks MultiViews
     IndexOptions FancyIndexing FoldersFirst NameWidth=*
     AllowOverride All
     Order allow,deny
     Allow from all
  </Directory> 
  ServerAdmin admin@localhost
  DocumentRoot /home/priato/dev/code/ryzom/tools/server/admin
  ServerName localhost
</VirtualHost>

RE: Apache configuration - Added by kerozcak about 5 years ago

Just to be sure.. it's not your whole httpd.conf file, right?

RE: Apache configuration - Added by Priato about 5 years ago

No, not the last posted.

RE: Apache configuration - Added by Nerocon about 5 years ago

Yeah the conflict is coming from the your virtual hosts being declared in your httpd.conf and /sites-available/default, clear the /sites-available/default and try this in your httpd.conf replacing the whole <VirtualHost></VirtualHost> section.

For some reason, I can't format the text, the code block is not working where I want, yet its sectioning out a piece near the bottom where its not defined lol, so here is a link to pastebin

http://pastebin.com/teDki8d2

RE: Apache configuration - Added by Priato about 5 years ago

Thank you for this issue. I don't have anymore the conflict but it remains problem when I try to connect with client:
my log informs me than the connection is good but it show me php code (I have tried with 2 PC: windowsXP for client and Ubuntu for server), like this:

2010/06/24 18:20:05 DBG 10c8 client_ryzom_r.exe http_client.cpp 57 CHttpClient::connect : Connected to web server '192.168.0.13:40916'
2010/06/24 18:20:05 INF 10c8 client_ryzom_r.exe login.cpp 2718 checkLogin : Connected
2010/06/24 18:20:05 DBG 10c8 client_ryzom_r.exe http_client.cpp 81 CHttpClient::send : Sending 'GET /login/r2_login.php?cmd=ask&login=Priato&lg=en
' to '192.168.0.13:40916 (192.168.0.13)'
2010/06/24 18:20:05 INF 10c8 client_ryzom_r.exe login.cpp 2726 checkLogin : Sent request for password salt
2010/06/24 18:20:05 INF 10c8 client_ryzom_r.exe http_client.cpp 155 CHttpClient::receive : Receiving
2010/06/24 18:20:05 INF 10c8 client_ryzom_r.exe http_client.cpp 163 CHttpClient::receive : Received OK 1023 bytes
2010/06/24 18:20:05 INF 10c8 client_ryzom_r.exe http_client.cpp 163 CHttpClient::receive : Received OK 1023 bytes
2010/06/24 18:20:05 INF 10c8 client_ryzom_r.exe http_client.cpp 163 CHttpClient::receive : Received OK 1023 bytes
2010/06/24 18:20:05 INF 10c8 client_ryzom_r.exe http_client.cpp 163 CHttpClient::receive : Received OK 1023 bytes
2010/06/24 18:20:05 INF 10c8 client_ryzom_r.exe http_client.cpp 163 CHttpClient::receive : Received OK 1023 bytes
2010/06/24 18:20:05 INF 10c8 client_ryzom_r.exe http_client.cpp 163 CHttpClient::receive : Received OK 1023 bytes
2010/06/24 18:20:05 INF 10c8 client_ryzom_r.exe http_client.cpp 163 CHttpClient::receive : Received OK 1023 bytes
2010/06/24 18:20:05 INF 10c8 client_ryzom_r.exe http_client.cpp 163 CHttpClient::receive : Received OK 1023 bytes
2010/06/24 18:20:05 INF 10c8 client_ryzom_r.exe http_client.cpp 163 CHttpClient::receive : Received OK 1023 bytes
2010/06/24 18:20:05 INF 10c8 client_ryzom_r.exe http_client.cpp 163 CHttpClient::receive : Received OK 1023 bytes
2010/06/24 18:20:05 INF 10c8 client_ryzom_r.exe http_client.cpp 163 CHttpClient::receive : Received OK 1023 bytes
2010/06/24 18:20:05 INF 10c8 client_ryzom_r.exe http_client.cpp 163 CHttpClient::receive : Received OK 1023 bytes
2010/06/24 18:20:05 INF 10c8 client_ryzom_r.exe http_client.cpp 163 CHttpClient::receive : Received OK 1023 bytes
2010/06/24 18:20:05 INF 10c8 client_ryzom_r.exe http_client.cpp 163 CHttpClient::receive : Received OK 1023 bytes
2010/06/24 18:20:05 INF 10c8 client_ryzom_r.exe http_client.cpp 163 CHttpClient::receive : Received OK 1023 bytes
2010/06/24 18:20:05 INF 10c8 client_ryzom_r.exe http_client.cpp 163 CHttpClient::receive : Received OK 1023 bytes
2010/06/24 18:20:05 INF 10c8 client_ryzom_r.exe http_client.cpp 163 CHttpClient::receive : Received OK 1023 bytes
2010/06/24 18:20:05 INF 10c8 client_ryzom_r.exe http_client.cpp 170 CHttpClient::receive : Received CLOSE 796 bytes
2010/06/24 18:20:05 INF 10c8 client_ryzom_r.exe login.cpp 2731 checkLogin : Received request login check
2010/06/24 18:20:05 WRN 10c8 client_ryzom_r.exe login.cpp 2749 checkLogin : <?php
...
    error_reporting(E_ERROR | E_PARSE);
...
    set_error_handler('err_callback');
...
    // For error handling, buffer all output
    ob_start('ob_callback_r2login');
...
    include_once('config.php');
...
    include_once('login_translations.php');
...
    include_once('.
2010/06/24 18:20:05 INF 10c8 client_ryzom_r.exe login.cpp 731 initLoginScreen : Using verbose log mode
2010/06/24 18:20:26 INF 10c8 client_ryzom_r.exe login.cpp 1296 CAHLoginQuit::execute : CAHLoginQuit called
...

It seems than the php page is not interpreted by the server as a code, but as "gross" html...
I don't have a good knowledge of apache, I will try to have more information about this.
Thanks a lot.

RyzomTestlogin.jpg - Result when I try to connect to my server (329.9 kB)

RE: Apache configuration - Added by kerozcak about 5 years ago

That configuration on wiki is not what you have to replace your httpd.conf, but it's what you have to add to your default httpd.conf

RE: Apache configuration - Added by Nerocon about 5 years ago

Yeah as Kerozcak said, the entire <VirtualHost> section is to be added to the existing httpd.conf at the bottom.

What distro are you using?

As for the php not being being run, it sounds like php is not installed properly or at all. To check if php is installed right create a new file under $RYZOM_PATH/code/ryzom/tools/server/ and call it phpinfo.php Edit it and add

<?php
phpinfo();
?>

Save, and try to open it with your browser.. http://serverIP/phpinfo.php

If it does not spit out a bunch of information about php nicely formatted with a blue header, php is broken.

RE: Apache configuration - Added by Priato about 5 years ago

after a uninstall/install of php, phpinfo is displayed, but only with port 40916, like this: http://192.168.0.13:40916/phpinfo.php (port 80 doesn't work)
I've tried to connect with client and I have "Empty answer from server (error code 62)". I've found the source of this message, and it come from login.cpp. I will take a look to know why, I have this message.
Thanks again for your help.

RE: Apache configuration - Added by Nerocon about 5 years ago

Oh yup my bad, forgot about the port.. good thinking

Not sure on the error code 62, you should pop into the IRC and ask, the folks there can probably point you in the right direction.

When does it pass error 62? Make sure your nel, nel_tools, and ring_open databases are setup correctly and have the right default data. Not sure if this is related to the problem, but worth looking at.

GL

RE: Apache configuration - Added by Priato about 5 years ago

nel domain database(in table) didn't have the right @ip (certainly due to reboot with another @IP: I use a DHCP), so I have updated it with the right @IP but it still the same, allways error code 62. I have checked my *.sql and *.cfg file, but there is nothing wrong, in config files I have put 'localhost' as server adress.

RE: Apache configuration - Added by Nerocon about 5 years ago

How are you starting up the server?, and do you have your $PATH's set correctly? I highly suggest you pop into IRC and ask as well.

RE: Apache configuration - Added by Priato about 5 years ago

My path is correct:

echo $PATH
/home/priato/dev/code/ryzom/tools/scripts/linux/:...

I start server with following command: shard start

In my log client "error_join.log", I can read:

[ev_init_done] st_start -> st_login
[ev_bad_login] st_login -> st_login
[ev_quit] st_login -> st_end

I have dropped my table database, and begin again from scratch, and I have the same problem (@IP domain in database are right now).

RE: Apache configuration - Added by Priato about 5 years ago

I have fellow step by step to the server end and it seems to be the mysql_connect() call that crash. But I don't understand why the "or die(" instruction is never called.
My "config.php" has following parameters:

$DBHost         = "localhost";
$DBUserName     = "shard";
$DBPassword     = "";
...
$AcceptUnknownUser = true;

I have tried the following hard code, but result still the same:

$link = mysql_connect('localhost:40916', 'shard', '');
if (!$link) {

I use MySQL Query Browser (Ubuntu) and there is no pb to connect to database with these informations...

RE: Apache configuration - Added by kerozcak about 5 years ago

To be honest, i have no idea what are you talking about. But you are doing something really wrong. 40916 is not MySQL port. It's port what should your http server listen on for connection from game client.

RE: Apache configuration - Added by Priato about 5 years ago

You are right, I don't know why I have put this port, maybe because I'm desperate ;)
I think I have forgotten a little thing...
My test is the following:
1) In following instruction, I have the echo displayed:

echo 'Here !!!';
mysql_connect(...) or die ('message...');

2) In following instruction, I don't have the echo displayed, or the "or die()" displayed:

//echo 'Here !!!';
mysql_connect(...) or die ('message...');
echo '... or Here !!!';

My conclusion is I have pb with mysql_connect(...) instruction.

With Ubuntu, we need to uncomment in "php.ini" file, an extension for mysql, so maybe my problem come from here...

RE: Apache configuration - Added by Priato about 5 years ago

That's it: my pb come from my "php.ini" with mysql.so to activate. There is php5-mysql package to install too...
That is what it seemed : It's a noob error :)
Sorry for this big post, I have hope it can be helpful for other Ubuntu user in the future.
Thank you for your help.

RE: Apache configuration - Added by Nerocon about 5 years ago

That would explain why I did not run into this problem, I installed LAMP separately one by one.

Glad you got it worked out Priato.

RE: Apache configuration - Added by Priato about 5 years ago

I didn't installed LAMP, I have only installed php5 and mysql packet but not php5-mysql packet...
Now I can log in, I have other error :) I will investigate.

PS: I have added an advice for Ubuntu user into "Configuring and running Ryzom Core server on Linux" tutorial.

RE: Apache configuration - Added by Max_De_Groot almost 3 years ago

Oddly enough, I have a similar problem with my Ubuntu server...
I had a working apache configuretion, with phpmyadmin installed
Now I followed the steps as the wiki says for configuring/installing and for some reason
I get
You don't have permission to access / on this server.
Apache/2.2.22 (Ubuntu) Server at 192.168.13.22 Port 80
if I try to connect.
phpmyadmin still works tho.

My httpd.conf is empty (as it was when it worked...)

I added the information from the wiki (edited to my server settings ofc.)

Listen 40916
<VirtualHost *:40916>
<Directory "/media/Data/ryzom_source/ryzom/code/ryzom/tools/server/">
Options -Indexes FollowSymLinks MultiViews
IndexOptions FancyIndexing FoldersFirst NameWidth=*
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Serveradmin admin@localhost
DocumentRoot /media/Data/ryzom_source/ryzom/code/ryzom/tools/server/www
ServerName 192.168.13.22
</VirtualHost>
<VirtualHost *:80>
<Directory "/media/Data/ryzom_source/ryzom/code/ryzom/tools/server/">
Options -Indexes FollowSymLinks MultiViews
IndexOptions FancyIndexing FoldersFirst NameWidth=*
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ServerAdmin admin@localhost
DocumentRoot /media/Data/ryzom_source/ryzom/code/ryzom/tools/server/admin
ServerName 192.168.13.22
</VirtualHost>

to sites-available/default and that's where the problems started.
Even chmodding server, server/www en server/admin doesn't help.

Any suggestions?

RE: Apache configuration - Added by nimetu almost 3 years ago

Max_De_Groot wrote:

to sites-available/default and that's where the problems started.
Even chmodding server, server/www en server/admin doesn't help.

You apache config seems fine, but if you have multiple VirtualHost blocks with same 'ServerName <ip>' and port, then they will override each other.

You could add simple domain override to /etc/hosts file and use those domains as 'ServerName <domain>'

Lastly, check apache logs (probably under /var/log/apache2). That error might mean missing index file and that you are not accessing the directory you think you are.

RE: Apache configuration - Added by Max_De_Groot almost 3 years ago

thnx;

changed the default to port 88, but that didn't solve the permission problems.
Started the whole project over in my home directory and the problems were solved.
Seems I can't get the permissions right on another harddrive.
(For some reason I can't even get ubuntu to mount the drive by default :p)

So, web related problems solved :D
I even got in the game...
Issues there belong to another thread :D

(1-22/22)