How to configure nginx to let magento execute php files.
For example I created phpinfo.php
and I'd like to execute it.
Where should I put it? ./
or ./pub/
?
What do I need to write into the config ?
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityHow to configure nginx to let magento execute php files.
For example I created phpinfo.php
and I'd like to execute it.
Where should I put it? ./
or ./pub/
?
What do I need to write into the config ?
If you use the official Nginx config (nginx.conf.sample
file in the Magento 2 distribution) then you need change the line 109 from :
location ~ (index|get|static|report|404|503)\.php$ {
to :
location ~ (index|get|static|report|404|503|phpinfo)\.php$ {
and place phpinfo.php
to the pub
subfolder because pub
declared as document root at line 21:
root $MAGE_ROOT/pub;
I use my own Nginx config for Magento 2 and it permits phpinfo.php
in the root folder.
sudo systemctl restart nginx
Don't be confuse so much. I have done magento2 installation with nginx and varnish caching. Please follow the below steps.
Step 1-: Install required packages
$ sudo apt-get install software-properties-common
$ sudo add-apt-repository -y ppa:ondrej/mysql-5.6
$ sudo add-apt-repository -y ppa:ondrej/php5-5.6
$ sudo apt-add-repository -y ppa:duggan/composer
$ sudo apt-get update
$ sudo apt-get install -y php5-fpm nginx varnish php5-gd php5-intl php5-mcrypt php5-xsl mysql-server php5-curl php5-json php5-composer
$ sudo php5enmod mcrypt
Step 2-: Create a database to install magento2.
mysql -p -e "create database magento2"
Step 3-: Varnish server setup.
sudo nano /etc/default/varnish
Default configuration replace from
DAEMON_OPTS="-a :6081 \
-T localhost:6082 \
-f /etc/varnish/default.vcl \
-S /etc/varnish/secret \
-s malloc,256m"
To
DAEMON_OPTS="-a :80 \
-T localhost:6082 \
-f /etc/varnish/default.vcl \
-S /etc/varnish/secret \
-s malloc,1024m"
Check default.vcl file port
nano /etc/varnish/default.vcl
Output-:
backend default {
.host = "127.0.0.1";
.port = "8080";
}
Configure the nginx.conf to listen port 8080.