I’ve searched all over Digitalocean and I find a lot of questions about how to install Magento on centos 7 with nginx but non do really explain properly step by step “how to”.
It would be nice if we could help eachother out here to write everything that is needed from simple security to how to how to set up proper permissions for Magento.
I could begin and then someone with the knowledge could just fill in further in the comments:
Step 0: Initial Centos 7 setup https://www.digitalocean.com/community/tutorials/initial-server-setup-with-centos-7
Step 1: Install Centos 7 with LEMP, follow this guide: https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-centos-7
Step 2: Additional Steps for a new Centos 7 server https://www.digitalocean.com/community/tutorials/additional-recommended-steps-for-new-centos-7-servers
Step 3: Download Magento 1.9.1.0 Please write in the comments how to do this, and then someone else could write Step 4 in the comments. Thank you!
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Would it be possible if someone could explain how to configure /etc/nginx/conf.d/default.conf to use multistore configuration if I use more than two domains, for example domain.com and domain.net
rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
yum -y upgrade
yum install mariadb mariadb-server mysql vim-enhanced nginx php-fpm php-mysql php-pear php-bcmath php-common php-gd php-pdo php-pdo-mysql php-mcrypt
edit /etc/my.cnf.d/server.cnf
bind-address = 127.0.0.1
run the following:
systemctl restart mariadb; systemctl enable mariadb; mysql_secure_installation
cat /proc/cpuinfo |grep processor -c
if the number returns is anything other than “1”, edit “/etc/nginx/nginx.conf”
Run nginx -t
systemctl restart nginx; systemctl enable nginx
Edit /etc/php.ini
date.timezone = America/Chicago
Edit /etc/php-fpm.d/www.conf
user = nginx
group = nginx
Run this to set the logs properly:
chown nginx:root /var/log/php-fpm -R
Start php-fpm:
systemctl restart php-fpm; systemctl enable php-fpm
Create your document root
mkdir -p /srv/www/YOUR_DOMAIN_GOES_HERE
chown nginx:nginx -R /srv/www
Download Magento (you will need to sign up for their site)
SCP/SFTP it to your server (I just dropped it in /root/)
Untar it, move the files around, and set ownership:
cd /srv/www/YOUR_DOMAIN_GOES_HERE
tar zxf ~/magento-1.9.1.0.tar.gz; mv magento* .
mv magento/.htaccess* .
cd /srv/
chown nginx:nginx * -R
Next, we need to set up the hostfile for the site. Edit /etc/nginx/conf.d/default.conf, and put this in there (changing all instances of “YOUR_DOMAIN_GOES_HERE” with your domain/sub-domain):
server {
listen 80 default;
## SSL directives might go here
server_name YOUR_DOMAIN_GOES_HERE www.YOUR_DOMAIN_GOES_HERE; ## Domain is here twice so server_name_in_redirect will favour the www
root /srv/www/YOUR_DOMAIN_GOES_HERE;
location / {
index index.html index.php; ## Allow a static html file to be shown first
try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler
expires 30d; ## Assume all files are cachable
}
## These locations would be hidden by .htaccess normally
location ^~ /app/ { deny all; }
location ^~ /includes/ { deny all; }
location ^~ /lib/ { deny all; }
location ^~ /media/downloadable/ { deny all; }
location ^~ /pkginfo/ { deny all; }
location ^~ /report/config.xml { deny all; }
location ^~ /var/ { deny all; }
location /var/export/ { ## Allow admins only to view export folder
auth_basic "Restricted"; ## Message shown in login window
auth_basic_user_file htpasswd; ## See /etc/nginx/htpassword
autoindex on;
}
location /. { ## Disable .htaccess and other hidden files
return 404;
}
location @handler { ## Magento uses a common front handler
rewrite / /index.php;
}
location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
rewrite ^(.*.php)/ $1 last;
}
location ~ .php$ { ## Execute PHP scripts
if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss
expires off; ## Do not cache dynamic content
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param MAGE_RUN_CODE default; ## Store code is defined in administration > Configuration > Manage Stores
fastcgi_param MAGE_RUN_TYPE store;
include fastcgi_params; ## See /etc/nginx/fastcgi_params
}
}
Run this:
nginx -t
If there aren’t any errors, restart nginx:
systemctl restart nginx
Next, we need to hop on MariaDB:
mysql -p
Now, to add the database & user/pass (Change the database name, user, and pass to what you want):
CREATE DATABASE magento;
GRANT ALL PRIVILEGES ON magento.* TO 'magento_user'@'localhost' IDENTIFIED BY 'YOUR_PASS_GOES_HERE';
Finally, go to the server IP or domain and go through the setup.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.