The PHP CGI cannot be accessed directly.

So i am trying to install magento 2.1.6 using the instal script and this is the message that it displays when it fails to install. I am new to ubuntu and even newer to Virtual Min Professional. Can i get assistance on resolving this. Also magento 2.1.6 support php 7.0 so that cannot be the issue here

Security Alert! The PHP CGI cannot be accessed directly.

This PHP CGI binary was compiled with force-cgi-redirect enabled. This means that a page will only be served up if the REDIRECT_STATUS CGI variable is set, e.g. via an Apache Action directive.

For more information as to why this behaviour exists, see the manual page for CGI security.

For more information about changing this behaviour or re-enabling this webserver, consult the installation file that came with this distribution, or visit the manual page.



zeddenit's picture
Submitted by zeddenit on Tue, 05/30/2017 - 15:55

I have added cgi.force_redirect = 0 to php.ini file and retried the install but failed again with same msg I changed it to cgi.force_redirect = 1 in php.ini and re tried and it has failed furhur more leading to apache2 service unable to start

Howdy -- sorry that you're having a problem with the Magento Install Script!

Is this a problem that you're just experiencing with one domain? Or are you seeing this issue with multiple domains?

Also, if you look in Server Configuration -> Website Options, what PHP Execution Mode is the domain using?

zeddenit's picture
Submitted by zeddenit on Wed, 05/31/2017 - 09:05

So i see the instal script was changed from 2.1.6 to 2.1.5 (lol) no issue tried to run the install script on 2 different domains same result. Checked as requested Server configuration> Website options> here are the current settings

Run CGI scripts as domain owner? Yes
PHP script execution mode CGI wrapper (run as virtual server owner) Maximum PHP script run time 30 seconds Ruby script execution mode Ruby scripts disabled Website matches all sub-domains? No Allow use of server-side includes? Global default Default website for IP address? No Webserver access log file /var/log/virtualmin/carlsitservices.com_access_log Webserver error log file /var/log/virtualmin/carlsitservices.com_error_log Website documents sub-directory public_html

I did switch PHP script execution mode to FCGId (run as virtual server owner) and tried to run the instal script but same result.

Are you running Ubuntu 16.04 there?

It does appear to be Ubuntu 16.04... zeddenit, just to verify though, what is the output of these two commands:

cat /etc/issue
php -v


I have same issue When trying installing Magento version 2.1.7.

xxxxxxxxxx@xxxxxxxxx:~# cat /etc/issue
Ubuntu 16.04.2 LTS \n \l

xxxxxxx@xxxxxxxx:~# php -v
PHP 7.0.18-0ubuntu0.16.04.1 (cli) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.18-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies

Found solution to this as mentioned above

just changing to "Apachemod_php (run as Apache's user)" link

Thanks for all the info!

Once you get Magento installed, are you then able to switch back to FCGID or CGI?

Or do you continue to receive that error if so?

After you finish installing Magento 2.x you will need to switch back to "CGI wrapper (run as virtual server owner)" otherwise you will be having problems with permissions when Magento dos cache or static-content deployment.

After you switched "CGI wrapper (run as virtual server owner)" go to Magento installation root and change folder permissions to 0777 "All (recursive)" for "pub" and "var" folders

Then open ssh using (virtual server owner) for current Virtualmin with and cd to Magento installation root

Then run few terminal commands

php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy

for this you migth need to ad en_GB or de_DE after space if you runing other languge backend/frontend or multiple websites setup for other languges when en_US

php bin/magento indexer:reindex
php bin/magento cache:flush

Hope that will help you