Linux Configuration Step-up installation of LNMP environment----GHJ

Source: Internet
Author: User
Tags fpm gettext install php openssl subversion download svn svn update fully qualified domain name

Front Desk: Nignx backstage: Apache

"Linux Command"
User
File directory
Start
Scheduled tasks:
"Open RZ Command"

Yum-y Install Lrzsz

Firewall

Firewall configuration file:/etc/sysconfig/iptables
Service Operations Command:/etc/init.d/iptables service iptables {start|stop ...}
Temporary change command: iptables iptables-save Iptables-restore, etc.
Service Iptables status can view the current status of the Iptables service.
But even if the service is running, the firewall doesn't have to work, and you need to see the firewall rules set up iptables-l
Let's talk about the commands for starting and shutting down the firewall:
1) effective after reboot
Open: Chkconfig iptables on
OFF: Chkconfig iptables off
2) immediate effect, failure after reboot
Open: Service iptables start
Close: Service iptables stop

"Modify IP"
#vi/etc/syssconfig/network-scripts/ifcfg-eth0

Device=eth0

Bootproto=static

Hwaddr=; Here is the physical address of your network card, usually detected network card you do not have to enter the

Onboot=yes

ipaddr=192.168.0.1

netmask=255.255.255.0

network=192.168.1.0

broadcast=192.168.1.255

gateway=; Enter your gateway, the IP address of the router

Save exit

#/sbin/service Network Restart

If the NIC boot is OK, the IP address setting is successful. In addition we can use ifconfig eth0 to display the current IP to verify that the settings are correct.

Use the following command:

/etc/init.d/network Reload command or service network [command]

"Yum Source"

. Local Source Authoring

1, first create a directory under the/media directory CDROM and attach the disc to the system/media/cdrom
Mkdir/media/cdrom
mount/dev/cdrom/media/cdrom/
2. Go to/etc/yum.repos.d directory Centos-base.repo rename.

Cd/etc/yum.repos.d
MV Centos-base.repo Centos-base.repo.bak
VI Centos-media.repo
Revision changed to
Gpgcheck=0
Enabled=1

3. Link all CentOS installation packages to/media/centos
Ln-s/media/cdrom/centos//media/centos






#yum the packages required to install the system environment

Yum-y Install Yum-fastestmirror NTP
Yum-y Install patch make Flex Bison tar
Yum-y Install Libtool libtool-libs kernel-devel
Yum-y Install libjpeg libjpeg-devel libpng libpng-devel
Yum-y Install Libtiff libtiff-devel gettext gettext-devel
Yum-y install libxml2 libxml2-devel zlib-devel NET-SNMP
Yum-y Install file glib2 glib2-devel bzip2 diff* openldap-devel
Yum-y Install bzip2-devel ncurses ncurses-devel Curl Curl-devel e2fsprogs
Yum-y Install e2fsprogs-devel krb5 krb5-devel libidn libidn-devel
Yum-y install OpenSSL openssl-devel vim-minimal unzip

# Install PHP support GD Library module
Yum-y install freetype freetype-devel png jpeg zlib GD php-gd*
# Install PHP 5.* components
Yum-y Install Libiconv libevent mhash mcrypt
# System library related library files required to install Mydsql
Yum install-y gcc gcc-c++ gcc-g77 autoconf automake fiex* ncurses-devel libmcrypt* libtool-ltdl-devel*

# Install Nginx Components
Yum-y Install pcre*

Yum-y Install gcc gcc-c++ gcc-g77 Flex Bison tar libtool libtool-libs kernel-devel autoconf libjpeg libjpeg-devel libpng Libpng-devel libtiff libtiff-devel gettext gettext-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel fi Le glib2 glib2-devel bzip2diff* openldap-devel bzip2-devel ncurses ncurses-devel Curl curl-devel e2fsprogs E2fsprogs-deve L krb5 krb5-devel libidn libidn-devel OpenSSL openssl-devel vim-minimal unzip Automake make

Yum-y install zlib zlib-devel OpenSSL openssl--devel pcre pcre-devel

"Install Pcre before installing Nginx"

Tar zvxf pcre-8.10.tar.gz
#cd pcre-8.10
#./configure
#make
#make Install

"Nginx"
Download the installation package: http://nginx.org/download/nginx-1.8.0.tar.gz
Tar zxvf nginx-1.8.0.tar.gz
CD nginx-1.8.0
./configure
Make && make install

Start Nginx:/usr/local/nginx/sbin/nginx
Restart Nginx:/usr/local/nginx/sbin/nginx-s Reload


Boot nginx: Create nginx files in the/etc/init.d/directory of Linux system

Vi/etc/init.d/nginx

#!/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=/usr/local/nginx/sbin/nginx
Nginx_config=/usr/local/nginx/conf/nginx.conf
Nginx_pid=/var/run/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/var/run/nginx.pid
}
# Reload Nginx service functions.
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

chmod A+x/etc/init.d/nginx

Finally, add the Ngix to the rc.local file so that the Nginx will start by default.
Vi/etc/rc.local
Add/etc/init.d/nginx Start
Save and exit the next reboot will take effect, implement nginx self-boot.

"Install MySQL"
Yum-y install gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* Mak E CMake

Yum-y Install CMake

Groupadd MySQL
Useradd-r-G MySQL MySQL

TAR-ZXVF mysql-5.6.21.tar.gz
CD mysql-5.6.21

CMake.
Make && make install

-------------------------is installed on/usr/local/mysql by default

Chown-r Mysql.mysql/usr/local/mysql

Cd/usr/local/mysql/scripts
./mysql_install_db--user=mysql--basedir=/usr/local/mysql--datadir=/usr/local/mysql/data

Cd/usr/local/mysql/support-files
CP Mysql.server/etc/rc.d/init.d/mysql
CP MY-DEFAULT.CNF/ETC/MY.CNF
Chkconfig--add MySQL
Chkconfig MySQL on
Service MySQL Start




Change Password:/usr/local/mysql/bin/mysqladmin-u root password ' 123456 '

Login:/usr/local/mysql/bin/mysql-u root-p


To modify remote access permissions:

1. Change the table method. It may be that your account is not allowed to log on remotely, only on localhost. This time, as long as the computer on the localhost, log in to MySQL, change the "MySQL" Database in the "User" table "host", from "localhost" to "%"

SQL code Copy Code

1. Mysql-u root-p
2. Use MySQL;
3. Mysql>update User Set host = '% ' where user = ' root ';
4. Mysql>select host, user from user;

2. Authorization law. For example, if you want to myuser use MyPassword to connect to a MySQL server from any host.

SQL code Copy Code
GRANT all privileges on * * to ' root ' @ '% ' identified by ' root ' with GRANT OPTION;

FLUSH privileges;


"Install Apache"

Cd/usr/local/src

Groupadd www
Useradd-g www-s/sbin/nologin-m www

wget http://apache.freelamp.com//httpd/httpd-2.2.17.tar.gz

Tar zxvf httpd-2.2.17.tar.gz

CD httpd-2.2.17


Apache default maximum connections and maximum number of clients is 40000, if your server requirements are larger, you can compile the Apache installation file:

Server/mpm/worker/worker.c

Locate the following lines and change the values below to change the maximum number of threads and maximum clients that Apache can support in the source code.

Define Default_server_limit 32
Define Max_server_limit 40000
Define Default_thread_limit 64
Define Max_thread_limit 40000

The above values are said to be smaller, reducing server consumption. But after seven months of revision, found nothing substantial change

Install APR and apr-util in turn
Tar zxvf apr-1.5.2.tar.gz
CD apr-1.5.2
./configure--PREFIX=/USR/LOCAL/APR
Make && make install

Tar zxvf apr-util-1.5.4.tar.gz

CD apr-util-1.5.4

./configure--prefix=/usr/local/apr-util--with-apr=/usr/local/apr/--with-mysql=/usr/local/mysql
Make && make install

Installing Apache 2.4

cd/usr/local/src/httpd-2.4.20

./configure--prefix=/usr/local/apache--with-mysql=/usr/local/mysql--with-apr=/usr/local/apr/--with-apr-util=/ usr/local/apr-util/--enable-so--enable-rewrite--with-mpm=prefork--disable-cgid--disable-cgi

Make && make install

If you need to compile Apache other features, you can add it yourself. But here, we just use Apache as the backend and handle pseudo-static, without having to add too many settings to waste memory

Annotations:

./configure//Configuring the Source code tree
--prefix=/usr/local/apache//System-agnostic files for the top-level installation directory prefix, also on the Apache installation directory.
--ENABLE-MODULE=SO//Open so module, so module is the Apache core module used to carry out DSO support
--enable-mods-shared=all//Compile all the templates, for no need we can be removed in httpd.conf.
--enable-cache//Support caching
--enable-file-cache//Support file cache
--enable-mem-cache//Support memory cache
--enable-disk-cache//support for disk caching
--enable-static-support//Support static connection (default is dynamic connection)
--ENABLE-STATIC-HTPASSWD//compile htpasswd with static connection-manage user files for Basic authentication
--enable-static-htdigest//compile htdigest with static connection-manage user files for Digest authentication
--enable-static-rotatelogs//compile rotatelogs with static connection-scrolls through the Apache log pipeline log Program
--enable-static-logresolve//compile with static connection logresolve-resolves the IP address in the Apache log to be the host name
--ENABLE-STATIC-HTDBM//compile htdbm with static connection-operation DBM Password database
--enable-static-ab//Compile Ab-apache HTTP server performance test tool with static connection
--enable-static-checkgid//compile with static connection Checkgid
--disable-cgid//Prohibit execution of CGI scripts with an external CGI daemon
--DISABLE-CGI//Prohibit compiling CGI version of PHP
--with-mpm=worker//Let Apache run as worker
--ENABLE-SSL//Compile the SSL module.

Start Apache (recommended not to start, and so we all set up, and Nginx boot)

/usr/local/apache/bin/apachectl Start|stop|restart

See if Apache launches

PS Aux|grep httpd

Set Apache to boot from:

Echo '/usr/local/apache/bin/apachectl start ' >>/etc/rc.local//Add the APACHECTL call to your system boot file.

Issue: Httpd:could not reliably determine the server ' s fully qualified domain name, using 127.0.0.1 for ServerName

Found in httpd.conf (/usr/local/apache/conf/httpd.conf)
#ServerName www.example.com:8080 to remove the #

Error while loading shared Libraries:libiconv.so.2:cannot open Shared object file:no such file or directory

Try to execute: LDD/USR/LOCAL/APACHE/BIN/HTTPD
You'll see this line.
Libiconv.so.2 = not Found
Previously compiled runs are possible, and may be the effect of upgrading some library files recently. Under/usr/local/lib can find libiconv.so.2, add/usr/local/lib to the path also not.
Add a row of/usr/local/lib in/etc/ld.so.conf and run Ldconfig. Run Apache,ok again.
Ld.so.conf and Ldconfig are maintenance system dynamic link libraries.


"Software version: PHP 5.6.3"

First, install the Libiconv library

TAR-ZVXF libiconv-1.14.tar.gz

CD libiconv-1.14

./configure–help
./configure--prefix=/usr/local

Make && make install

echo "/usr/local/lib" >>/etc/ld.so.conf

/sbin/ldconfig

Download php5.6.12

wget http://cn2.php.net/distributions/php-5.6.3.tar.gz

Unzip PHP 5.6.3 Source package

TAR-ZXVF php-5.6.3.tar.gz



./configure--prefix=/usr/local/php--with-config-file-path=/usr/local/php/etc--enable-mb--enable-bcmath-- Enable-mbstring--enable-sockets--with-curl--enable-ftp--enable-sockets--disable-ipv6--with-gd--with-jpeg-dir-- With-png-dir--with-freetype-dir--enable-gd-native-ttf--with-iconv-t--with-zlib--with-pdo-mysql=/usr/local/ MySQL--with-mysqli=/usr/local/mysql/bin/mysql_config--with-mysql=/usr/local/mysql--enable-dom--enable-xml-- ENABLE-FPM--with-iconv-dir=/usr/local--with-apxs2=/usr/local/apache/bin/apxs

Once the compilation is complete, let's make again. In make, we note that the-liconv parameter is added. If you do not add the-liconv parameter, the system will error in make compilation. The error message is as follows:

Generating phar.php

Php-5.3.16/sapi/cli/php:error while loading shared libraries:libiconv.so.2:cannot open shared object File:no such fi Le or directory
Make: * * * [sapi/cli/php] Error 1

Use the following command:

Make zend_extra_libs= '-liconv '

Make install

[note] in the above command:
The function of –ENABLE-FPM is to turn on the fastcgi function of PHP, that is to turn on php-fpm function.

–with-mysql=/usr/local/mysql is the ability to enable PHP to support MySQL,/usr/local/mysql is the path to the MySQL database installation.

–enable-mbstring means that the primary function of enabling the Mbstring Module Mbstring module is to detect and convert the encoding, providing a string function for the corresponding multibyte operation. At present PHP internal code only supports iso-8859-*, EUC-JP, UTF-8, the other encoding language is not able to display correctly in the PHP program, so we want to enable the Mbstring module.

–with-iconv-dir=/usr/local Specifies where PHP stores the Libiconv library.

–WITH-APXS2=/USR/LOCAL/APACHE/BIN/APXS Specifies the location of PHP to find Apache.

Configuring Environment Variables for PHP

echo "path= $PATH:/usr/local/php/bin:/usr/local/php/sbin" >>/etc/profile
SOURCE!$ # Refresh System Environment

CP Php.ini-production/usr/local/php/etc/php.ini

cd/usr/local/php
CP Etc/php-fpm.conf.default etc/php-fpm.conf

VI etc/php-fpm.conf

user = www
Group = www

Under the installation directory:

cp/usr/local/src/php-5.6.3/sapi/fpm/init.d.php-fpm/etc/init.d/php-fpm

chmod 755/etc/init.d/php-fpm

/usr/local/php/sbin/php-fpm-t

Start and close php and view PHP status
Service PHP-FPM Start
Or
/usr/local/php/sbin/php-fpm
Service PHP-FPM Stop
Service PHP-FPM Status
Usage:/etc/init.d/php-fpm {start|stop|force-quit|restart|reload|status}

Add PHP to the system service and start randomly

Chkconfig--add php-fpm && chkconfig php-fpm on



"PHP and Apache"

/usr/local/apache/conf/httpd.conf:

LoadModule Php5_module modules/libphp5.so
AddType application/x-httpd-php. php

Restart Apache/usr/local/apache/bin/apachectl restart

echo "<?php phpinfo ();? > ">/usr/local/apache/htdocs/index.php

cat/usr/local/apache/htdocs/index.php

PHP and Nginx nginx-> php-fpm (502)

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

"Master-slave Replication"


"Read and Write separation"

"Reverse proxy"

"Git"

"SVN"

=======================================================

SVN configuration

1. Install the SVN server side
Yum install subversion download from image install SVN server side
cd/usr/local///Enter directory, ready to create SVN directory
mkdir SVN//Create an SVN directory
Chmod-r 777 SVN//Modify directory permissions to 777
Svnadmin Create/usr/local/svn/sunny//Create an SVN version repository sunny (sunny can name it casually)
CD svn/sunny/conf//Enter the configuration file directory under the sunny repository

Below to modify the three configuration files in this directory
(1) VI svnserve.conf//configuration repository information and user file and user password file path, repository path

Put
# anon-access = Read
# auth-access = Write
# password-db = passwd
These four lines, the preceding # number and the space is removed (note to remove the # to shelf write, do not leave the extra space), into
Anon-access = none//change to None
auth-access = Write
Password-db = passwd
Realm = sunny//change to your own version library
Save

(2) vi Authz//files, creating permissions for SVN Group and group users
[Group]
Sunny = GEP,WCE//Create a sunny group and specify two users GEP and WCE

[/]//define permissions under the root directory
@sunny = RW//sunny Group user rights are read and write
* = r//other users have read access only
Save exit

(3) VI passwd//Create or modify user passwords
[Users]
GEP = 123456//user named GEP has a password of 123456
WCE = 123456//...
Save exit


Start SVN:
Svnserve-d-r/usr/local/svn///A multi-version library is used here to start if a single version of the library can be svnserve-d-r/usr/local/svn/sunny
Add a row
Then you set the self-start
Vi/etc/rc.local opening a self-boot file to add
/usr/bin/svnserve-d-r/usr/local/svn/

At this end, you can check out files from the server.

SVN command:
NETSTAT-TNL |grep:3690 See if SVN starts
PS aux |grep ' svn ' Find all SVN-initiated processes
Kill-9 2505 kills 2505 of this found SVN process


SVN checkout Svn://172.19.5.2/sunny/data0/htdocs/blog//Check out a repository file to the specified directory
SVN up//update file

Automatic Updates
Join in the Vi/usr/local/svn/sunny/hooks/post-commit

#!/bin/sh
#设置一些变量
Svn=/usr/bin/svn
WEB=/HOME/TESTSVN #要更新的目录
Export Lang=en_us. UTF-8
$SVN update $WEB--username xxx--password xxx


Where svn= to the right of the SVN command location generally defaults to/USR/BIN/SVN
web= right to your actual web directory
Give executable permission
chmod 777/usr/local/svn/sunny/hooks/post-commit
Installation Complete


=========================================================================
Other operations

#svn commit-m "Notes" xxx.php//Submit File
SVN ci-m ' AAA ' test.php//Submit File

#svn Add File//new files to SVN
SVN add *.php//(Add all PHP files in the current directory)
SVN delete test.php//delete test.php
SVN log test.php//view the log information of the test file
SVN cleanup//Clean up the current directory



SVN switch--relocate svn://192.168.1.253 svn://172.19.10.250//Relocate SVN repository address




SVN repository starting mode, now SVN has sunny, test two repository
1: Single-version library starter svnserve-d-r/usr/local/svn/sunny
2: Multi-version Library starter svnserve-d-R/USR/LOCAL/SVN
The difference is the start of the SVN command in the startup parameter-r specified directory.

To restrict different user permissions for different repository operations, modify the Authz file in the Conf directory in the Repository

To configure the sunny repository as an example
VI Authz
[Groups]
Teacher = Sunny,sunny1
[sunny:/]//Specify repository and directory permissions
@teacher = RW//teacher Group user rights are read and write
* = r//other users have read access only
Save exit

VI passwd set the user's account number and password in the group
[Users]
Sunny = 123456
Sunny1 = 123456

"Memecache radius"


"Load Balancing"

Linux Configuration Step-up installation of LNMP environment----GHJ

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.