Pre-deployment preparation;
Nginx Installation Reference Other blog posts
This article is for mysql+php only
Iptables and SELinux do not configure, turn off
System CD as Yum source, configure Yum file
Get the source package from the network, the IP address can surf the internet
MySQL is installed using CMake, compile and install the CMake first
Compile and install MySQL:
[Email protected] ~]# wget http://down1.chinaunix.net/distfiles/mysql-5.5.22.tar.gz
[Email protected] ~]# tar zxvf mysql-5.5.22.tar.gz-c/usr/src/
[Email protected] ~]# cd/usr/src/mysql-5.5.22/
[Email protected] mysql-5.5.22]# Cmake-dcmake_install_prefix=/usr/local/mysql-ddefault_charset=utf8-ddefault_ collation=utf8_general_ci-dwith_extra_charsets=all-dsysconfdir=/etc/
[[email protected] mysql-5.5.22]# make &&make Install
[email protected] mysql-5.5.22]# CP support-files/my-medium.cnf/etc/my.cnf
CP: Do you want to overwrite "/etc/my.cnf"? Y
[email protected] mysql-5.5.22]# CP support-files/mysql.server/etc/init.d/mysqld
[Email protected] mysql-5.5.22]# chmod +x/etc/init.d/mysqld
[Email protected] mysql-5.5.22]# chkconfig--add mysqld
[Email protected] mysql-5.5.22]# echo "path= $PATH:/usr/local/mysql/bin" >>/etc/profile
[Email protected] mysql-5.5.22]# Source/etc/profile
[[email protected] mysql-5.5.22]# Groupadd MySQL
[Email protected] mysql-5.5.22]# useradd-m-s/sbin/nologin mysql-g MySQL
[Email protected] mysql-5.5.22]# cd/usr/local/mysql/scripts/
[Email protected] scripts]#/mysql_install_db--basedir=/usr/local/mysql--datadir=/usr/local/mysql/data--user= Mysql
Installing MySQL system tables ...
Ok
Filling Help Tables ...
Ok
[[Email protected] scripts]# CD
[[email protected] ~]#/etc/init.d/mysqld start
Starting MySQL ... Determine
[Email protected] ~]# mysqladmin-uroot password 123123
[Email protected] ~]# mysql-uroot-p123123
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 2
Server Version:5.5.22-log Source Distribution
Copyright (c), Oracle and/or its affiliates. All rights reserved.
This software comes with absolutely NO WARRANTY. This is the free software,
And you is welcome to modify and redistribute it under the GPL v2 license
Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.
Mysql> quit;
Install PHP:
[Email protected] ~]# yum-y install libxml2-devel gd-devel zlib-devel
[Email protected] ~]# wget http://cn2.php.net/distributions/php-5.4.36.tar.bz2
[Email protected] ~]# tar jxvf php-5.4.36.tar.bz2-c/usr/src/
[Email protected] ~]# cd/usr/src/php-5.4.36/
[Email protected] php-5.4.36]#/configure--prefix=/usr/local/php5--with-gd--with-zlib--with-mysql=/usr/local/ MySQL--with-config-file-path=/usr/local/php5--enable-mbstring--enable-fpm--with-jpeg-dir=/usr/lib
[[email protected] php-5.4.36]# make &&make Install
[Email protected] php-5.4.36]# ls/usr/local/php5/
Bin etc include Lib Php sbin var
[email protected] php-5.4.36]# CP Php.ini-development/usr/local/php5/php.ini
[Email protected] ~]# ln-s/usr/local/php5/bin/*/usr/local/bin/
[Email protected] ~]# ln-s/usr/local/php5/sbin/*/usr/local/sbin/
Install Zendguardloader:
[Email protected] ~]# tar zxvf zendguardloader-70429-php-5.4-linux-glibc23-x86_64.tar.gz
zendguardloader-70429-php-5.4-linux-glibc23-x86_64/
zendguardloader-70429-php-5.4-linux-glibc23-x86_64/php-5.4.x/
Zendguardloader-70429-php-5.4-linux-glibc23-x86_64/php-5.4.x/zendguardloader.so
Zendguardloader-70429-php-5.4-linux-glibc23-x86_64/readme.txt
[email protected] ~]# CP zendguardloader-70429-php-5.4-linux-glibc23-x86_64/php-5.4.x/zendguardloader.so/usr/ local/php5/
[Email protected] ~]#
Edit the PHP.ini (/usr/local/php/etc) file and add the following at the last location:
[Email protected] ~]# Vi/usr/local/php5/php.ini
[Zend Guard]
Zend_extension=/usr/local/php5/zendguardloader.so
; Enables loading encoded scripts. The default value is on
Zend_loader.enable=1
; Optional:following lines can be added your php.ini file for Zendguardloader configuration
Zend_loader.disable_licensing=0
Zend_loader.obfuscation_level_support=3
: Wq
Configuring Nginx Support PHP:
[Email protected] ~]# cd/usr/local/php5/etc/
[Email protected] etc]# VI php-fpm.conf # #新建配置文件
[Global]
PID = Run/php-fpm.pid
[WWW]
Listen = 127.0.0.1:9000
user = Nginx
Group = Nginx
PM = dynamic
Pm.max_children = 50
Pm.start_servers = 20
Pm.min_spare_servers = 5
Pm.max_spare_servers = 35
[Email protected] ~]#/USR/LOCAL/SBIN/PHP-FPM # #启动php-FPM
[Email protected] ~]# NETSTAT-UTPLN |grep php
TCP 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 5587/php-fpm
To write a startup Lnmp script:
[Email protected] ~]# vi/etc/init.d/lnmp
#!/bin/bash
# CHKCONFIG:35 95 30
# description:this script is for LNMP management!
Ngf=/usr/local/nginx/sbin/nginx
Ngp=/usr/local/nginx/logs/nginx.pid
fpmf=/usr/local/php5/sbin/php-fpm
Fpmp=/usr/local/php5/var/run/php-fpm.pid
Case $ in
Start
$NGF &&echo "Nginx is starting!"
$FPMF && echo "PHP-FPM is starting!"
;;
Stop
Kill-quit $ (cat $NGP) &&echo "Nginx is stoped!"
Kill-quit $ (cat $FPMP) &&echo "PHP-FPM is stoped!"
;;
Restart
$ stop
$ start
;;
Reload
Kill-hup $ (cat $NGP)
Kill-hup $ (cat $FPMP)
;;
Status
NETSTAT-UTPLN |grep Nginx &>/dev/null
If [$?-eq 0]
Then
echo "Nginx is running!"
Else
echo "Nginx is not running!"
Fi
Netstat-upltn |grep php-fpm &>/dev/null
If [$?-eq 0]
Then
echo "PHP-FPM is runing!"
Else
echo "PHP-FPM is not running!"
Fi
;;
*)
echo "Usage $ {Start|stop|status|restart}"
Exit 1
;;
Esac
: Wq
[Email protected] ~]# chmod +X/ETC/INIT.D/LNMP
[Email protected] ~]# chkconfig--add LNMP
[Email protected] ~]#/ETC/INIT.D/LNMP status
Nginx is running!
PHP-FPM is runing!
This article is from the "Lp-linux" blog, make sure to keep this source http://linuxlp.blog.51cto.com/11463376/1773559
Linux Enterprise Common Service---deployment LNMP environment