CentOS Source Installation Build LNMP whole process (including NGINX,MYSQL,PHP,SVN) "Turn"

Source: Internet
Author: User
Tags configuration php fpm gz file install php openssl php download svn scp command

Transferred from: http://blog.csdn.net/yanzi1225627/article/details/49123659

Server environment: CentOS6.5 64-bit

Goal: Build LNMP (Linux + Nginx + MySQL + PHP +svn), where SVN is used instead of FTP to facilitate debugging of synchronization code in development

Related directory: All software installed in the/www/directory, the WWW directory under the new Web folder as the root path of the site, the WWW directory new WWWSVN as the repository address of SVN. /www/software is used to put nginx,mysql,php installation package and source code. Nginx run group and account Www:www

One, pre-installation preparation

Yum-y install NTP make OpenSSL openssl-devel pcre pcre-devel libpng libpng-devel libjpeg-6b libjpeg-devel-6b freetype fre Etype-devel gd gd-devel zlib zlib-devel gcc gcc-c++ libxpm libxpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel li BXML2 libxml2-devel imake autoconf automake screen sysstat compat-libstdc++-33 Curl Curl-devel cmake

Installs all the dependencies that you want to install directly.

Then download the source code for Nginx, MySQL, PHP:

nginx:http://nginx.org/en/download.html Download stable version of 1.8.0: nginx-1.8.0.tar.gz

mysql:http://dev.mysql.com/downloads/mysql/, download the Community Server version with the suffix tar.gz source mysql-5.6.27.tar.gz:

php:http://php.net/downloads.php Download php-5.6.14.tar.gz

Get these three copies of the tar.gz file to the/www/software directory on the server through the SCP command.

Second, install Nginx

Unzip the file, then go to nginx-1.8.0 and enter the command:

./configure--user=www--group=www--prefix=/www/nginx

Then the Make,make install is complete.

After installing the first thing, create WWW users and groups, otherwise you will encounter http://blog.itblood.com/nginx-emerg-getpwnam-www-failed.html error.

Perform:

/usr/sbin/groupadd-f www
/usr/sbin/useradd-g www www

Nginx command under/www/nginx/sbin/, copy to/etc/init.d/a copy, next set boot boot.

chmod 755/etc/init.d/nginx

Chkconfig--add Nginx

Chkconfig Nginx on

And then

New Nginx under the cd/etc/rc.d/init.d/directory, the contents are as follows:

#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
# It is v.0.0.2 version.
# Chkconfig:-85 15
# Description:nginx is a high-performance Web and proxy server.
# It has a lot of features, but it's not for everyone.
# Processname:nginx
# Pidfile:/var/run/nginx.pid
# config:/usr/local/nginx/conf/nginx.conf
Nginxd=/www/nginx/sbin/nginx
Nginx_config=/www/nginx/conf/nginx.conf
Nginx_pid=/www/nginx/logs/nginx.pid
Retval=0
Prog= "Nginx"
# Source function library.
. /etc/rc.d/init.d/functions
# Source Networking configuration.
. /etc/sysconfig/network
# Check that networking are up.
[${networking} = "No"] && exit 0
[-X $nginxd] | | Exit 0
# Start Nginx daemons functions.
Start () {
If [-e $nginx _pid];then
echo "Nginx already running ..."
Exit 1
Fi
Echo-n $ "Starting $prog:"
Daemon $nginxd-C ${nginx_config}
Retval=$?
Echo
[$RETVAL = 0] && Touch/var/lock/subsys/nginx
Return $RETVAL
}
# Stop Nginx daemons functions.
Stop () {
Echo-n $ "Stopping $prog:"
Killproc $nginxd
Retval=$?
Echo
[$RETVAL = 0] && rm-f/var/lock/subsys/nginx/www/nginx/logs/nginx.pid
}
Reload () {
Echo-n $ "Reloading $prog:"
#kill-hup ' Cat ${nginx_pid} '
Killproc $nginxd-hup
Retval=$?
Echo
}
# See how we were called.
Case "$" in
Start
Start
;;
Stop
Stop
;;
Reload
Reload
;;
Restart
Stop
Start
;;
Status
Status $prog
Retval=$?
;;
*)
echo $ "Usage: $prog {start|stop|restart|reload|status|help}"
Exit 1
Esac
Exit $RETVAL

Note: If the Nginx installation path is not under/www/nginx, then the appropriate modification is fine.

#设置开机启动/etc/rc.d/init.d/nginx restartservice nginx Restart

At this point nginx installation is OK, but left two problems:

1, is the problem of changing the default Web root in/www/web

2, is the integration with PHP, the default nginx is not recognized PHP

For the 1,nginx Default Web root directory under the Nginx installation path of the HTML folder, we changed him to the/www/web directory.

Into the/www/nginx/conf directory, vim Nginx.conf, will

Location/{root HTML;        Index index.php index.html index.htm; }

Modified to:

Location/{

Root/www/web;

Index index.html index.php;

}

Note that the recognition of the index.php is increased.

Will

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; }

Modified to:

Location ~ \.php$ {

Root/www/web;

Fastcgi_pass 127.0.0.1:9000;

Fastcgi_index index.php;

Fastcgi_param Script_filename/scripts$fastcgi_script_name;

#include fastcgi_params;

Include fastcgi.conf;

}

And then it's OK.

The second problem with the integration of PHP, to install after the completion of PHP and then complete.

Three, install MySQL

Unzip to the source directory, execute:

#cmake-dcmake_install_prefix=/www/mysql

Then make make install installs. Here are a few things to do after installation:

1, check if there is a my.conf under/etc/, if any, by the MV Command renamed to

My.cnf.backup

PS: This step is very important!!!

2. Create MySQL users and groups

#/usr/sbin/groupadd MySQL

#/usr/sbin/useradd-g MySQL MySQL adds MySQL users and groups.

Perform

CAT/ETC/PASSWD View the list of users
Cat/etc/group viewing a list of user groups

Chown-r mysql:mysql/www/mysql Modify the MySQL installation directory permissions.

3, go to/www/mysql and create the database that comes with the system.

scripts/mysql_install_db--basedir=/www/mysql--datadir=/www/mysql/data--user=mysql

4, add service, start MySQL

CP Support-files/mysql.server/etc/init.d/mysql
Chkconfig MySQL on
Service MySQL Start--start MySQL

5, set root password

In order to be able to use mysql/bin commands anywhere, vim/etc/prifile

Add to:

Path=/www/mysql/bin: $PATH
Export PATH

Source/etc/profile after saving

Perform:

Mysql-uroot  mysql> SET PASSWORD = PASSWORD (' root ');

Set the root user's password to root.

6, in order to support remote access to the database, execution;

Mysql> Grant All on * * to [e-mail protected] "%" identified by "Xroot";

mysql> flush Privileges; Update permissions

This creates a user named Xroot, with a password of Xroot, who can access the database remotely.

Four, install PHP

Unzip and enter the source code:

#./configure--prefix=/www/php--enable-fpm--with-fpm-user=www--with-fpm-group=www--with-openssl-- With-libxml-dir--with-zlib--enable-mbstring--with-mysql=/www/mysql--with-mysqli=/www/mysql/bin/mysql_config-- Enable-mysqlnd--with-pdo-mysql=/www/mysql --with-gd--with-jpeg-dir--with-png-dir--with-zlib-dir -- With-freetype-dir--with-curl

Then make make and install. Next, you need to do the following:

1, integrated nginx, start PHP

Into the cd/www/php/etc/directory, copy Php-fpm.conf.default to php-fpm.conf. Execute/www/php/sbin/php-fpm start start php-fpm.

2, Configuration PHP.ini

Copy the/www/software/php-5.6.14/php.ini-production from the installation source to the Lib folder of the PHP installation directory.

3, if you need to install Curl extension (above the Configure has been brought), into the source Ext/curl directory, to ensure that the computer has been installed curl and curl-devel, and then:

A,/www/php/bin/phpize below, for convenience can add this directory to/etc/profile:

PATH=/www/php/bin:/www/mysql/bin:$PATH

Export PATH

B

./configure--with-curl--with-php-config=/www/php/bin/php-config

After make makes install,curl.so generates a

/www/php/lib/php/extensions/no-debug-non-zts-20131226 directory, then edit php.ini to find extension_dir and extension modifications.

Five, install SVN configuration post-commit

This step is in place of FTP, which allows developers to develop and synchronize code. Can be installed directly from Yum.

# Rpm-qa Subversion//Check if you have a low version of SVN

#yum Remove Subversion//Uninstall the lower version of SVN

# yum Install httpd httpd-devel Subversion mod_dav_svn mod_auth_mysql//install SVN

Verify that the installation was successful by # Svnserve--version. The next step is to create the warehouse and synchronize with the Web directory.

1,mkdir-p/WWW/WWWSVN This folder is the SVN repository. Svnadmin CREATE/WWW/WWWSVN Create a warehouse, execute the above command, you can find inside there are conf, db,format,hooks, locks, README.txt and other files, stating that an SVN library has been established. (PS: You can build the SVN repository directory through svnserve-d-r/www/svndata, and then svnadmin create a new warehouse in the Svndata directory)

2. Configure user and password

In the WWWSVN down into the Conf folder, there are three files: Authz passwd svnserve.conf are to be edited.

#vim passwd//set user and password

[Users]
# Harry = Harryssecret
# sally = Sallyssecret
Wangning=wangning
Yanzi=yanzi

#vim Authz//Set permissions

[/]

wangning = RW

Yanzi = RW

# &joe = R

# * =

#vim svnserve.conf

Anon-access = None
auth-access = Write
# # # The PASSWORD-DB option controls the location of the password
# # Database file. Unless specify a path starting with A/,
# # # The file ' s location was relative to the directory containing
# # # This configuration file.
# # If SASL is enabled (see below), the This file won't be used.
# # # Uncomment the line below to use the default password file.
Password-db = passwd
# # # The AUTHZ-DB option controls the location of the authorization
# # # Rules for path-based access control. Unless you specify a path
# # # Starting with a/, the file's location was relative to the
# # # directory containing this file. If you don ' t specify an
# # # AUTHZ-DB, no path-based access control is done.
# # # Uncomment the line below to use the default authorization file.
Authz-db = Authz
# # # This option specifies the authentication realm of the repository.
# # If repositories have the same authentication realm, they should
# # # has the same password database, and vice versa. The default Realm
# # is repository ' s UUID.
Realm = My First Repository

Note: There must be no spaces before these valid rows.

3. Start and Stop SVN

#svnserve-D-r/www/wwwwvn//Start SVN

#killall Svnserve//Stop

After SVN is started, it can be tested outside.

SVN checkout svn://192.1.15.222--username XXX

4, Configuration Post-commit

After the above configuration, SVN's warehouse address is/www/wwwsvn, but the root of the Web is/www/web, the two are not a directory, you can not see the role of SVN push.

A, first in the terminal of the server, #svn co svn://192.1.15.222/www/web

Remember to modify the/www/web directory permissions to Www:www.

Chown-r Www:www/www/web

B, # cd/www/wwwsvn/hooks/, then CP Post-commit.tmpl Post-commit

Vim Post-commit, enter in:

Export LANG=zh_cn. UTF-8

SVN up --username yanzi --password yanzi/www/web/

Chown- R www:www/www/web/

Then everything OK, outside SVN commit to see the web directory there is a corresponding file it!

Ps:

The name and password behind 1,SVN up is the SVN user that was previously set up.

2, above up is the meaning of update, according to the meaning of git to understand, is a warehouse a, and then a new B to track A, every time a has submitted, let B also pull over. In SVN is update.

Reference Links:

1. SVN part: http://www.cnblogs.com/davidgu/archive/2013/02/01/2889457.html

Http://www.cnblogs.com/zhoulf/archive/2013/02/02/2889949.html

2.LNMP part: Http://www.tuicool.com/articles/jqIb22

3.mysql part: http://www.cnblogs.com/xiongpq/p/3384681.html

Download link nginx + mysql + php:

Http://yunpan.cn/cFQZxxhYeWxX8 (Extract code: 7F93)

Additional notes about SVN :

1, generally set up directory/WWW/WWWSVN for a first-level directory, and then create a new two-level directory/www/wwwsvn/project1 as a warehouse Project1.

Command:

Svnadmin Create/www/wwwsvn/project1

Start SVN:

Svnserve-d-R/WWW/WWWSVN

This starts the SVN root directory is WWWSVN, the address of the outer Project1 is: svn:192.xx.xx.x/project1 the benefit of doing this is that you can build multiple project. On the outside SVN co svn:192. A new Project1 folder will also be created when Xx.xx.x/project1.

Conclusion: If you want to freely control the file name of the project, then svnserve the project folder to start directly, so SVN checkout when the first to build the outside folder, and then come in checkout on the line. If you want to directly checkout down with the project folder, then svnserve when the outer directory is launched. This allows you to bring your own Project1 folder when checkout anywhere.

2, about Post-commit

First, in the server's/a/apps/zhujibao/manager/public/path, SVN co svn:192.xx.xx.x/city52, so the city52 folder is created automatically.

The contents are:

Export LANG=ZH_CN. UTF-8

SVN up--username Yanzi--password yanzi/a/apps/zhujibao/manager/public/city52

Chown-r www:www/a/apps/zhujibao/manager/public/city52

Repos= "$"

rev= "$"

#mailer. PY commit "$REPOS" "$REV"/path/to/mailer.conf

The last sentence must be commented out! also, remember to give post-commit Add executable permissions .

3, if you do not set Post-commit, then you are outside to submit something, in the warehouse address is nothing to see, so this post-commit is necessary!

CentOS Source Installation Build LNMP whole process (including NGINX,MYSQL,PHP,SVN) "Turn"

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.