12.1、LNMP架构介绍
和LAMP不同的是,提供web服务的是Nginx
并且php是作为一个独立的服务存在的,这个服务叫做php-fpm
Nginx直接处理静态请求,动态请求会转发给php-fpm
12.2、MySQL安装
cd /usr/local/src
wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
tar zxvf mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
mv mysql-5.6.35-linux-glibc2.5-x86_64 /usr/local/mysql
cd /usr/local/mysql
useradd mysql
mkdir /data/
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
cp support-files/my-default.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
vi /etc/init.d/mysqld
定义basedir和datadir
/etc/init.d/mysqld start
[root@zgxlinux-01 src]# rm -rf /usr/local/mysql/
[root@zgxlinux-01 src]# rm -rf /etc/init.d/mysqld
[root@zgxlinux-01 src]# tar mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz
[root@zgxlinux-01 src]# mv mysql-5.6.39-linux-glibc2.12-x86_64 /usr/local/mysql
[root@zgxlinux-01 src]# ls /usr/local/mysql/
bin docs man scripts support-files
COPYING include mysql-test share
data lib README sql-bench
[root@zgxlinux-01 src]# rm -rf /data/mysql*
[root@zgxlinux-01 src]# ls /data/
mariadb wwwroot
[root@zgxlinux-01 mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
[root@zgxlinux-01 mysql]# echo $?
0
[root@zgxlinux-01 mysql]# vim /etc/my.cnf
[root@zgxlinux-01 mysql]# cp support-files/mysql.server /etc/init.d/mysql
[root@zgxlinux-01 mysql]# vim /etc/init.d/mysql
[root@zgxlinux-01 mysql]# mv /etc/init.d/mysql /etc/init.d/mysqld
[root@zgxlinux-01 ~]# /etc/init.d/mysqld start
Starting MySQL. SUCCESS!
[root@zgxlinux-01 ~]# ps aux |grep mysql
root 1713 0.0 0.1 113308 1616 pts/0 S 16:45 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/zgxlinux-01.pid
mysql 1852 1.0 44.8 1302720 451564 pts/0 Sl 16:45 0:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=zgxlinux-01.err --pid-file=/data/mysql/zgxlinux-01.pid --socket=/tmp/mysql.sock
root 1878 0.0 0.0 112720 984 pts/0 R+ 16:46 0:00 grep --color=auto mysql
[root@zgxlinux-01 mysql]# chkconfig --add mysqld
[root@zgxlinux-01 mysql]# chkconfig mysqld on
[root@zgxlinux-01 mysql]# service mysqld stop
Shutting down MySQL.. SUCCESS!
[root@zgxlinux-01 mysql]# service mysqld start
Starting MySQL. SUCCESS!
[root@zgxlinux-01 mysql]# ps aux |grep mysqld
root 1985 0.0 0.1 11816 1604 pts/0 S 16:48 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/zgxlinux-01.pid
mysql 2124 1.3 45.2 1302720 455144 pts/0 Sl 16:48 0:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=zgxlinux-01.err --pid-file=/data/mysql/zgxlinux-01.pid --socket=/tmp/mysql.sock
root 2148 0.0 0.0 112720 984 pts/0 R+ 16:48 0:00 grep --color=auto mysqld
12.3、PHP安装
和LAMP安装PHP方法有差别,需要开启php-fpm服务
cd /usr/local/src/
wget http://cn2.php.net/distributions/php-5.6.30.tar.gz
tar zxf php-5.6.30.tar.gz
useradd -s /sbin/nologin php-fpm
cd php-5.6.30
./configure --prefix=/usr/local/php-fpm --with-config-file-path=/usr/local/php-fpm/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --with-pear --with-curl --with-openssl
make && make install
cp php.ini-production /usr/local/php-fpm/etc/php.ini
vi /usr/local/php/etc/php-fpm.conf //写入如下内容(参考https://coding.net/u/aminglinux/p/aminglinux-book/git/blob/master/D15Z/php-fpm.conf)
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod 755 /etc/init.d/php-fpm
chkconfig --add php-fpm
chkconfig php-fpm on
service php-fpm start
ps aux |grep php-fpm
#安装过程
[root@zgxlinux-01 src]# cd php-5.6.32/
[root@zgxlinux-01 php-5.6.32]# make clean
[root@zgxlinux-01 php-5.6.32]# ./configure --prefix=/usr/local/php-fpm --with-config-file-path=/usr/local/php-fpm/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --with-pear --with-curl --with-openssl
[root@zgxlinux-01 php-5.6.32]# echo $?
1
[root@zgxlinux-01 php-5.6.32]# yum install -y libcurl-devel
[root@zgxlinux-01 php-5.6.32]# echo $?
0
[root@zgxlinux-01 php-5.6.32]# make && make install
[root@zgxlinux-01 php-5.6.32]# echo $?
0