Video Walkthroughs at Superb Internet
close
Domain Name / Customer ID:

Password:

Forgot Password

All material © 1996 - 2024 Superb Internet Technologies Inc. // version-1.50.33
« Back to all videos

LEMP installation on CentOS

LEMP installation on CentOS

This video tutorial shows you how to install LEMP, which includes Linux, nginx, MySQL, and PHP, the open-source solution stack, on your CentOS server. The server is already running CentOS, thus the Linux part already intact. Implement the following steps to install the remaining components of the LEMP stack.

  1. To begin, update your server by typing, yum update at the command prompt and press Enter. It will take a few moments to update.
  2. Then, when prompted, type y and press Enter.

Once the update is complete, begin installing the required repositories by executing the following:

  1. At the command prompt, type:
    rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
    and press Enter.
  2. Next, type:
    rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
    and press Enter.

Install MySQL

  1. Then, you can install the MySQL server by executing the following:
    yum install mysql mysql-server
    , and press Enter.
  2. When, prompted, type y, and press Enter.
  3. You then need to restart MySQL by entering /etc/init.d/mysqld restart, and press Enter. This will take a few moments to run.
  4. You can configure the MySQL by running the following command:
    /usr/bin/mysql_secure_installation
    , and press Enter.
  5. Next, you will set a new root password to ensure that unauthorized users cannot login to the MySQL. At the initial prompt to enter your current root password, leave it blank and press Enter.
  6. When you are prompted to set root password, type y, and press Enter
  7. You are then prompted to enter your new password. Notice that the new password cannot be left blank. Enter your new password, press Enter, then re-enter the new password to confirm it and press Enter again.
  8. When asked whether to remove anonymous users, type y and press Enter
  9. When asked whether to disallow root login remotely, type y and press Enter
  10. When asked whether to remove test database and access to it, type y and press Enter
  11. When asked whether to reload privilege tables now, type y and press Enter

Install nginx

  1. To install nginx, execute the following from the command prompt: yum install nginx and press Enter
  2. When prompted, type y and press Enter
  3. To start nginx, execute the following:
    /etc/init.d/nginx start
    , and press Enter.
  4. To confirm that the nginx is installed open your web browser and direct your browser to your server's public domain name or IP address, you may need to reload the page.

Install PHP

  1. To install PHP execute the following at the command prompt.
    yum--enablerepo=remi install php-fpm php-mysql
    and press Enter.

You will see the installation in progress, which can take a few moments. You can safely disregard the warnings.

  1. When prompted, type y and press Enter
  2. On the next yes, no question, type y, and press Enter.
  3. Now, you will change the PHP configuration by editing it using the vi editor At the command prompt, enter vi /etc/php.ini, and press Enter.
  4. To locate the needed line type: /cgi.fix_pathinfo=1, and press Enter.
  5. To start editing, press the Insert. key. In the line you just located, change the value from number 1 to 0 and delete the semicolon from the beginning of the line
  6. Now, press the Esc. key to escape insert mode and save the changes by executing a colon, w.
  7. Press Enter. and exit the vi editor with a :q. and press Enter.
  8. To configure nginx, execute the following command.
    vi /etc/nginx/nginx.conf
    and press Enter.
  9. Next, locate the line, worker processes 1;. In that line, change the value from 1. to 4. by pressing the Insert. key and changing the value.
  10. Press the Esc. key to escape insert mode and save the changes with a :w.
  11. Press Enter. and exit the vi editor with a :q. and press Enter.
  12. To configure the nginx host execute the following at the command prompt:
    vi /etc/nginx/conf.d/default.conf
    , and press Enter.
  13. Then, press the Insert. key to start editing the file.
  14. First, locate the server_name line and change it to server_name [your domain name].com;.
  15. Next, locate the index line, under location/ { and change it to index index.php index.html index.htm;. Uncomment the entire section beginning with location - \.php$ {, by deleting the # sign from the lines.
  16. Then, change the line that states fastcgi_param SCRIPT_FILENAME, to fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;.
  17. Uncomment the include line by removing the number sign.
  18. Uncomment the #{, by removing the # sign.
  19. Press the Esc. key to escape the insert mode and save the changes with a :w.
  20. Press Enter. and exit the vi editor with a :q. and press Enter.
  21. Now you need to edit the configuration of the php-fpm, also known as the FastCGI Process Manager. At the command prompt type
    vi /etc/php-fpm.d/www.conf
    and press Enter.
  22. Next, locate the line that states user=apache, and press the Insert. key. Then, change the line to user = nginx
  23. You then need to locate the group=apache line and change it to group = nginx and press the Esc key to escape the insert mode.
  24. Then, save the changes with a :w.
  25. Press Enter. and exit the vi editor with a :q. and press Enter.
  26. Now you need to restart the php-fpm. At the command prompt, run
    service php-fpm restart
    and press Enter.
  27. To create the php.info page, execute
    vi /usr/share/nginx/html/info.php
    , and press Enter.
  28. Now, you can start editing. Press the Insert. key and enter the following lines:
    <?php
    phpinfo();
    ?>
    press the Esc key to escape insert mode.
  29. Save the changes with a :w.
  30. Press Enter. and exit the vi editor with a :q. and press Enter.
  31. For the changes to take effect, you will need to restart the nginx server by executing service nginx restart.
  32. Then, you need to open your web browser and direct it to http://www.[your domain name].com/info.php You will see the php.info page displaying information about PHP’s configuration on your screen.
  33. Next, you will set up auto start of the newly installed programs. From the command line, execute the following:
    chkconfig --levels 235 mysqld on
    , and press Enter.
  34. Then retype the line above, but replace mysqld, with nginx. Press Enter. and input the same line as the one above, but change nginx to php-fpm, and press Enter.

You have now successfully installed LEMP on your CentOS server. Thank you for joining us, and check back often for new tutorials.


comments powered by Disqus