Ubuntu14.04 install LNMP_MySQL

Source: Internet
Author: User
Ubuntu14.04 install LNMP LNMPUbuntu

We usually use centos to build LNMP, but we usually use the ubuntu Desktop version for debugging during development. The following describes in detail how to install an LNMP on ubuntu.

1. download and install the latest ubuntu14.04 desktop version

II. install mysql

1. download the latest mysql version, for example:
Wgethttp: // dl.mysql.cn/mysql5/5.5/mysql-5.5.25.tar.gz

2. decompress:
Tar-xvf mysql-5.5.25.tar.gz

3. go to the mysql file directory:
Cd mysql-5.5.25

Note: the INSTALL-SOURCE file contains the installation guide. For more information, see.

4. mysql needs to be compiled using cmake. install cmake first:
Sudo apt-get install cmake

5. install the g ++ compiler
Sudo apt-get install g ++

6. install the dependent Library libncurses
Sudo apt-get install libncurses5-dev

7. renewal
Cmake.
Make
Sudo make install

8. add mysql groups and users
Groupadd mysql
Useradd-r-g mysql

9. go to the mysql installation directory.
Cd/usr/local/mysql

10. change owner and group
Sudo chown-R mysql.
Sudo chgrp-R mysql.

11. create a database
Sudo scripts/mysql_install_db -- user = mysql

12. change owner
Sudo chown-R root.
Sudo chown-R mysql data

13. Generate the mysql configuration file
Sudo cp support-files/my-medium.cnf/etc/my. cnf

14. start mysql
Sudo bin/mysqld_safe -- user = mysql &

15. execute the following command to start the mysql command line tool. if it can be correctly started, mysql is successfully installed.
/Usr/local/mysql/bin/mysql

II. install PHP

1. download the PHP source code package:
Wgethttp: // cn2.php.net/distributions/php-5.5.12.tar.gz

2. decompress:
Tar-xvf php-5.5.12.tar.gz

3. install the dependent Library
Sudo apt-get install libxml2-dev openssl libcurl3-openssl-dev libcurl4-gnutls-dev libjpeg-dev libpng-dev libxpm-dev libfreetype6-dev libt1-dev libmcrypt-dev libxslt1-dev

4. go to the source code directory.
Cd php-5.5.12

5. execute the configuration command
. /Configure -- prefix =/usr/local/php -- with-config-file-path =/usr/local/php/etc -- with-mysql =/usr/local/mysql -- with-mysqli =/usr/local/mysql/bin/mysql_config -- with-iconv-dir =/usr/local -- with-freetype-dir -- with-jpeg-dir --- png-dir -- with-zlib -- with-libxml-dir =/usr -- enable-xml -- disable-rpath -- enable-bcmath -- enable-shmop -- enable-sysvsem -- enable-inline -optimization -- with-curl -- enable-mbregex -- enable-fpm -- enable-mbstring -- with-mcrypt -- with-gd -- enable-gd-native-ttf -- with-openssl -- -mhash -- enable-pcntl -- enable-sockets -- with-xmlrpc -- enable-zip -- enable-soap -- without-pear -- with-zlib -- enable-pdo -- with-pdo-mysql

7. run the following command before compilation
Ln-s/usr/local/mysql/lib/libmysqlclient. so.18/usr/lib/

8. Compile and install
Make
Sudo make install

9. Generate the php configuration file php. ini
Sudo cp./php. ini-production/usr/local/php/etc/php. ini

10. start php
/Usr/local/php/bin/php-cgi-B 9000 &

3. install Nginx

1. download the Nginx source code package:
Wgethttp: // nginx.org/download/nginx-1.7.0.tar.gz

2. extract
Tar-xvf nginx-1.7.0.tar.gz

3. install the dependent Library
Sudo apt-get install libpcre3 libpcre3-dev

4. go to the source code directory.
Cd nginx-1.7.0

5. run the configuration command
./Configure -- prefix =/usr/local/nginx -- with-http_ssl_module -- with-http_flv_module -- with-http_gzip_static_module

6. Compile and install
Make
Sudo make install

7. modify the nginx configuration file:
Sudo gedit/usr/local/nginx/conf/nginx. conf &

8. find the following content in the file and remove.
Location ~ /. Php $ {
Root html;
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
# Fastcgi_param SCRIPT_FILENAME/scripts $ fastcgi_script_name;
Fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;
Include fastcgi_params;
}
Note: The above fastcgi_param parameter must be written as "$ document_root $ fastcgi_script_name ;".

9. start nginx
Sudo/usr/local/nginx/sbin/nginx &


4. test the connection between nginx, php, and mysql.

1. enter 127.0.0.1 in the browser to check if any nginx prompt is displayed.

2. create an index. php file in the/usr/local/nginx/html directory and add the following line

3. change the attributes of index. php.
Sudo chmod ugo + rwx-R/usr/local/nginx/html/index. php

4. enter 127.0.0.1/index. php in the browser to check whether php information is displayed.

5. finally, test the connection between php and mysql, and replace the content in index. php with the following:
$ Con = mysql_connect ("127.0.0.1", "root", null );
Mysql_select_db ("information_schema", $ con );
$ Result = mysql_query ("SELECT * FROM USER_PRIVILEGES ");
$ Row = mysql_fetch_row ($ result );
Echo $ row [0];
Mysql_close ($ con );
?>

6. input 127.0.0.1/index. php in the browser. the following information indicates that the connection between nginx, php, and mysql is normal.
'Root' @ 'localhost

Related Article

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.