cancel
Showing results for 
Search instead for 
Did you mean: 

Impossible to install on clean Ubuntu 18.04 LAMP Stack

SOLVED

Impossible to install on clean Ubuntu 18.04 LAMP Stack

Just for the record. I just spend ±20 hours to install Magento2 on a Ubuntu 18.04 machine that hosts serveral websites. The php.ini, .htaccess, hostname.conf files etc are correct. mod_rewrite and all other extentions were added by

sudo apt install php7.3-intl  etc

etc, clean database "magento" was created in Mysql Server version: 5.7.29-0ubuntu0.18.04.1 (Ubuntu)  and i run the latest version of apache: 

Server version: Apache/2.4.29 (Ubuntu) Server built:   2020-03-13T12:26:16

 

First I tried the installation by the composer:

To get Magento 2 latest release you may want to use Github repository… Install Composer, Curl and other dependencies to get started…

sudo apt install curl git
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

 

That gave multiple times the error :

Installing magento/project-community-edition (2.3.4)

  - Installing magento/project-community-edition (2.3.4): Downloading (100%)         

Created project in /var/www/my-site-name/magento2

Loading composer repositories with package information 

[Composer\Downloader\TransportException]                                                                                  
  The "https://repo.packagist.org/packages.json" file could not be downloaded: failed to open stream: Connection timed out  

                                                                        

So that wont go. So I downloaded the magento.tar files, ftp-ed them to the folder on the webserver, run the privileges commands as stated. And finally run the install command from the prompt; that installed the magento on the webserver.:

Starting Magento installation:

File permissions check...

[Progress: 1 / 985]

Required extensions check...

[Progress: 2 / 985]......

.....

[Progress: 984 / 985]

Write installation date...

[Progress: 985 / 985]

[SUCCESS]: Magento installation complete.

[SUCCESS]: Magento Admin URI: /admin_14632us

Nothing to import.

Navigating to

https://www.mysite.nl/magento2/ 

showed the "Luma homepage"  

 

But there is now way you can go to the admin page. 

https://www.mysite.nl/magento2/admin_14632us

It just shows a 404 error. And i've looked up the forum for hints to correct this, but i give up.

 

My final conclusion; it's impossible to install, so people who depend on sales from the number of installed versions earn less than they should.

 

Adobe really should make a better install script! The current one is utterly rubbish.

I'll wait a few months to try again. For the moment i'll stick to the webshop i made myself. I feel bad for the people that have to work with this.

                                                   Best regards and good luck!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Impossible to install on clean Ubuntu 18.04 LAMP Stack

So i had the problem i couldn't reach the admin page right after installing Magento2 on a clean system. I finally solved it by adding an extra subdomain to my website that is not :443 enabled, but only :80 for running the setup function. It seems that on a existing website running HTTPS, you can't use the setup, because the HTTPS protocol wont let you.

 

What errors were displayed:

 

I got the "Magento Setup - 401 Unauthorized Access" Error when typing  example.com/setup displaying this:

 

Schermafbeelding 2020-04-11 om 11.47.21.png

Or i had the 404 "page not found error" when using the URI example.com/admin_XXXX 

 

The solution is to add a extra sub-domain on the website containing the magento2 folder.

 

First of all i went to the DNS section of my provider and added an extra "A-record" for the subdomain webshop.example.com 

 

Then i added the new virtual domain to my apache2 configuration:

first navigate to the folder containing the files:

$ cd /etc/apache2/sites-available

use pico or vi to create the new config file:

sudo pico webshop.example.conf

and add the virtual host lines that configure the webshop.example.com sub-domain:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName webshop.example.nl
    ServerAlias webshop.example.nl
# i uploaded all magento2 files to the folder webshop
#most of you will use magento2
    DocumentRoot /var/www/example/webshop

    #i use seperate log files for every hosted domain:
    ErrorLog ${APACHE_LOG_DIR}/webshop_example_error.log
    CustomLog ${APACHE_LOG_DIR}/webshop_example_access.log combined

#my magento2 files are in the folder named "webshop"
#most of you will use magento2 as foldername
<Directory "/var/www/example/webshop">
Options +ExecCGI +Indexes +FollowSymLinks +MultiViews
AllowOverride all
Require all granted
RewriteEngine on
</Directory>

RewriteEngine on
</VirtualHost>

Safe the file.  Then load it to the active sites set on the webserver by using:

sudo a2ensite webshop.example.conf

restart apache2 and check if it is functioning correct:

sudo systemctl reload apache2
systemctl status apache2.service

If there are any errors they are displayed. correct them. if it's running fine you'll get:

:/etc/apache2/sites-available$ systemctl status apache2.service
● apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
           └─apache2-systemd.conf
   Active: active (running) (Result: exit-code) since Fri 2020-04-10 22:08:23 CEST; 14h ago

 Now i can access the admin part by navigating to :

 

http://webshop.example.nl/admin_xXXX

 HTTP!!!!!!!!!!!!!!! not HTTPS and it shows:

Schermafbeelding 2020-04-11 om 12.21.38.png 

View solution in original post

3 REPLIES 3

Re: Impossible to install on clean Ubuntu 18.04 LAMP Stack

Hello @systemerror 

 

Please refer the below link:

https://magento.stackexchange.com/q/89125/24801

Can you please try to access admin URL by adding index.php

 

I hope it helps.

Problem solved? Click Kudos and "Accept as Solution".
200+ Magento 2 Extensions for Enhanced Shopping Experience.

Re: Impossible to install on clean Ubuntu 18.04 LAMP Stack

Thanks for the link, i've checked it and noticed the last part:

  <Directory /var/www/html>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            allow from all
 </Directory>

Normally i set the line "allow from all" to "Require all granted" also stated in the documentation.

As i'm adding magento2 to an existing virtual hosted website, i need to use the username of that website in stead of "magento" because otherwise i can't copy the new magento files to a subdir of that site. The website, shall be called example.com.

 

Inside /etc/apache2/sites-anabled/ there are the 2 main-config-files (80, 443) for settings used by that virtual hosted site. First the non ssl port 80 one: example.conf

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example
    ErrorLog ${APACHE_LOG_DIR}/example.com_error.log
    CustomLog ${APACHE_LOG_DIR}/example.com_access.log combined
    Alias /awstatsclasses "/usr/share/awstats/lib/"
    Alias /awstats-icon/ "/usr/share/awstats/icon/"
    Alias /awstatscss "/usr/share/doc/awstats/examples/css"
    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    ScriptAlias /awstats/ /usr/lib/cgi-bin/
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch


<Directory "/usr/lib/cgi-bin/">
AuthUserFile /etc/apache2/htpasswd
AuthName "Add your password for this area"
AuthType Basic
Require valid-user
</Directory>

<Directory "/var/www/example.com/webshop">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Require all granted
</Directory>

RewriteEngine on
RewriteCond %{SERVER_NAME} =www.example.com [OR]
RewriteCond %{SERVER_NAME} =example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

 

Notice: RewriteEngine is on!

 

 And the SSL one: example-ssl.conf

 

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerAdmin webmaster@localhost
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example
    ErrorLog ${APACHE_LOG_DIR}/example.com_error.log
    CustomLog ${APACHE_LOG_DIR}/example.com_access.log combined
    Alias /awstatsclasses "/usr/share/awstats/lib/"
    Alias /awstats-icon/ "/usr/share/awstats/icon/"
    Alias /awstatscss "/usr/share/doc/awstats/examples/css"
    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    ScriptAlias /awstats/ /usr/lib/cgi-bin/
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch


<Directory "/usr/lib/cgi-bin/">
AuthUserFile /etc/apache2/htpasswd
AuthName "Add password "
AuthType Basic
Require valid-user
</Directory>


#added for MAGENTO
<Directory "/var/www/example/webshop">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Require all granted
</Directory>

RewriteEngine on

Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
Header always set Strict-Transport-Security "max-age=31536000"

#added for magento
#https://devdocs.magento.com/guides/v2.3/install-gde/prereq/apache.html
# Allow encoded slashes
AllowEncodedSlashes NoDecode

</VirtualHost>
</IfModule>

Notice: RewriteEngine is on!

 

All traffic is redirected to SSL by the rewrite rule mentioned in the last lines of example.conf

 

All security headers are activated on my site example.com , so it get's a A+ in the securityheaders.io check

 

All php7.3 modules needed for magento were checked by using:

https://devdocs.magento.com/guides/v2.3/install-gde/prereq/php-settings.html

php -m informed that missing modules ( e.g. ext-bcmath)

had to be added to my php installation, and that was done by using e.g.

 

sudo apt install php7.3-bcmath

finally php -m listed all required modules.

 

 

Next I altered the php.ini file according to:

https://devdocs.magento.com/guides/v2.3/install-gde/prereq/php-settings.html

$ sudo pico /etc/php/7.3/apache2/php.ini

changed the lines memory_limit=1G

short_open_tag = On 

The in the documentation mentioned line "asp_tags=" is not anymore inside PHP.INI because it was dropped in version 7.0, so this is obsolete:

 

https://www.php.net/manual/en/ini.core.php

mentiones:

asp_tags	"0"	PHP_INI_PERDIR	Removed in PHP 7.0.0.

Then i added the new database "magento" to my MySQL prog.

Instructions used:

 

https://devdocs.magento.com/guides/v2.3/install-gde/prereq/mysql.html

These instructions are missing one important line!

 

You also need to make a password for the mysql-user "magento" and that is not mentioned.

So these lines should be done in MySQL:

$ mysql -u root -p;
$ create database magento;
$ create user magento IDENTIFIED BY 'magento';
$ GRANT ALL ON magento.* TO magento@localhost IDENTIFIED BY 'magento';
$ alter user 'magento'@'localhost' identified with mysql_native_password by 'putyourpasswordhere';
$ flush privileges;


Now you can login as mysql-user magento with the provided password "putyourpassworehere" when typing mysql -u magento -p

 

I've downloaded the latest Magento-CE-2 package to my desktop, and ftp-ed it to the desired folder: example.com/webshop (for most of you example.com/magento2)

 

Now it's time to log in to the webserver with SSL and navigating to this folder in order to run the privileges scripts in order to set all the desired access settings:

 

 

https://www.linode.com/docs/websites/ecommerce/install-magento-on-ubuntu-18-04/#configure-apache

i used: 

sudo find var vendor pub/static pub/media app/etc -type f -exec chmod g+w {} \;
sudo find var vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} \;
sudo chown -R example:www-data .
sudo chmod u+x bin/magento

 

As i'm adding magento to an existing website, who's identified by the user example, i had to use that name. Most of you need to put in line 3 magento:www-data . in stead of example...

(and notice the . in that line), because you're using the apache user magento for this install.

 

Next: installing Magento CE according to the linode steps.

Use for the installation the apache user name that is used for the website where you're installing to. In my case example. So I run

Su example

to run the install script of magento as the apache user example.

Navigate to the magento2 installer folder on the website:

cd /var/www/example/webshop/ (in most cases /var/www/example/magento2/)

and as i'm in Europe I had to add to the script the lines 

--language="nl_NL" --currency="EUR" --timezone="Europe/Amsterdam"

The script became:

$ ./magento setup:install --base-url="https://www.example.com/webshop" --admin-firstname="Myfirstname" --admin-lastname="Mylastname" --admin-email="myemail" --admin-user="myname" --admin-password="mypass" --db-name="magento" --db-host="localhost" --db-user="magento" --db-password="mysqlpass" --language="nl_NL" --currency="EUR" --timezone="Europe/Amsterdam"

Notice that a lot of text editors mess up the -- characters, if so the script will stall; stating:

                                                     
  Too many arguments, expected arguments "command".  
                                                     

 

 The mysql part of the installation works fine. All lines and tables are created by the installer.

 

Write installation date...

[Progress: 985 / 985]

[SUCCESS]: Magento installation complete.

[SUCCESS]: Magento Admin URI: /admin_xxxxxXX

Nothing to import.

 

The "Luma demo-site" also showed up on example.com/webshop

But the example.com/webshop/admin_xxxxxXX that was generated by the script didn't.

 

 

After running the installer, a huge lot(!) of .htaccess files are created in all folders of example.com/webshop where magento2 is installed. (most of you will install it in example.com/magento2) I used Cyberduck (ftp-prog) to rename a few of these .htaccess files, and i was suprised to see that a lot of them contain the lines:

 

 

Options -Indexes

<IfModule mod_rewrite.c>
    RewriteEngine Off
</IfModule>

The one above was inside example.com/webshop/setup/ (for most of you example.com/magento2/setup

 

The RewriteEngine was here turned off! Is that done on purpose?

 

Navigating to example.com/webshop/setup/  gives a webpage showing the magento logo with the sentence "Welcome.... => navigate to System =>Tools => Web Setup Wizzard with a 401 error.

 

Navigating to example.com/webshop/admin_xxxXXX gives a 404

 

Now i'm stuck, because i can't access the admin area.

 

 

 

 

 

Re: Impossible to install on clean Ubuntu 18.04 LAMP Stack

So i had the problem i couldn't reach the admin page right after installing Magento2 on a clean system. I finally solved it by adding an extra subdomain to my website that is not :443 enabled, but only :80 for running the setup function. It seems that on a existing website running HTTPS, you can't use the setup, because the HTTPS protocol wont let you.

 

What errors were displayed:

 

I got the "Magento Setup - 401 Unauthorized Access" Error when typing  example.com/setup displaying this:

 

Schermafbeelding 2020-04-11 om 11.47.21.png

Or i had the 404 "page not found error" when using the URI example.com/admin_XXXX 

 

The solution is to add a extra sub-domain on the website containing the magento2 folder.

 

First of all i went to the DNS section of my provider and added an extra "A-record" for the subdomain webshop.example.com 

 

Then i added the new virtual domain to my apache2 configuration:

first navigate to the folder containing the files:

$ cd /etc/apache2/sites-available

use pico or vi to create the new config file:

sudo pico webshop.example.conf

and add the virtual host lines that configure the webshop.example.com sub-domain:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName webshop.example.nl
    ServerAlias webshop.example.nl
# i uploaded all magento2 files to the folder webshop
#most of you will use magento2
    DocumentRoot /var/www/example/webshop

    #i use seperate log files for every hosted domain:
    ErrorLog ${APACHE_LOG_DIR}/webshop_example_error.log
    CustomLog ${APACHE_LOG_DIR}/webshop_example_access.log combined

#my magento2 files are in the folder named "webshop"
#most of you will use magento2 as foldername
<Directory "/var/www/example/webshop">
Options +ExecCGI +Indexes +FollowSymLinks +MultiViews
AllowOverride all
Require all granted
RewriteEngine on
</Directory>

RewriteEngine on
</VirtualHost>

Safe the file.  Then load it to the active sites set on the webserver by using:

sudo a2ensite webshop.example.conf

restart apache2 and check if it is functioning correct:

sudo systemctl reload apache2
systemctl status apache2.service

If there are any errors they are displayed. correct them. if it's running fine you'll get:

:/etc/apache2/sites-available$ systemctl status apache2.service
● apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
           └─apache2-systemd.conf
   Active: active (running) (Result: exit-code) since Fri 2020-04-10 22:08:23 CEST; 14h ago

 Now i can access the admin part by navigating to :

 

http://webshop.example.nl/admin_xXXX

 HTTP!!!!!!!!!!!!!!! not HTTPS and it shows:

Schermafbeelding 2020-04-11 om 12.21.38.png