2013-11-25

LEMP is a combination of operating system and open-source software stack. The acronym LEMP is derived from first letters of Linux, Nginx HTTP Server, MySQL/MariaDB database, and PHP or Perl or Python. We already have shown you how to install LAMP on many platforms.

In this tutorial i will describe how to install nginx, MariaDB and PHP on openSUSE 13.1.

Install Nginx

Nginx (pronounced as engine-x) is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server written by Igor Sysoev. According to netcraft web server survey 14.08% web sites are served by Nginx.

Nginx is found in the official openSUSE repository, so let us install Nginx with following command:

Start Nginx and make it to start automatically on every reboot:

Stop Apache or any other web servers if you have any:

By default webserver is accessible as localhost. If you want to access it from a remote machine, you should allow webserver default port 80 through your firewall/router.

Add the following line in it.

Restart firewall:

Test Apache

Create a new index.html file under /srv/www/htdocs/,

Add the following line.

Open your web browser and navigate to http://localhost/ or http://server-ip-address/.

Nginx web server has been installed now.

Configure Nginx

Open the file /etc/nginx/nginx.conf and set the worker_processes (i.e No. of CPU’s in your system).

To see the no. of CPU’s, use the command “lscpu”. In my case it’s “1″. So I set this as ’1′:

Define the virtual hosts information in server section.

Save and close the file. Restart Nginx service:

Install MariaDB

MariaDB is a drop in replacement for MySQL. It is a robust, scalable and reliable SQL server that comes rich set of enhancements.

Now start installing MariaDB:

Start MariaDB service and let it to start automatically on every reboot:

Set MySQL root password

By default MySWL root password is empty. So to prevent unauthorized access to MySQL, let us set root user password:

Sample output:

Install PHP

PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely used open-source general purpose scripting language that is especially suited for web development and can be embedded into HTML.

Install PHP with following command:

Before start php5-fpm service, let us rename the file /etc/php5/fpm/php-fpm.conf.default to /etc/php5/fpm/php-fpm.conf.

Open up php-fpm.conf file,

and change the user and group values from nobody to nginx:

Save and close the file.

Open file /etc/php5//fpm/php-fpm.conf,

Find the line error_log. Uncomment and set the value as /var/log/php-fpm.log.

There is no php.ini file for php-fpm on openSUSE 13.1, so let us copy it from /etc/php5/cli/ to /etc/php5/fpm/ as shown below.

Now edit file /etc/php5/fpm/php.ini,

Find the line cgi.fix_pathinfo, uncomment it and change the value from 1 to 0 (zero):

Save and close the file.

Now start php-fpm service.

Test PHP

Create a sample “testphp.php” file in Apache document root folder and append the lines as shown below:

Add the following line in it.

Restart nginx service:

Navigate to  http://server-ip-address/testphp.php. It will display all the details about php such as version, build date and commands etc.

If you want to install all PHP modules, enter the command zypper in php* and restart the Nginx service. To verify for the modules, open up your eb browser and navigate to http://server-ip-address/testphp.php. You will able to see all PHP modules.

Install phpMyAdmin (Optional)

phpMyAdmin is a free open-source web interface tool used to manage your MySQL databases.phpMyAdmin is available in the openSUSE default repositories. So let us install it using command:

phpMyAdmin is found under /srv/www/htdocs/ directory. We need it under /usr/share/ directory. So Let us create a symlink using the following command:

Then open the nginx.conf file,

Add the lines shown in red colour within the server {} section.

Save and close the file. Restart nginx service.

Now navigate to http://localhost/phpMyAdmin or http://ip-address/phpMyAdmin. You should see the following like screen. Enter the mysql root username and root user password.

This is how your phpMyAdmin Dashboard looks.

Now you will able to manage mysql databases graphically using phpMyAdmin.

That’s it. You should have a working LEMP server now. Congrats!

---------------------------------------------------------------------
Install LEMP Server (Nginx, MariaDB and PHP-FPM) on openSUSE 13.1

Show more