• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Resolved transvhosts.pl fails to update apache default DocumentRoot

massin

New Pleskian
Server operating system version
AlmaLinux 9.1
Plesk version and microupdate number
18.0.51 Update #1
Moving vhosts to a new drive following the documentation. The result is that the Apache default DocumentRoot is not updated:

Bash:
# plesk bin transvhosts.pl --dest-dir /mnt/data/vhosts/ --correct-scripts
Moving files to new directory...
Correct psa configuration file...
Correct passwd file...
Correct php-fpm pools configuration...
Restart plesk-php74-fpm service...
Correct Fail2Ban jails configuration...
ERROR:__main__:Iptables action with name="apache" already exists in jail apache-xmlrpc
File "/etc/fail2ban/jail.local" was stored successfully.
OK
Correct database...
Update hosting settings...
done
Update subdomains settings...
done
Update system users settings...
done
Update aps resources parameters...
done
Call to undefined method Service_Agent_Transport_Local::checkConnection()
Reconfigure aps applications...
done
Execution failed.
Command: httpdmng
Arguments: Array
(
    [0] => --reconfigure-server
    [1] => -no-restart
)

Details: [2023-04-12 06:30:47.721] 20555:6436b287af7b4 ERR [util_exec] proc_close() failed ['/usr/local/psa/admin/bin/apache-config' '-t'] with exit code [1]
[2023-04-12 06:30:48.462] 20555:6436b287af7b4 ERR [util_exec] proc_close() failed ['/usr/local/psa/admin/bin/apache-config' '-t'] with exit code [1]
[2023-04-12 06:30:48.950] 20555:6436b287af7b4 ERR [panel] Apache config (16813062470.34584500) generation failed: Template_Exception: AH00526: Syntax error on line 8 of /etc/httpd/conf/plesk.conf.d/server.conf:
DocumentRoot '/var/www/vhosts/default/htdocs' is not a directory, or is not readable

file: /usr/local/psa/admin/plib/Template/Writer/Webserver/Abstract.php
line: 75
code: 0
AH00526: Syntax error on line 8 of /etc/httpd/conf/plesk.conf.d/server.conf:
DocumentRoot '/var/www/vhosts/default/htdocs' is not a directory, or is not readable




Can`t reconfigure web server
Correct user scripts...

The variable is updated correctly in the psa.conf:
Bash:
# grep -r HTTPD_VHOSTS_D /etc/psa/psa.conf
HTTPD_VHOSTS_D /mnt/data/vhosts

Some other tools (e.g. the 'plesk repair fs' tool) also fails to see the updated configuration.

If I move the vhosts directory back, everything goes back to normal.

Any ideas of why the $VAR->server->webserver->httpDir is not getting set to the new value?
 
The skeleton directory was modified and is missing the /htdocs path. It would be good if the script could do without, but it expects the default configuration to run smoothly. To fix

"DocumentRoot '/var/www/vhosts/default/htdocs' is not a directory, or is not readable"

simply add /var/www/vhosts/default/htdocs with ownership root:root and mod 0755.
 
Thanks, Peter. I did that and then ran the reconfigure script, but I still get errors:

Bash:
# /usr/local/psa/admin/bin/httpdmng --reconfigure-all
Execution failed.
Command: httpdmng
Arguments: Array
(
    [0] => --reconfigure-domains
    [1] => example.com
)

Details: [2023-04-12 10:11:47.554] 6368:6436e6525a45a ERR [util_exec] proc_close() failed ['/usr/local/psa/admin/bin/apache-config' '-w' '/var/www/vhosts/system/example.com/conf/httpd.conf'] with exit code [101]
[2023-04-12 10:11:47.657] 6368:6436e6525a45a ERR [util_exec] proc_close() failed ['/usr/local/psa/admin/bin/apache-config' '-l' '/var/www/vhosts/system/example.com/conf/httpd.conf:/etc/httpd/conf/plesk.conf.d/vhosts/example.com.conf'] with exit code [100]
[2023-04-12 10:11:47.951] 6368:6436e6525a45a ERR [util_exec] proc_close() failed ['/usr/local/psa/admin/bin/apache-config' '-l' '/var/www/vhosts/system/example.com/conf/httpd.conf:/etc/httpd/conf/plesk.conf.d/vhosts/example.com.conf'] with exit code [100]
[2023-04-12 10:11:48.296] 6368:6436e6525a45a ERR [panel] Apache config (16813195060.15695800) generation failed: Template_Exception: mkdir: cannot create directory ‘/var/www/vhosts/system/example.com/conf’: No such file or directory
mktemp: failed to create file via template ‘/var/www/vhosts/system/example.com/conf/httpd.conf.XXXXXX’: No such file or directory
Can not create temporary file

file: /usr/local/psa/admin/plib/Template/Writer/Webserver/Abstract.php
line: 75
code: 0
mkdir: cannot create directory ‘/var/www/vhosts/system/example.com/conf’: No such file or directory
mktemp: failed to create file via template ‘/var/www/vhosts/system/example.com/conf/httpd.conf.XXXXXX’: No such file or directory
Can not create temporary file
 
Well, you need to check the error message that the script gives you and then check why that error exists. In this new case it seems that a domain directory is missing. The script only works if the expected directories and files are present. If something is missing, has wrong permissions, wrong ownership etc. it cannot work right.
 
To recap:
  • I'm moving the HTTPD_VHOSTS_D from the default (/var/www/vhosts) to another drive (/mnt/data/vhosts).
  • I got an error with apache after running the provided transvhosts.pl script (this is the initial comment in the thread) because the DocumentRoot didn't exist.
  • You suggested creating the missing directory (in the OLD vhosts location). I did this and that fixed the apache not starting issue, but none of the sites worked.
  • I ran the httpdmng --reconfigure-all script and got the errors in my second message.
So something is not right with the transvhosts.pl script in 18.0.51 Update #1 or I am doing something wrong.
 
If you've manually moved the vhosts directly yourself then ran the script, you're going to fail. The CORRECT way is to just run the script and it'll do the moving for you.
 
I ran the script. I didn't do anything manually (except for the suggestion to manually create the missing htdocs directory AFTER the script failed).
 
To recap again:

  • My GOAL (what I am tryng to achieve) is to move the vhosts from the default (/var/www/vhosts) to another drive (/mnt/data/vhosts).
  • I USED transvhosts.pl to make this move (see first comment in this thread).
  • The transvhosts.pl script did not change the DocumentRoot in Apache, which gave me the error starting apache (see first comment in this thread).
  • Peter - you told me to manually create the htdocs in the OLD directory structure (/var/www/vhosts) to fix the apache problem.
  • I created the directory as per your instructions.
  • Apache started, but none of the websites worked.
  • I tried running a reconfigure, but received errors about the OLD directory structure being missing. It's as though the change to the vhosts did not get set in the Plesk database. The psa.conf was updated properly, but still the scripts don't see the new vhosts directory that was defined USING the transvhosts.pl script.
I have NOT manually moved anything (I hope that is clear now). I have ONLY used transvhosts.pl.

So, no, this thread should not be closed as it hasn't resolved anything with the issue I've reported.
 
You may have created one missing directory, but on your additional attempt another missing directory or file was claimed by the script. I cannot tell you why these directories are missing from your installation. Have you considered to # plesk repair web all so that you can be sure that everything that shall be moved is in place and working before the move? Currently there seem to be missing directories and files in the paths of your server.
 
@Peter Debik - here is the output of running the repair (where Plesk is set to the default vhosts directory of /var/www/vhosts) and then running the transvhosts.pl script:

Bash:
# plesk repair web -y

Checking Plesk version .............................................. [OK]

Checking Apache configuration ....................................... [OK]

Checking for custom configuration templates ......................... [OK]

Checking associations between domains and IP addresses .............. [OK]

Checking for corrupted reference between IP collections and 
IPaddresses ......................................................... [OK]

Checking for links between APS applications and subscriptions ....... [OK]

Checking for nginx ULIMIT value ..................................... [OK]

Checking for extra configurations in database not owned by any object
................................................................... [OK]

Checking the status of the required Apache modules .................. [OK]

Checking the configuration of Apache modules ........................ [OK]

Checking web server configuration. Please wait
    Reinstalling SSL/TLS certificates ............................... [OK]
    Applying the default SSL/TLS certificate to all IP addresses .... [OK]
    Repairing web server configuration for all domains. This aspect 
    can be used with individual domains ("plesk repair web         
    example.com"), and on the server level ("plesk repair web") ..... [OK]
    Repairing server-wide configuration parameters for web servers .. [OK]

Checking the usage of PHP handlers .................................. [OK]

Checking for obsolete PHP-FPM configuration files ................... [OK]

Error messages: 0; Warnings: 0; Errors resolved: 0

# plesk bin transvhosts.pl --dest-dir /mnt/data/vhosts/ --correct-scripts
Moving files to new directory...
Correct psa configuration file...
Correct passwd file...
Correct php-fpm pools configuration...
Restart plesk-php74-fpm service...
Correct Fail2Ban jails configuration...
ERROR:__main__:Iptables action with name="apache" already exists in jail apache-xmlrpc
File "/etc/fail2ban/jail.local" was stored successfully.
OK
Correct database...
Update hosting settings...
done
Update subdomains settings...
done
Update system users settings...
done
Update aps resources parameters...
done
Call to undefined method Service_Agent_Transport_Local::checkConnection()
Reconfigure aps applications...
done
Execution failed.
Command: httpdmng
Arguments: Array
(
    [0] => --reconfigure-domains
    [1] => example.com
)

Details: [2023-04-13 07:40:45.264] 49812:6438146c13747 ERR [util_exec] proc_close() failed ['/usr/local/psa/admin/bin/apache-config' '-w' '/var/www/vhosts/system/example.com/conf/httpd.conf'] with exit code [101]
[2023-04-13 07:40:46.822] 49812:6438146c13747 ERR [util_exec] proc_close() failed ['/usr/local/psa/admin/bin/apache-config' '-l' '/var/www/vhosts/system/example.com/conf/httpd.conf:/etc/httpd/conf/plesk.conf.d/vhosts/example.com.conf'] with exit code [100]
[2023-04-13 07:40:47.143] 49812:6438146c13747 ERR [util_exec] proc_close() failed ['/usr/local/psa/admin/bin/apache-config' '-l' '/var/www/vhosts/system/example.com/conf/httpd.conf:/etc/httpd/conf/plesk.conf.d/vhosts/example.com.conf'] with exit code [100]
[2023-04-13 07:40:47.495] 49812:6438146c13747 ERR [panel] Apache config (16813968430.86448600) generation failed: Template_Exception: mkdir: cannot create directory ‘/var/www/vhosts/system/example.com/conf’: No such file or directory
mktemp: failed to create file via template ‘/var/www/vhosts/system/example.com/conf/httpd.conf.XXXXXX’: No such file or directory
Can not create temporary file

file: /usr/local/psa/admin/plib/Template/Writer/Webserver/Abstract.php
line: 75
code: 0
mkdir: cannot create directory ‘/var/www/vhosts/system/example.com/conf’: No such file or directory
mktemp: failed to create file via template ‘/var/www/vhosts/system/example.com/conf/httpd.conf.XXXXXX’: No such file or directory
Can not create temporary file




Can`t reconfigure web server
Correct user scripts...

Like I've said, something is not working with the transvhosts.pl script. Even after transvhosts.pl runs and updates the vhosts directory, the scripts still default back to /var/www/vhosts.
 
I think this looks like product issue PPPM-13949, sorry for not identifying this earlier. It is a known issue on Plesk Obsidian 18.0.51. Took me a while to understand this one.

The good news is: A workaround exists. In essence it is about manually editing the HTTPD_VHOSTS_D variable in a psa table, but to me it remains unclear whether afterwards transvhosts.pl shall be run again or whether the update will suffice. For that reason: A support engineer should look onto the system to determine what the situation is, which steps are missing etc.

 
Thanks, @Peter Debik - that was enough to point me in the right direction.

I figured out the table via the daily mysql dump. Then I first ran an update on the DB table to change the HTTPD_VHOSTS_D variable, followed by re-running the transvhosts.pl script ... this time there were no errors and everything looks like it is working.
 
Do actually do the change in SQL mentioned by @massin, run these commands:

To access SQL and the PSA database:
MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin psa

And then you can run the update query, like this:
update ServiceNodeEnvironment set value='/newpath' where name = 'HTTPD_VHOSTS_D';

It might require a reboot so Apaches config files are rewritten.
 
The issue has been resolved since Plesk Obsidian 18.0.52, published April 25th, 2023. It is again possible to change the location of virtual hosts using the transvhosts.pl utility.
 
Back
Top