Can not connect to Virtual Server with domain name.

Distro CentOS 6.5 on a VPS
Virtualmin/Webmin/Usermin on Apache.

This was a long drawn out process. First I was creating the Virtual Servers within Webmin, I did a lot of work to get the php to work i those, but I did it. Then I went to try to set up the email accounts and all of them regardless of domain were showing up as user@webmin.domain.com and I couldn’t receieve mail to the actual user@domain.com. So I decided to just create a Virtual Server within Virtualmin and that worked for the email. I am not able to receive email to the user@domain.com, but with the settings that Virtualmin put into my httpd.conf file I was unable to connect to the site files. So I made changes to that information and here is my current issue.

If I navigate to www.domain.com I get a Forbidden You don’t have permission to access / on this server. error. But if I type in www.domain.com/index.php or www.domain.com/index.html the page will show up but those are missing the css and javascript because "Resource interpreted as Script but transferred with MIME type text/html: " But if I go to say www.domain.com/read.php which uses the same css and js files the page will load exactly as it should.

I tried setting the DirectoryIndex to just index.php and that doesn’t work. I’ve searched for over 10 hours trying to find someone else with the same issue and I’ve made changes to my httpd.conf file that I don’t even know what it should look like anymore. (Just making changes to the VirtualHost section)

Please let me know what information you need from me to help me fix this.

The repos that I used:
CentOS-Base.repo CentOS-Vault.repo Percona.repo vz.repo
CentOS-Debuginfo.repo epel.repo remi.repo
CentOS-Media.repo epel-testing.repo virtualmin.repo

The settings added to my httpd.conf file for the VirtualServer with the items commented out so that I could get working what is working.

<VirtualHost :80>
#SuexecUserGroup#502” “#502
ServerAdmin shawn@{DOMAIN}.com
ServerName {DOMAIN}.com
ServerAlias www.{DOMAIN}.com
#ServerAlias webmail.{DOMAIN}.com
#ServerAlias admin.{DOMAIN}.com
DocumentRoot /home/shawn/public_html
ErrorLog /var/log/virtualmin/{DOMAIN.com_error_log
CustomLog /var/log/virtualmin/{DOMAIN}.com_access_log combined
AddType text/javascript .js
AddType text/css .css
#ScriptAlias /cgi-bin/ /home/shawn/cgi-bin/
#ScriptAlias /awstats/ /home/shawn/cgi-bin/
#DirectoryIndex index.php index.html index.htm index.php index.php4 index.php5
#<Directory /home/shawn/public_html>
#Options Indexes FollowSymLinks
#AllowOverride All
#Order allow,deny
#Allow from all
#
#<Directory /home/shawn/public_html>
#Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI
#Allow from all
#AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,S$
#AddHandler fcgid-script .php
#AddHandler fcgid-script .php5
#FCGIWrapper /home/shawn/fcgi-bin/php5.fcgi .php
#FCGIWrapper /home/shawn/fcgi-bin/php5.fcgi .php5
#
#<Directory /home/shawn/public_html>
#DirectoryIndex index.php
#order allow,deny
#AddHandler fcgid-script .php
#AddHandler fcgid-script .php5
#FCGIWrapper /home/shawn/fcgi-bin/php5.fcgi .php
#FCGIWrapper /home/shawn/fcgi-bin/php5.fcgi .php5
#
#UserDir “/www/shawn/public_html”
#DirectoryIndex index.php
#RemoveHandler .php
#RemoveHandler .php5
#php_admin_value engine Off
#IPCCommTimeout 101
#FcgidMaxRequestLen 1073741824
#SuexecUserGroup#502” “#502
#<Directory /home/shawn/cgi-bin>
#Allow from all
#AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,S$
#
#RewriteEngine on
#RewriteCond %{HTTP_HOST} =webmail.{DOMAIN}.com
#RewriteRule ^(.
) https://{DOMAIN}.com:20000/ [R]
#RewriteCond %{HTTP_HOST} =admin.{DOMAIN}.com
#RewriteRule ^(.) https://{DOMAIN}.com:10000/ [R]
#RemoveHandler .php
#RemoveHandler .php5
#php_admin_value engine off
#IPCCommTimeout 9999
#FcgidMaxRequestLen 1073741824
#Alias /dav /home/shawn/public_html
#Alias /pipermail /var/lib/mailman/archives/public
#<Location /dav>
#DAV on
#AuthType Basic
#AuthName “{DOMAIN}.com”
#AuthUserFile /home/shawn/etc/dav.digest.passwd
#Require valid-user
#ForceType text/css .css
#Satisfy All
#RemoveHandler .php
#RemoveHandler .php5
#RewriteEngine off
#
#
#AuthName “{DOMAIN}.com statistics”
#AuthType Basic
#AuthUserFile /home/shawn/.awstats-htpasswd
#require valid-user
#
#AuthType Basic
#AuthName “{DOMAIN}.com”
#AuthUserFile /home/shawn/etc/dav.digest.passwd
#Require valid-user
#ForceType text/css .css
#Satisfy All
#RemoveHandler .php
#RemoveHandler .php5
#RewriteEngine off
#
#
#AuthName “{DOMAIN}.com statistics”
#AuthType Basic
#AuthUserFile /home/shawn/.awstats-htpasswd
#require valid-user
#
#RedirectMatch /cgi-bin/mailman/([^/.]
)(.cgi)?(.) https://{DOMAIN}.com:10000/virtualmin-mailman/unauthenticated/$1.cgi$3
#RedirectMatch /mailman/([^/.]
)(.cgi)?(.*) https://{DOMAIN}.com:10000/virtualmin-mailman/unauthenticated/$1.cgi$3


AddType text/javascript .js


AddType text/css .css

Please let me know what other information is needed.

Shawn

Howdy,

On a brand new CentOS installation, setup with the default vendor-supplied software repositories and no third party repositories added – the things you’re describing typically work out of the box.

However, it looks like there’s some third party repositories configured which may be causing the problems you’re seeing… some of those repositories are known to cause problems, when certain packages are installed from them.

And then, with the modifications to the Apache config, while I’m sure that did resolve some problems, it would also be causing some others :slight_smile:

One thing we can check quick – what is the output of these commands:

rpm -qa | grep php rpm -qa | grep httpd

However, is this server a fairly new installation? If so, what are your thoughts on starting from scratch, and on that new system, not enabling any third party repositories?

There’s some additional information on using third party repositories on CentOS in the article here titled “Why does PHP / ProFTPd no longer work after performing updates? (I’m using CentOS, and enabled third party repositories)”:

https://www.virtualmin.com/documentation/system/faq

rpm -qa | grep php

php-pdo-5.3.3-27.el6_5.i686
php-5.3.3-27.el6_5.i686
php-mcrypt-5.3.3-3.el6.i686
wbm-php-pear-1.5-1.noarch
php-cli-5.3.3-27.el6_5.i686
php-common-5.3.3-27.el6_5.i686
php-mysql-5.3.3-27.el6_5.i686

rpm -qa | grep httpd

httpd-tools-2.2.15-29.el6.vm.1.i686
httpd-2.2.15-29.el6.vm.1.i686

This is a new installation. I did have ISPconfig 3 on a Ubuntu 10.04 LTS, but it became messed up when I was setting up Laravel. I was tired of IspConfig so I wanted something new. I let the company managing my VPS to pick the Distro because they need to reset it because they had to set up some things behind my VPS for some memory allocation. Anyway, I’m fine with starting over, but I couldn’t find a step by step process for setting up Centos 6 with Virtualmin and Webmin. If that exists then I’m find with starting over. Can I start over using my current setup or do I need to email my provider and get a new Distro. If so is there a good Distro to use?

Thanks
Shawn

Ah, while it does look like there are some third party repositories enabled, they don’t appear to have overridden the default PHP and Apache packages yet.

Here’s where I’d start –

First, I’d suggest running these commands to disable all the third party repos (you can enable then later if needed):

mv /etc/yum.repos.d/vz.repo /etc/yum.repos.d/vz.repo.orig mv /etc/yum.repos.d/Percona.repo /etc/yum.repos.d/Percona.repo.orig mv /etc/yum.repos.d/epel.repo.repo /etc/yum.repos.d/epel.repo.orig mv /etc/yum.repos.d/remi.repo.repo /etc/yum.repos.d/remi.repo.orig mv /etc/yum.repos.d/epel-testing.repo.repo /etc/yum.repos.d/epel-testing.repo.orig

Those are all third party repositories which could cause problems (and may potentially already be causing problems, but let’s see if we can get this working).

Once those are disabled – the easiest way to troubleshoot the issue you’re seeing would be with a default Apache config.

Can you make a copy of your existing website, delete the Virtual Server you have there, then re-create it?

Once you do all that, I’d be interested to see what problems you have with the default Apache config for that domain… as the default Apache config should work.

And if it doesn’t work for some reason, it shouldn’t be hard to tweak it, assuming there aren’t unrelated issues causing problems.

One last thing – if you go into System Settings -> Re-Check Config, does that detect any problems?

-Eric

Only two of those repos were on my box. I will try what you said this evening with removing the Virtual Server. Should I clear out the httpd.conf file and maybe find what the default looked like and match it, then create the new Virtual Server?

Running the Re-Check gives:

Virtualmin could not work out the default IPv6 address for virtual servers on your system. You will need to update either the Network interface for virtual addresses or Default virtual server IP address fields on the module configuration page.

Other than that it completes fine. I will clear out the virtual server and do another, let me know if I need to restore my httpd.conf file.

Shawn

I went into my Virtualmin and disabled the Virtual Server. I then deleted it and all record of it. I then wen to make sure there were not any Virtual Hosts in Webmin >apache. I then opened my httpd.conf file and deleted everything after the example for the VirtualHost. I then re-created the virtual Server in Virtualmin and I logged in through FTP as the new user. I uploaded my entire site and when I navigate to the page I get a 404 Not found. I then type in index1.html at the end (which is a real file [index.html does not exist]) That page displays. So I try typing in index.php which starts a download. Now I am able to navigate to .html files and css files. But the php is not working. Do I need to enable it in http.conf?

Thanks
Shawn

Howdy,

Index files should be displayed by default, and PHP files should work by default… so it sounds like there may be some things that were changed that we need to find.

Can you paste in the current VirtualHost config that you have for this particular domain? We can verify that everything in there looks normal.

Also, if you go into Virtualmin, and click Server Configuration -> Website Options, what is the PHP Execution Mode set to?

Lastly, if you type this command, what output do you receive:

grep -i sethandler /etc/httpd/conf.d/*.conf

Current VirtualHost config from httpd.conf

SuexecUserGroup "#503" "#503" ServerName {domain}.com ServerAlias www.{domain}.com ServerAlias webmail.{domain}.com ServerAlias admin.{domain}.com DocumentRoot /home/shawn/public_html ErrorLog /var/log/virtualmin/{domain}.com_error_log CustomLog /var/log/virtualmin/{domain}.com_access_log combined ScriptAlias /cgi-bin/ /home/shawn/cgi-bin/ ScriptAlias /awstats/ /home/shawn/cgi-bin/ DirectoryIndex index.html index.htm index.php index.php4 index.php5 Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch allow from all AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,Sy$ Action application/x-httpd-php5 /cgi-bin/php5.cgi AddType application/x-httpd-php5 .php5 AddType application/x-httpd-php5 .php allow from all AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,Sy$ RewriteEngine on RewriteCond %{HTTP_HOST} =webmail.{domain}.com RewriteRule ^(.*) http://{domain}.com:20000/ [R] RewriteCond %{HTTP_HOST} =admin.{domain}.com RewriteRule ^(.*) https://{domain}.com:10000/ [R] RemoveHandler .php RemoveHandler .php5 php_admin_value engine Off Alias /dav /home/shawn/public_html Alias /pipermail /var/lib/mailman/archives/public DAV on AuthType Basic AuthName "{domain}.com" AuthUserFile /home/shawn/etc/dav.digest.passwd Require valid-user ForceType text/plain Satisfy All RemoveHandler .php RemoveHandler .php5 RewriteEngine off AuthName "{domain}.com statistics" AuthType Basic AuthUserFile /home/shawn/.awstats-htpasswd require valid-user RedirectMatch /cgi-bin/mailman/([^/\.]*)(.cgi)?(.*) https://{domain}.com:$ RedirectMatch /mailman/([^/\.]*)(.cgi)?(.*) https://{domain}.com:10000/vi$

The “PHP script execution mode” is set to

CGI wrapper (run as virtual server owner)

And lastly the result of
grep -i sethandler /etc/httpd/conf.d/*.conf
is
/etc/httpd/conf.d/perl.conf:# SetHandler perl-script
/etc/httpd/conf.d/perl.conf:# SetHandler perl-script
/etc/httpd/conf.d/php.conf:SetHandler application/x-httpd-php

Do I need to re-install php?

Ah, while you currently have the recommended vendor-supplied PHP version installed, it looks like you have PHP config files that come from a third party.

That likely means your server at one point was using a third party PHP package, and the config files from it still reside on your system, and are currently causing some problems.

Here’s what I’d recommend for starters –

Edit the file /etc/httpd/conf.d/php.conf, and comment out this line:

SetHandler application/x-httpd-php

And then restart Apache:

/etc/init.d/httpd restart

Once you do that, does PHP execute properly on your system?

-Eric

It is working now! Thank you SO much!

Shawn