Build and configure the LNMP server nginx + mysql + php environment in LinuxDebian _ MySQL

Source: Internet
Author: User
LNMP server in LinuxDebian-nginx + mysql + php environment construction and configuration of LNMPLinux server Nginxdebian

I just installed the LNMP server environment on the company's server yesterday. here, I will record the process in brief.

Here, I used the Dotdeb source during installation for reference only.

1. import the Dotdeb Source. it is said that the software version in the Dotdeb source is relatively new.

Before importing Dotdeb to the source, we need to obtain the GnuPG key and import it:

wget http://www.dotdeb.org/dotdeb.gpgcat dotdeb.gpg | apt-key add -

The prompt "OK" indicates that the import is successful. Then we start to import the Dotdeb Source. the Source list is located in "/etc/apt/sources. list". we open sources. list using the vi tool or nano tool and add the following two lines:

deb http://packages.dotdeb.org wheezy alldeb-src http://packages.dotdeb.org wheezy all

After completion, update the source:

apt-get update

Next, you can start to install nginx, mysql, and php.

2. MySQL

Install with apt:

apt-get install -y mysql-server mysql-client

During installation, you will be asked about the root password and enter the password you want to set.

After the installation is complete, run the following configuration command:

mysql_secure_installation

Follow the prompts to go down. during the process, you will be asked if you want to change the root password, whether to remove anonymous users, and whether to disable root remote logon. you can configure it as needed.

Note: When using mysql, I found that the remote client could not connect to the database. later I found the problem was "/etc/mysql/my. the statement "bind-address = 127.0.0.1" in the cnf file is at work. The address is bound to 127.0.0.1, so remote access to the database is not allowed. here we can comment it out, or if your server is an ip address, you can configure it as the ip address of your server.

Of course, it may be that your mysql does not have the permission to enable the remote access account. if this is the reason, you only need to add a record in the mysql user table:

grant all PRIVILEGES on *.* to user1@'%'identified by '123456' WITH GRANT OPTION;FLUSH  PRIVILEGES;

Restart the mysql service:

service mysql restart

3. install PHP

Install with apt:

apt-get install php5-fpm php5-gd php5-mysql php5-memcache php5-curl

The above command installs the extension of the php5-memcache, so continue to install Memcached:

apt-get install memcached

After the installation is complete, you can use php5-fpm-v to view the PHP version.

4. install Nginx

During installation, I directly installed all the Nginx extension functions (nginx-full). later functions may be enhanced, so I installed them all directly:

apt-get install -y nginx-full

Then start Nginx:

service nginx start

Put the question address http: // ip. if you see the following, it indicates that your Nginx installation is normal.

Next, Configure Nginx. The Nginx configuration file is in "/etc/nginx/sites-available/default"

……    location ~ /.php$ {        fastcgi_split_path_info ^(.+/.php)(/.+)$;    #    # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini    #    #    # With php5-cgi alone:    #   fastcgi_pass 127.0.0.1:9000;    #    # With php5-fpm:        fastcgi_pass unix:/var/run/php5-fpm.sock;        fastcgi_index index.php;        include fastcgi_params;    }……

Restart Nginx after saving:

service nginx restart

Then let's create a php page and test it:

nano /usr/share/nginx/html/phpinfo.php

Input:

 

After saving the file, you can directly access: http: // ip/phpinfo. php. if the phpinfo page appears, our work is complete!

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.