<\/span><\/h2>\nFirst, you will need to login to your server via SSH as the root user:<\/p>\n
ssh root@IP_ADDRESS -p PORT_NUMBER<\/pre>\nand replace \u201cIP_ADDRESS\u201d and \u201cPORT_NUMBER\u201d with your actual server IP address and SSH port number.<\/p>\n
Once logged in, let\u2019s make sure that your Ubuntu 18.04 server is up-to-date by running the following commands:<\/p>\n
$ sudo apt-get update\r\n$ sudo apt-get upgrade<\/pre>\nThis will update the package index and will update the software currently installed on the server to the latest version.<\/p>\n
Once your system is fully up-to-date, we can now proceed with the OpenCart installation.<\/p>\n
<\/span>2. Install the MySQL Database Server<\/span><\/h2>\nNext, we will install the MySQL server. To install the default package, run the following command:<\/p>\n
$ sudo apt-get install mysql-server<\/pre>\nThis will install MySQL 5.7 on your server, but it will not prompt you to set a password or make any other configuration changes. Because this leaves your installation of MySQL insecure, in order to improve the security of your MySQL server, we recommend that you run the \u2018mysql_secure_installation<\/strong>\u2018 script by typing the following command:<\/p>\n$ mysql_secure_installation<\/pre>\nThis script will help you to perform important security tasks like setting up a root password, disable remote root login, remove anonymous users, etc.<\/p>\n
<\/span>3. Create a Database for OpenCart<\/span><\/h2>\nNow, we will create our MySQL database for our OpenCart site. Log in to your MySQL server with the following command and enter your MySQL root password:<\/p>\n
sudo mysql -u root -p<\/pre>\nIn this section, we will create a new MySQL database opencart<\/code> and assign user access to it to a new user admin_user<\/code> with the\u00a0password Strong_Password<\/code>:<\/p>\nCREATE DATABASE opencart;\r\nGRANT ALL PRIVILEGES ON opencart.* TO 'admin_user'@'localhost' IDENTIFIED BY 'Strong_Password';\r\nFLUSH PRIVILEGES;\r\nexit;<\/pre>\nDon\u2019t forget to replace \u2018Strong_Password\u2019 with an actual strong password.<\/p>\n
<\/span>4. Install Apache and PHP<\/span><\/h2>\nTo install the Apache web server, run the following command:<\/p>\n
$ sudo apt-get install apache2<\/pre>\nAfter the installation is complete, you should enable Apache to start automatically upon server reboot with:<\/p>\n
$ sudo systemctl enable apache2<\/pre>\nYou can also check the status of your Apache service with the following command:<\/p>\n
$ sudo systemctl status apache2<\/pre>\nOutput:<\/p>\n
apache2.service - The Apache HTTP Server\r\n Loaded: loaded (\/lib\/systemd\/system\/apache2.service; enabled; vendor preset:\r\n Drop-In: \/lib\/systemd\/system\/apache2.service.d\r\n \u2514\u2500apache2-systemd.conf\r\n Active: active (running)\r\n Process: 728 ExecStart=\/usr\/sbin\/apachectl start (code=exited, status=0\/SUCCES\r\n Main PID: 855 (apache2)\r\n Tasks: 6 (limit: 2321)\r\n CGroup: \/system.slice\/apache2.service\r\n \u251c\u2500855 \/usr\/sbin\/apache2 -k start\r\n \u251c\u2500876 \/usr\/sbin\/apache2 -k start\r\n \u251c\u2500877 \/usr\/sbin\/apache2 -k start\r\n \u251c\u2500878 \/usr\/sbin\/apache2 -k start\r\n \u251c\u2500879 \/usr\/sbin\/apache2 -k start\r\n \u2514\u2500880 \/usr\/sbin\/apache2 -k start\r\n<\/pre>\nSince OpenCart is a PHP-based application, our next step is to install PHP and some PHP extensions required by OpenCart:<\/p>\n
$ sudo apt-get install php libapache2-mod-php<\/pre>\n$ sudo apt-get install php-cli php-common php-mbstring php-gd php-intl php-xml php-mysql php-zip \r\nphp-curl php-xmlrpc<\/pre>\nRestart the Apache web server to load the PHP modules:<\/p>\n
$ sudo systemctl restart apache2<\/pre>\nNow check the PHP version installed on your server:<\/p>\n
$ php -v<\/pre>\nOutput:<\/p>\n
PHP 7.2.10-0ubuntu0.18.04.1 (cli) (built: Sep 13 2018 13:45:02) ( 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.10-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies<\/pre>\n<\/span>5. Download the Latest Release of OpenCart<\/span><\/h2>\nThe latest version of OpenCart (v.3.0.3.1) can be downloaded from the OpenCart website (recommended for end users) or directly from Github (recommended for web developers). The download page also offers access to previous versions of OpenCart.<\/p>\n
$ sudo wget https:\/\/github.com\/opencart\/opencart\/releases\/download\/3.0.3.1\/opencart-3.0.3.1.zip\r\n$ sudo unzip opencart-3.0.3.1<\/pre>\n$ sudo mv upload\/ \/var\/www\/html\/opencart\r\n$ sudo cd \/var\/www\/html\/opencart\/\r\n$ sudo cp config-dist.php config.php\r\n$ sudo cp admin\/config-dist.php admin\/config.php<\/pre>\nThen run the commands below to set the correct permissions for OpenCart to function.<\/p>\n
$ sudo chown -R www-data:www-data \/var\/www\/html\/opencart\/<\/pre>\n