{"id":17124,"date":"2015-05-07T09:45:59","date_gmt":"2015-05-07T14:45:59","guid":{"rendered":"https:\/\/secure.rosehosting.com\/blog\/?p=17124"},"modified":"2022-12-16T03:45:48","modified_gmt":"2022-12-16T09:45:48","slug":"install-magento-on-a-centos-7-vps-with-nginx-php-fpm-and-mariadb","status":"publish","type":"post","link":"https:\/\/www.rosehosting.com\/blog\/install-magento-on-a-centos-7-vps-with-nginx-php-fpm-and-mariadb\/","title":{"rendered":"Install Magento on CentOS 7, with Nginx, PHP-FPM and MariaDB"},"content":{"rendered":"
Magento is a very popular and feature rich open source e-commerce web application. Magento is fully customizable to meet the users requirements and allowing them to create and launch a fully functional online store in minutes. In this tutorial we will show you how to install Magento on a CentOS 7 VPS<\/a> with Nginx web server, PHP-FPM and MariaDB.<\/p>\n <\/p>\n As usual, log in to your server as user root and make sure that your CentOS 7 VPS is fully up-to-date<\/p>\n Magento needs a database, so we will install MariaDB server and create an empty database for the store<\/p>\n Start the MariaDB server and enable it to start on boot<\/p>\n Run the mysql_secure_installation post-installation script to improve the security of the MariaDB server and set the root password.<\/p>\n Now, log in to the MariaDB server console and create a database<\/p>\n Don’t forget to change PASSWORD with an actual strong password.<\/p>\n Next, we will install Nginx web server. It is not available by default in CentOS 7 so we will use the official Nginx repository<\/p>\n Start the Nginx web server and enable to start on boot<\/p>\n Install PHP and few PHP modules<\/p>\n Now, go the Magento’s official website and download the latest stable version. At the moment of writing this article it is version 1.9.1.0<\/p>\n Unpack the Magento archive to the document root directory on your server<\/p>\n The content of the archive will be unpacked in a new ‘magento’ directory inside the document root.<\/p>\n Set proper permissions:<\/p>\n Create an Nginx virtual block for your domain with the following content<\/p>\n Replace all instances of magentoodomain.com with your own domain name. and restart Nginx for the changes to take effect.<\/p>\n We are done with the command line installation. Now, launch the web based Magento installer by accessing http:\/\/magentodomain.com and complete the required the steps to finish the installation<\/p>\n Of course you don\u2019t have to do any of this if you use one of our Linux VPS Hosting<\/a> services, in which case you can simply ask our expert Linux admins to install Magento for you. They are available 24\u00d77 and will take care of your request immediately. You can also checkout our guide on How to Install Magento 2 on CentOS 8<\/a>.<\/p>\n PS.<\/span><\/strong> If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.<\/p>\n","protected":false},"excerpt":{"rendered":" Magento is a very popular and feature rich open source e-commerce web application. Magento is fully customizable to meet the … <\/p>\nyum -y update<\/pre>\n
yum install mariadb mariadb-server<\/pre>\n
systemctl start mariadb\r\nsystemctl enable mariadb<\/pre>\n
mysql -u root -p<\/pre>\n
mysql> CREATE DATABASE magentodb;\r\nmysql> GRANT ALL PRIVILEGES ON magentodb . * TO magentouser@'localhost' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;\r\nmysql> FLUSH PRIVILEGES;<\/pre>\n
rpm -UVh http:\/\/nginx.org\/packages\/centos\/7\/noarch\/RPMS\/nginx-release-centos-7-0.el7.ngx.noarch.rpm\r\nyum install nginx<\/pre>\n
systemctl start nginx\r\nsystemctl enable nginx<\/pre>\n
yum install php php-fpm php-cli php-mysql php-curl php-gd<\/pre>\n
wget http:\/\/www.magentocommerce.com\/downloads\/assets\/1.9.1.0\/magento-1.9.1.0.tar.gz<\/pre>\n
tar -xvzf magento-1.9.1.0.tar.gz -C \/var\/www\/html\/\r\nrm magento-1.9.1.0.tar.gz<\/pre>\n
cd \/var\/www\/html\/magento\r\nchmod -R o+w app\/etc\/\r\nchmod -R o+w var\/\r\nchmod -R o+w media\/<\/pre>\n
nano \/etc\/nginx\/conf.d\/magentodomain.conf\r\n\r\nserver {\r\nlisten 80 default;\r\nserver_name www.magentoodomain.com *.magentoodomain.com;\r\nroot \/var\/www\/html\/magento\r\n\r\nlocation \/ {\r\nindex index.html index.php;\r\ntry_files $uri $uri\/ @handler;\r\nexpires 30d;\r\n}\r\n\r\nlocation ^~ \/app\/\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 { deny all; }\r\nlocation ^~ \/includes\/\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 { deny all; }\r\nlocation ^~ \/lib\/\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 { deny all; }\r\nlocation ^~ \/media\/downloadable\/ { deny all; }\r\nlocation ^~ \/pkginfo\/\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 { deny all; }\r\nlocation ^~ \/report\/config.xml\u00a0\u00a0 { deny all; }\r\nlocation ^~ \/var\/\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 { deny all; }\r\n\r\nlocation \/var\/export\/ {\r\nauth_basic\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"Restricted\";\r\nauth_basic_user_file htpasswd;\r\nautoindex\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 on;\r\n}\r\n\r\nlocation\u00a0 \/. {\r\nreturn 404;\r\n}\r\n\r\nlocation @handler {\r\nrewrite \/ \/index.php;\r\n}\r\n\r\nlocation ~ .php\/ {\r\nrewrite ^(.*.php)\/ $1 last;\r\n}\r\n\r\nlocation ~ .php$ {\r\nif (!-e $request_filename) { rewrite \/ \/index.php last; }\r\n\r\nexpires\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 off;\r\nfastcgi_pass\u00a0\u00a0 127.0.0.1:9000;\r\nfastcgi_param\u00a0 HTTPS $fastcgi_https;\r\nfastcgi_param\u00a0 SCRIPT_FILENAME\u00a0 $document_root$fastcgi_script_name;\r\nfastcgi_param\u00a0 MAGE_RUN_CODE default;\r\nfastcgi_param\u00a0 MAGE_RUN_TYPE store;\r\ninclude\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 fastcgi_params; ## See \/etc\/nginx\/fastcgi_params\r\n}\r\n}<\/pre>\n
systemctl restart nginx<\/pre>\n