Construction of LNMP environment under Ubuntu system

Source: Internet
Author: User
Tags fpm web services administrator password

LNMP stands for: Linux system nginx+mysql+php this site server architecture.

Linux is a class Unix The computer operating system collectively, is currently the most popular free operating system. Representative editions are:Debian,centos,ubuntu,Fedora ,Gentoo and so on.

Nginx is a lightweight Web server/reverse proxy server and e-mail (IMAP/POP3) proxy Server

MySQL is a small relational database management system .

PHP is an embedded HTML document that executes on a server-side scripting language .

these four kinds of software are free Open Source software , combined to become a free, efficient, and highly scalable Web services system.

(a) First, I need to install an Ubuntu system, I installed on the virtual machine, the process is very simple

After installation can be installed in the system nginx, MySQL, PHP.

We'll first configure the system's NIC so that he can surf the internet and set his DNS

[Email protected]:~# vim/etc/network/interfaces[email protected]:~# vim/etc/resolv.conf

Then restart the network card, Ubuntu and CentOS Restart the network card command is not the same

[Email protected]:~# ifdown eth0 && ifup eth0

Check the network card information to confirm that it is configured.

Two

Then proceed to the next step, install Nginx, can download to the official website, find stable version

Open the/etc/apt/source.list file, paste the following two lines of command to the end of the file, do not stick the wrong!!

Deb Http://nginx.org/packages/ubuntu/codename nginxdeb-src http://nginx.org/packages/ubuntu/codename nginx

Then change the codename to trusty, different versions of the system to replace the words, to find the official website can

Download secret key

[Email protected]:~# wget Http://nginx.org/keys/nginx_signing.key

After downloading, execute the following command

[Email protected]:~# apt-key Add Nginx_signing.key

Last update source, install Nginx, start Nginx

[Email protected]:~# apt-get Update [email protected]:~# apt-get Install nginx[email protected]:~# service Nginx start

Let's have a look at port 80.

[Email protected]:~# netstat-ntpl | grep 80

Set the firewall to allow 80 ports to pass, Ubuntu and CentOS commands are also different

[Email protected]:~# UFW Allow 80

You can see the Welcome page of Nginx by logging into the native IP address with your browser.

Three

You can install MySQL after the nginx is installed.

First build MySQL related users, groups, folders, the new directory recursively set the main MySQL and the genus MySQL

[Email protected]:~# groupadd mysql[email protected]:~# useradd-g mysql mysql-s/bin/false[email protected]:~# mkdir-p /disk/data/mysql/var[email protected]:~# chown-r Mysql:mysql/disk/data/mysql/var

Unzip the MySQL package.

[Email protected]:~# tar zxvf mysql-5.5.35.tar.gz

Install some packages, or you will get an error later

[Email protected]:~# apt-get Install g++[email protected]:~# apt-get install libaio1[email protected]:~# apt-get install L Ibncurses5-dev[email protected]:~# apt-get Install libncurses5[email protected]:~# wget http://ftp.gnu.org/gnu/bison/ Bison-2.5.1.tar.gz[email protected]:~# tar zxvf bison-2.5.1.tar.gz [email protected]:~# cd Bison-2.5.1/[email protected ]:~/CD bison-2.5.1#./configure

Error during configuration because M4 is not installed

[Email protected]:~/cd bison-2.5.1# apt-get Install M4ubuntu do not have the make command installed. Use Apt-get command in ubuntu [email protected]:~/cd bison-2.5.1# apt-get Install make[email protected]:~/cd bison-2.5.1# make && make Install

Then do the MySQL installation

[Email protected]:~# cd mysql-5.5.35/[email protected]:~/mysql-5.5.35# cmake. -dcmake_install_prefix=/disk/local/mysql-dmysql_datadir=/disk/data/mysql/var-dsysconfdir=/etc

You'll see the CMake command on Ubuntu.

[Email protected]:~/mysql-5.5.35# apt-get Install CMake

CMake again, if also reported is wrong, RM CMakeCache.txt

Compile and install after success

[Email protected]:~/mysql-5.5.35# make && make install

MySQL can be configured after installation, be sure to do it in the installation directory

[Email protected]:~# cd/disk/local/mysql[email protected]:~/disk/local/mysql# CP./support-files/my-huge.cnf/etc/ My.cnf

Modify the configuration file for backup

[Email protected]:~/disk/local/mysql# vim/etc/my.cnf[email protected]:~/disk/local/mysql# mv/etc/my.cnf/etc/ My.cnf.bak[email protected]:~/disk/local/mysql# vim/etc/my.cnf.bak[email protected]:~/disk/local/mysql# vim/etc/ My.cnf

Write the following configuration to the configuration file

[client]  port            = 3306   socket          = /tmp/mysql.sock   [mysqld]  datadir = /Disk/data/mysql/var  port             = 3306  socket           = /tmp/mysql.sock  skip-external-locking  key_buffer_ Size = 256m  max_allowed_packet = 20m  sort_buffer_size = 2m   read_buffer_size = 2m  read_rnd_buffer_size = 8m  myisam_ sort_buffer_size = 64m   #server-id      = 1   #xzy   thread_stack            =  192k  thread_cache_size       = 64  myisam-recover          = BACKUP  max_connections         = 5000  query_cache_limit       = 2M   query_cache_size        = 256m   #错误日志记录   log_ error = /disk/log/mysql/error.log   #慢查询日志    #slow-query-log         = /Disk/log/mysql/mysql-slow.log   #long_query_time  = 5    #log-queries-not-using-indexes   #二进制文件日志   log_bin                  = /disk/log/mysql/ Mysql-bin.log  binlog_format     = row  expire_logs_days         = 10  max_binlog_size         =  100m   #不区分大小写   lower_case_table_names=1  [mysqldump]  quick   MAX_ALLOWED_PACKET = 16M  [MYSQL]  NO-AUTO-REHASH  [MYISAMCHK]   key_buffer_size = 256m  sort_buffer_size = 256m  read_ buffer = 2m  write_buffer = 2m  [mysqlhotcopy]   Interactive-timeout

Create a new log file and set up a generic group

[Email protected]:~/disk/local/mysql#kdir-p/disk/log/mysql[email protected]:~/disk/local/mysql# chown-r MySQL: Mysql/disk/log/mysql

Initializing the database

[Email protected]:~/disk/local/mysql#/disk/local/mysql/scripts/mysql_install_db--user=mysql

Launch MySQL into the system and he'll tell you you can't find the/etc/rc.d/init.d/mysqld file.

[Email protected]:~/disk/local/mysql# CP./support-files/mysql.server/etc/rc.d/init.d/mysqld

Now enter the support-files/directory under the current directory

[Email protected]:~/disk/local/mysql/support-files#./mysql.server restart

This will start MySQL up.

MySQL uses port 3306 to add 3306 ports to the firewall

[Email protected]:~# UFW Allow 3306

View firewall status

[Email protected]:~# UFW Status

The last is a password to the root account in the MySQL database, which is not the root of the operating system, but the root of the database management system.

[Email protected]:~/disk/local/mysql/bin#./mysqladmin-u root password ' 666666 '

Next we modify the/etc/profile file to add this phrase to the end of the file, add the MySQL service to the system environment variable

Export path= $PATH:/disk/local/mysql/bin

Make the configuration effective immediately source/etc/profile so we can tab out the MySQL command.

We use the account password to log in to MySQL

[Email protected]:~# mysql-u root-p

Then enter the password to log in to the operation of the database

We use the Windows Natcivat to connect to the server MySQL, there is a 1130 error prompt, because the remote server does not have permission to log on MySQL

To authorize and set a password for the root user

Mysql> Grant All on * * to ' root ' @ '% ' identified by ' 888888 ';

(iv) Installation of php,php is relatively simple

[Email protected]:~# apt-get Install php5[email protected]:~# apt-get install php5-fpm[email protected]:~# apt-get instal L php5-curl[email protected]:~# apt-get install libmcrypt4 php5-mcrypt[email protected]:~# apt-get Install Php5-gd[email protected]:~# apt-get Install php5-xmlrpc[email protected]:~# apt-get install Libapache2-mod-php5[email protected]:~# Apt-get Install Php5-mysql[email protected]:~#/etc/init.d/php5-fpm start

Then combine PHP and Nginx, modify the default profile, and uncomment the following code

[Email protected]:/etc/nginx/conf.d# vim default.conf location ~ \.php$ {root html;          Fastcgi_pass 127.0.0.1:9000;          Fastcgi_index index.php;          Fastcgi_param script_filename $document _root$fastcgi_script_name;  Include Fastcgi_params; }

If you change the port, remember to set up a firewall!!! After modifying the configuration file, remember to restart the NGINX service!!!

Check if Port 9000 is turned on, if not.

Modify/etc/php5/fpm/pool.d/www,conf To change the listen in the file to 9000

Create a new index.php file under the site root directory/usr/share/nginx/html, write <?php phpinfo (); >

Remember to restart the PHP5-FPM service!!!

Enter HTTP//native address in the browser address/index.php will be able to access the PHP page

(v) Now that the LNMP environment is set up, the next installation discuz forum

Unzip the Discuz_x3.3_sc_utf8.zip compressed package to the root of the Web site/usr/share/nginx/html

Install the unzip command-D specify the Unzip directory

will get three folders upload, Readme, utility

Set permissions on the site root directory

[Email protected]:~# chmod-r 777/usr/share/nginx/html/

Access HTTP/host address/upload/install/index.php by browser

Go to discuz installation homepage to install, fill in hostname, database password, administrator password

After the installation is successful, you can log in with the administrator.

Construction of LNMP environment under Ubuntu system

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.