Install LNMP in Ubuntu

Source: Internet
Author: User
I have always said on the Internet that Nginx has the performance advantage in handling high connections, so I hope to try it out. Here we will talk about how to install the Nginx service in Ubuntu. 1. During mysqlsudoapt-getinstallmysql-servermysql-client installation, enter the password of the root user. 2. Install nginxsudoapt-getinstallnginx3. Install

I have always said on the Internet that Nginx has the performance advantage in handling high connections, so I hope to try it out.

Here we will talk about how to install the Nginx service in Ubuntu.

1. Install mysql

  1. Sudo apt-get install mysql-server mysql-client

Enter the root user password during installation.

2. Install nginx

  1. Sudo apt-get install nginx

3. After the installation is successful. Restart the nginx service.

  1. Sudo service nginx restart

After starting, we can access the following address. See if the nginx welcome page is available.

4. Here we use php5-fpm for our php parsing.

  1. Sudo apt-get install php5-fpm

5. Next, we need to modify the nginx site configuration.

Ngnix configuration files are stored in/etc/nginx/sites-availble/default

  1. Server {
  2. Listen 80; # listen for ipv4; this line is default and implied
  3. Listen [:]: 80 default ipv6only = on; # listen for ipv6
  4. Root/usr/share/nginx/www;
  5. Index. php index.html index.htm;
  6. # Make site accessible from http: // localhost/
  7. Server_name _;
  8. Location /{
  9. # First attempt to serve request as file, then
  10. # As directory, then fall back to index.html
  11. Try_files $ uri // index.html;
  12. }
  13. Location/doc {
  14. Root/usr/share;
  15. Autoindex on;
  16. Allow 127.0.0.1;
  17. Deny all;
  18. }
  19. # Error_page 404/404 .html;
  20. # Redirect server error pages to the static page/50x.html
  21. #
  22. Error_page 500 502 503 x.html;
  23. Location =/50x.html {
  24. Root/usr/share/nginx/www;
  25. }
  26. # Proxy the PHP scripts to Apache listening on 127.0.0.1: 80
  27. #
  28. # Location ~ \. Php $ {
  29. # Proxy_pass http: // 127.0.0.1;
  30. #}
  31. # Pass the PHP scripts to FastCGI server listening on Fig: 9000
  32. #
  33. Location ~ \. Php $ {
  34. Try_files $ uri = 404;
  35. Fastcgi_pass 127.0.0.1: 9000;
  36. Fastcgi_index index. php;
  37. Include fastcgi_params;
  38. }
  39. # Deny access to. htaccess files, if Apache's document root
  40. # Concurs with nginx's one
  41. #
  42. Location ~ /\. Ht {
  43. Deny all;
  44. }
  45. }

Added some php parsing code.

6. install some components related to php5.

  1. Sudo apt-cache search php5
  1. Apt-get install php5-mysql php5-curl php5-gd php5-intl php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp

7. Restart the service

  1. Sudo service php5-fpm restart
  2. Sudo service nginx

8. Try writing a probe file. Haha.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.