Before starting, enter the command below to check whether you have the proper OS version installed on your machine:<\/p>\n
# cat \/etc\/issue<\/pre>\nwhich should give you the underneath output. Of course if you use another openSUSE version the output will show that version:<\/p>\n
Welcome to openSUSE 13.1 \"Bottle\" - Kernel \\r (\\l)<\/pre>\n<\/p>\n
And now without further ado, we can begin by removing the pre-installed Apache web-server since we are replacing it with Nginx.<\/p>\n
To do that, first we’ll stop the service, disable it from autostart and then remove it. To do that, type the following commands in your command line interface:<\/p>\n
# systemctl stop apache2.service\r\n# systemctl disable apache2.service\r\n# zypper rm apache2<\/pre>\n<\/span>2. UPDATE THE SYSTEM<\/span><\/h2>\nNow that the Apache webserver has been removed, we can update the system. Type:<\/p>\n
# zypper up<\/pre>\nOnce the updates are finished, you can start setting up the LEMP stack by installing MySQL.\u00a0In our extensive experience in dealing with the beautiful operational system that is openSUSE we stumbled upon errors and couldn’t start MySQL due to missing PERL dependencies. In some cases we were getting the following error:<\/p>\n
FATAL ERROR: please install the following Perl modules before executing \/usr\/bin\/mysql_install_db:\r\nSys::Hostname\r\nCreation of MySQL databse in \/var\/lib\/mysql failed\r\nmysql.service: control process exited, code=exited status=1<\/pre>\nTo avoid this error, just install the Sys::Hostname<\/strong><\/em> PERL dependency with the following command:<\/p>\n# zypper install perl-Sys-Hostname-Long<\/pre>\n<\/span>3. Install MySQL<\/span><\/h2>\nWith that taken care of, you can now continue with the MySQL installation. Execute:<\/p>\n
# zypper install -y mysql-community-server mysql-community-server-client<\/pre>\n<\/span>4. Configure MySQL<\/span><\/h2>\nEnable MySQL to start on boot and then start the service:<\/p>\n
# systemctl enable mysql.service\r\n# systemctl start mysql.service<\/pre>\nDo the initial configuration of MySQL. Follow the on-screen messages as follows:<\/p>\n
# mysql_secure_installation steps:\r\n\r\n- Enter current password for root (enter for none):\r\n - Set root password? [Y\/n] Y\r\n - Remove anonymous users? [Y\/n] Y\r\n - Disallow root login remotely? [Y\/n] Y\r\n - Remove test database and access to it? [Y\/n] Y\r\n - Reload privilege tables now? [Y\/n] Y <\/code><\/pre>\n<\/span>5. Install Nginx<\/span><\/h2>\nNext, let’s install Nginx. Type:<\/p>\n
# zypper install -y nginx<\/pre>\n<\/span>6. Configure Nginx<\/span><\/h2>\nEnable Nginx to start on boot:<\/p>\n
# systemctl enable nginx.service<\/pre>\nIn case of ‘\/sbin\/insserv failed, exit code 1’ error, type:<\/strong><\/p>\n# insserv syslog<\/pre>\nand repeat:<\/p>\n
# systemctl enable nginx.service<\/pre>\nThen, start Nginx:<\/p>\n
# systemctl start nginx.service<\/pre>\nNow go to http:\/\/<yourdomain.com> or http:\/\/<your_ip_address> from your favorite browser. You should see the contents of the file index.html file that is stored in the document root for Nginx (\/srv\/www\/htdocs\/).<\/p>\n
We will now edit the Nginx configuration file. Make sure it resembles to the one we are posting, except for the lines you are sure you want them adjusted according to your needs. Note that this is only an initial config and it may vary depending on the website\/application you are about to host.<\/p>\n
# vim \/etc\/nginx\/nginx.conf<\/pre>\n<\/code>worker_processes\u00a0 2;\r\n\r\n\u00a0\u00a0\u00a0 sendfile\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 on;\r\n\r\n\u00a0\u00a0\u00a0 keepalive_timeout\u00a0 65;\r\n\r\n\u00a0\u00a0\u00a0 gzip\u00a0 on;\r\n\r\n\u00a0\u00a0\u00a0 include conf.d\/*.conf;\r\n\r\n\u00a0\u00a0\u00a0 server {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 listen\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 80;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 server_name\u00a0 _;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #charset koi8-r;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 location \/ {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 root\u00a0\u00a0 \/srv\/www\/htdocs\/;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 index index.php index.html index.htm;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 error_page\u00a0\u00a0 500 502 503 504\u00a0 \/50x.html;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 location = \/50x.html {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 root\u00a0\u00a0 \/srv\/www\/htdocs\/;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 location ~ \\.php$ {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 root\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/srv\/www\/htdocs\/;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 fastcgi_pass\u00a0\u00a0 127.0.0.1:9000;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 fastcgi_index\u00a0 index.php;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 include\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 fastcgi_params;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 # deny access to .htaccess files, if Apache's document root\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 # concurs with nginx's one\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 location ~ \/\\.ht {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 deny\u00a0 all;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }\r\n\u00a0\u00a0\u00a0 }<\/code><\/pre>\nSave and close the file. Test the Nginx config:<\/p>\n
# nginx -t<\/pre>\nIf everything is OK make the Nginx service aware of the changes by reloading it with the following command:<\/p>\n
# systemctl reload nginx.service<\/pre>\n