{"id":3619,"date":"2019-02-26T02:23:03","date_gmt":"2019-02-26T02:23:03","guid":{"rendered":"http:\/\/myprojects.advchaweb.com\/?p=3619"},"modified":"2022-06-02T13:56:21","modified_gmt":"2022-06-02T13:56:21","slug":"install-magento-2-3-on-ubuntu-16-04-and-nginx","status":"publish","type":"post","link":"https:\/\/myprojects.advchaweb.com\/index.php\/2019\/02\/26\/install-magento-2-3-on-ubuntu-16-04-and-nginx\/","title":{"rendered":"Install Magento 2.3 on Ubuntu 16.04 and Nginx"},"content":{"rendered":"<ol>\n<li>Download the magento 2.3 with sample data from this link: https:\/\/magento.com\/tech-resources\/download<br \/>\nI download the file Magento-CE-2.3.0_sample_data-2018-11-27-10-26-20.tar.bz2<\/li>\n<li>Extract the zip or tar.bz2 file to the web root. I extract the file into mce230 directory<\/li>\n<li>Check the php version (CLI and PHP-FPM). Make sure php version is 7.2\n<pre class=\"lang:default decode:true \">teddy@teddy:~$ php -v\r\nPHP 7.0.33-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Dec  7 2018 08:27:52) ( NTS )\r\nCopyright (c) 1997-2017 The PHP Group\r\nZend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies\r\n    with Zend OPcache v7.0.33-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2017, by Zend Technologies\r\n    with Xdebug v2.6.1, Copyright (c) 2002-2018, by Derick Rethans<\/pre>\n<p>change it to php 7.2<\/p>\n<pre class=\"lang:default decode:true \">teddy@teddy:~$ sudo ln -sfn \/usr\/bin\/php7.2 \/etc\/alternatives\/php<\/pre>\n<p>check again<\/p>\n<pre class=\"lang:default decode:true \">teddy@teddy:~$ php -v\r\nPHP 7.2.14-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Jan 13 2019 10:05:18) ( NTS )\r\nCopyright (c) 1997-2018 The PHP Group\r\nZend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies\r\n    with Zend OPcache v7.2.14-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies\r\n    with Xdebug v2.6.1, Copyright (c) 2002-2018, by Derick Rethans<\/pre>\n<p>Also check the php-fpm version: http:\/\/localhost:8080\/phpinfo.php<br \/>\nIf not php 7.2, change it like this:<\/p>\n<pre class=\"lang:default decode:true \">teddy@teddy:~$ sudo gedit \/etc\/nginx\/sites-available\/default<\/pre>\n<p>Modify to enable php7.2-fpm<\/p>\n<pre class=\"lang:default decode:true \">server {\r\n\tlisten 8080 default_server;\r\n\tlisten [::]:8080 default_server;\r\n\r\n\t...\r\n\r\n\t# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000\r\n\t#\r\n\tlocation ~ \\.php$ {\r\n\t\tinclude snippets\/fastcgi-php.conf;\r\n\t#\r\n\t#\t# With php7.0-cgi alone:\r\n\t#\tfastcgi_pass 127.0.0.1:9000;\r\n\t#\t# With php7.0-fpm:\r\n\t\tfastcgi_pass unix:\/run\/php\/php7.2-fpm.sock; #ENABLE\r\n\t#\tfastcgi_pass unix:\/run\/php\/php7.0-fpm.sock;\r\n\t#\tfastcgi_pass unix:\/run\/php\/php5.6-fpm.sock;\r\n\t}\r\n\r\n\t...\r\n}\r\n...<\/pre>\n<p>Then save and restart nginx server.<br \/>\ncheck again the php-fpm version: http:\/\/localhost:8080\/phpinfo.php<br \/>\nNow it&#8217;s PHP Version 7.2.14-1+ubuntu16.04.1+deb.sury.org+1<br \/>\nNOTE: I foundSOME EXTENSIONS ARE MISSING. SO INSTALL THEM<\/p>\n<pre class=\"lang:default decode:true \">sudo apt-get install php7.2-bcmath php7.2-soap<\/pre>\n<p>&nbsp;<\/li>\n<li>Create the config file\n<pre class=\"lang:default decode:true\">teddy@teddy:~$ sudo gedit \/etc\/nginx\/sites-available\/mce230.test<\/pre>\n<p>Here is the content:<\/p>\n<pre class=\"lang:default decode:true \">server {\r\n    listen 80;\r\n    server_name mce230.test;\r\n    set $MAGE_ROOT \/home\/teddy\/Documents\/works\/mce230;\r\n\r\n    root $MAGE_ROOT;\r\n\r\n    index index.php;\r\n    autoindex off;\r\n    charset UTF-8;\r\n    error_page 404 403 = \/errors\/404.php;\r\n    #add_header \"X-UA-Compatible\" \"IE=Edge\";\r\n    client_max_body_size 100M;\r\n\r\n    # PHP entry point for setup application\r\n    location ~* ^\/setup($|\/) {\r\n        root $MAGE_ROOT;\r\n        location ~ ^\/setup\/index.php {\r\n            fastcgi_split_path_info ^(.+?\\.php)(\/.*)$;\r\n            fastcgi_buffers 1024 4k; \r\n            fastcgi_read_timeout 600s; \r\n            fastcgi_connect_timeout 600s;\r\n            fastcgi_pass unix:\/run\/php\/php7.2-fpm.sock; #FOR AWS SERVER\r\n            #fastcgi_pass 127.0.0.1:9000;\r\n            #fastcgi_index index.php;\r\n            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\r\n            include fastcgi_params;\r\n        }\r\n\r\n        location ~ ^\/setup\/(?!pub\/). {\r\n            deny all;\r\n        }\r\n\r\n        location ~ ^\/setup\/pub\/ {\r\n            add_header X-Frame-Options \"SAMEORIGIN\";\r\n        }\r\n    }\r\n\r\n    # PHP entry point for update application\r\n    location ~* ^\/update($|\/) {\r\n        root $MAGE_ROOT;\r\n\r\n        location ~ ^\/update\/index.php {\r\n            fastcgi_split_path_info ^(\/update\/index.php)(\/.+)$;\r\n            fastcgi_pass unix:\/run\/php\/php7.2-fpm.sock; #FOR AWS SERVER\r\n            #fastcgi_pass 127.0.0.1:9000;\r\n            fastcgi_index index.php;\r\n            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\r\n            fastcgi_param PATH_INFO $fastcgi_path_info;\r\n            include fastcgi_params;\r\n        }\r\n\r\n        # Deny everything but index.php\r\n        location ~ ^\/update\/(?!pub\/). {\r\n            deny all;\r\n        }\r\n\r\n        location ~ ^\/update\/pub\/ {\r\n            add_header X-Frame-Options \"SAMEORIGIN\";\r\n        }\r\n    }\r\n\r\n    location \/ {\r\n        try_files $uri $uri\/ \/index.php?$args;\r\n    }\r\n\r\n    location \/pub\/ {\r\n        location ~ ^\/pub\/media\/(downloadable|customer|import|theme_customization\/.*\\.xml) {\r\n            deny all;\r\n        }\r\n        alias $MAGE_ROOT\/pub\/;\r\n        add_header X-Frame-Options \"SAMEORIGIN\";\r\n    }\r\n\r\n\r\n    location ~ ^\/pub\/static\/version {\r\n        rewrite ^\/pub\/static\/(version\\d*\/)?(.*)$ \/pub\/static\/$2 last;\r\n    }\r\n\r\n    location \/static\/ {\r\n        # Uncomment the following line in production mode\r\n        # expires max;\r\n\r\n        # Remove signature of the static files that is used to overcome the browser cache\r\n        location ~ ^\/static\/version {\r\n            rewrite ^\/static\/(version\\d*\/)?(.*)$ \/static\/$2 last;\r\n        }\r\n\r\n        location ~* \\.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {\r\n            add_header Cache-Control \"public\";\r\n            add_header X-Frame-Options \"SAMEORIGIN\";\r\n            expires +1y;\r\n\r\n            if (!-f $request_filename) {\r\n                rewrite ^\/static\/(version\\d*\/)?(.*)$ \/static.php?resource=$2 last;\r\n            }\r\n        }\r\n\r\n        location ~* \\.(zip|gz|gzip|bz2|csv|xml)$ {\r\n            add_header Cache-Control \"no-store\";\r\n            add_header X-Frame-Options \"SAMEORIGIN\";\r\n            expires off;\r\n\r\n            if (!-f $request_filename) {\r\n                rewrite ^\/static\/(version\\d*\/)?(.*)$ \/static.php?resource=$2 last;\r\n            }\r\n        }\r\n\r\n        if (!-f $request_filename) {\r\n            rewrite ^\/static\/(version\\d*\/)?(.*)$ \/static.php?resource=$2 last;\r\n        }\r\n\r\n        add_header X-Frame-Options \"SAMEORIGIN\";\r\n    }\r\n\r\n    location \/media\/ {\r\n        try_files $uri $uri\/ \/get.php?$args;\r\n\r\n        location ~ ^\/media\/theme_customization\/.*\\.xml {\r\n            deny all;\r\n        }\r\n\r\n        location ~* \\.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {\r\n            add_header Cache-Control \"public\";\r\n            add_header X-Frame-Options \"SAMEORIGIN\";\r\n            expires +1y;\r\n            try_files $uri $uri\/ \/get.php?$args;\r\n        }\r\n\r\n        location ~* \\.(zip|gz|gzip|bz2|csv|xml)$ {\r\n            add_header Cache-Control \"no-store\";\r\n            add_header X-Frame-Options \"SAMEORIGIN\";\r\n            expires off;\r\n            try_files $uri $uri\/ \/get.php?$args;\r\n        }\r\n\r\n        add_header X-Frame-Options \"SAMEORIGIN\";\r\n    }\r\n\r\n    location \/media\/customer\/ {\r\n        deny all;\r\n    }\r\n\r\n    location \/media\/downloadable\/ {\r\n        deny all;\r\n    }\r\n\r\n    location \/media\/import\/ {\r\n        deny all;\r\n    }\r\n\r\n    # PHP entry point for main application\r\n    location ~ (index|get|static|report|404|503)\\.php$ {\r\n        try_files $uri =404;\r\n        fastcgi_pass unix:\/run\/php\/php7.2-fpm.sock; #FOR AWS SERVER\r\n        #fastcgi_pass 127.0.0.1:9000;\r\n        fastcgi_buffers 1024 4k;\r\n\r\n        fastcgi_read_timeout 600s;\r\n        fastcgi_connect_timeout 600s;\r\n        # to configure profiler in Magento 2\r\n        fastcgi_param  MAGE_PROFILER html;\r\n\r\n        fastcgi_index index.php;\r\n        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\r\n        #include fastcgi_params;\r\n        #FOR DEVELOPMENT MODE ONLY - BEGIN\r\n        fastcgi_param MAGE_IS_DEVELOPER_MODE true;\r\n        fastcgi_param PHP_VALUE  display_startup_errors=on;\r\n        fastcgi_param PHP_VALUE  display_errors=on;\r\n        fastcgi_param PHP_VALUE  html_errors=on;\r\n        fastcgi_param PHP_VALUE  log_errors=on;\r\n        fastcgi_param PHP_VALUE  error_log=\/home\/teddy\/Documents\/works\/mce230\/var\/log\/system.log;\r\n        #FOR DEVELOPMENT MODE ONLY - END\r\n        include fastcgi_params;\r\n        #FOR DEBUGGING WITH XDEBUG - BEGIN\r\n        #fastcgi_read_timeout 600;\r\n        #FOR DEBUGGING WITH XDEBUG - END\r\n    }\r\n\r\n    gzip on;\r\n    gzip_disable \"msie6\";\r\n\r\n    gzip_comp_level 6;\r\n    gzip_min_length 1100;\r\n    gzip_buffers 16 8k;\r\n    gzip_proxied any;\r\n    gzip_types\r\n    text\/plain\r\n    text\/css\r\n    text\/js\r\n    text\/xml\r\n    text\/javascript\r\n    application\/javascript\r\n    application\/x-javascript\r\n    application\/json\r\n    application\/xml\r\n    application\/xml+rss\r\n    image\/svg+xml;\r\n    gzip_vary on;\r\n\r\n    # Banned locations (only reached if the earlier PHP entry point regexes don't match)\r\n    location ~* (\\.php$|\\.htaccess$|\\.git) {\r\n        deny all;\r\n    }\r\n}<\/pre>\n<p>&nbsp;<\/li>\n<li>Enable file config\n<pre class=\"lang:default decode:true\">teddy@teddy:~$ sudo ln -s \/etc\/nginx\/sites-available\/mce230.test \/etc\/nginx\/sites-enabled\/mce230.test<\/pre>\n<p>&nbsp;<\/li>\n<li>Register the host on my system\n<pre class=\"lang:default decode:true\">sudo gedit \/etc\/hosts<\/pre>\n<p>Like this:<\/p>\n<pre class=\"lang:default decode:true\">...\r\n127.0.0.1 \tmce230.test\r\n...<\/pre>\n<p>&nbsp;<\/li>\n<li>CHECK THE NGINX SETTING AND RESTART IT:\n<pre class=\"lang:default decode:true\">teddy@teddy:~$ sudo nginx -t\r\nnginx: [warn] conflicting server name \"\" on 0.0.0.0:80, ignored\r\nnginx: the configuration file \/etc\/nginx\/nginx.conf syntax is ok\r\nnginx: configuration file \/etc\/nginx\/nginx.conf test is successful\r\nteddy@teddy:~$ sudo service nginx restart<\/pre>\n<p>&nbsp;<\/li>\n<li>Set file permission and owner:\n<pre class=\"lang:default decode:true\">teddy@teddy:~\/Documents\/works\/mce230$ sudo su\r\nroot@teddy:\/home\/teddy\/Documents\/works\/mce230# find var vendor pub\/static pub\/media app\/etc -type f -exec chmod g+w {} \\;\r\nroot@teddy:\/home\/teddy\/Documents\/works\/mce230# find var vendor pub\/static pub\/media app\/etc -type d -exec chmod g+ws {} \\;\r\nroot@teddy:\/home\/teddy\/Documents\/works\/mce230# chown -R :www-data .\r\nroot@teddy:\/home\/teddy\/Documents\/works\/mce230# chmod u+x bin\/magento\r\nroot@teddy:\/home\/teddy\/Documents\/works\/mce230# exit\r\nexit<\/pre>\n<p>Then<\/p>\n<pre class=\"lang:default decode:true\">teddy@teddy:~\/Documents\/works\/mce230$ sudo chown www-data -R var\/ pub\/ app\/etc\/ setup\/ generated\/\r\nteddy@teddy:~\/Documents\/works\/mce230$ sudo chmod -R 777 var\/ pub\/ app\/etc\/ setup\/ generated\/<\/pre>\n<p>&nbsp;<\/li>\n<li>Run the first installation: http:\/\/mce230.test<br \/>\nIt&#8217;d be redirected to http:\/\/mce230.test\/setup\/#\/landing-install<br \/>\nNOTE: Don&#8217;t forget to create a new database &#8216;mce230&#8217; with utf8-general-ci via phpmyadmin (http:\/\/phpmyadmin.test:8080)<br \/>\nOK. So here is My Store Address : http:\/\/mce230.test\/<br \/>\nand Magento Admin Address: http:\/\/mce230.test\/admin_cereoy<br \/>\n<span class=\"rcp-restricted-content-message\">SORRY, ONLY ADMIN CAN SHOW THIS!<\/span><\/li>\n<\/ol>\n<p>NOTE: Don&#8217;t forget to compile after finishing the installation. If not, you&#8217;d get the ugly page.<\/p>\n<pre class=\"lang:default decode:true\">teddy@teddy:~\/Documents\/works\/mce230$ sudo su -s \/bin\/bash www-data \r\nwww-data@teddy:\/home\/teddy\/Documents\/works\/mce230$ php bin\/magento setup:upgrade --keep-generated &amp;&amp; php bin\/magento setup:di:compile &amp;&amp; php bin\/magento setup:static-content:deploy -f --language en_AU --language en_US &amp;&amp; php bin\/magento indexer:reindex &amp;&amp; php bin\/magento cache:clean &amp;&amp; php bin\/magento cache:flush<\/pre>\n<p>&nbsp;<\/p>\n<p>DONE<\/p>\n<p>BUGS:<br \/>\nSometimes the product images can&#8217;t be displayed! I tried to recompile with all the above commands but no avail<br \/>\nSolution: I need to resize the product images<\/p>\n<pre class=\"lang:default decode:true \">www-data@teddy:\/home\/teddy\/Documents\/works\/mce230$ php bin\/magento catalog:image:resize\r\n1\/3422 [&gt;---------------------]   0% &lt; 1 sec 66.2 MiB \t| \/m\/b\/mb01-blue   \r\n3\/3422 [&gt;----------------]   0% 2 secs 66.2 MiB \t| \/m\/b\/mb04-black-0_alt1   \r\n5\/3422 [&gt;----------------]   0% 3 secs 66.2 MiB \t| \/m\/b\/mb03-black-0_alt1  \r\n15\/3422 [&gt;----------------]   0% 12 secs 66.2 MiB \t| \/w\/b\/wb06-red-0_alt1.j  \r\n21\/3422 [&gt;----------------]   0% 18 secs 66.2 MiB \t| \/u\/g\/ug07-bk-0_alt1.jp  \r\n26\/3422 [&gt;----------------]   0% 22 secs 66.2 MiB \t| \/l\/u\/luma-yoga-brick.j  \r\n27\/3422 [&gt;----------------]   0% 22 secs 66.2 MiB \t| \/l\/u\/luma-foam-roller.  \r\n29\/3422 [&gt;--------]   0% 24 secs 66.2 MiB \t| \/l\/u\/luma-stability-ball-gray.  \r\n30\/3422 [&gt;--------]   0% 25 secs 66.2 MiB \t| \/l\/u\/luma-stability-ball-pink. \r\n456\/3422 [=&gt;-------]  13% 6 mins 66.2 MiB \t| \/w\/h\/wh08-white_alternate_1.jp \r\n500\/3422 [=&gt;-------]  14% 7 mins 66.2 MiB \t| \/w\/j\/wj04-white_alternate_1.jp \r\n801\/3422 [==&gt;------]  23% 11 mins 66.2 MiB \t| \/w\/s\/wsh12-red_main_1.jpg\r\nProduct images resized successfully<\/pre>\n<p>I think no need to wait until 100% to resize the images! because it&#8217;d take a long time. just refresh the page if you think if the process is already pretty long<\/p>\n<p>TO DISABLE THE CODE PROFILER ON THE M2 PAGE, MODIFY THE NGINX FILE (sudo gedit \/etc\/nginx\/sites-available\/mce230.test) THEN SET:<\/p>\n<pre class=\"lang:default decode:true \">#fastcgi_param  MAGE_PROFILER html;<\/pre>\n<p>THEN RESTART NGINX SERVER: sudo service nginx reload<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Download the magento 2.3 with sample data from this link: https:\/\/magento.com\/tech-resources\/download I download the file Magento-CE-2.3.0_sample_data-2018-11-27-10-26-20.tar.bz2 Extract the zip or tar.bz2 file to the web root. I extract the file into mce230 directory Check the php version (CLI and PHP-FPM). Make sure php version is 7.2 teddy@teddy:~$ php -v PHP 7.0.33-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Dec 7 &hellip; <a href=\"https:\/\/myprojects.advchaweb.com\/index.php\/2019\/02\/26\/install-magento-2-3-on-ubuntu-16-04-and-nginx\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Install Magento 2.3 on Ubuntu 16.04 and Nginx&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[71,17,78],"tags":[],"class_list":["post-3619","post","type-post","status-publish","format-standard","hentry","category-magento","category-ubuntu","category-ubuntu-16-04"],"_links":{"self":[{"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/posts\/3619","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/comments?post=3619"}],"version-history":[{"count":18,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/posts\/3619\/revisions"}],"predecessor-version":[{"id":7411,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/posts\/3619\/revisions\/7411"}],"wp:attachment":[{"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/media?parent=3619"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/categories?post=3619"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/tags?post=3619"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}