LNMP介绍:
MYSQL安装:
使用二进制免编译包(发布前编译后再打包);为安装顺利可先使用yum安装wget,perl-Data-Dumper,libaio
cd /usr/local/src
wget http://mirrors.163.com/mysql/Downloads/MySQL-5.6/mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz
tar zxvf mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.6.39-linux-glibc2.12-x86_64 /usr/local/mysql
cd /usr/local/mysql
useradd mysql
mkdir /data/
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql #初始化
#若报FATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db:
#Data::Dumper
#则需先 yum -y install perl-Data-Dumper
#若报Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No #such file or directory
#则需先 yum -y install libaio
cp support-files/my-default.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
vim /etc/init.d/mysqld ; 定义basedir(mysql程序目录/usr/local/mysql)和datadir(/data/mysql)
chkconfig --add mysqld #加入系统服务
/etc/init.d/mysqld start
#/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql --datadir=/data/mysql & #命令行方式启动
php安装:
在lnmp里面php的安装和lamp的安装是有差别的。lnmp架构里php需要开启php-fpm服务,是一个独立的服务。
useradd -s /sbin/nologin php-fpm
cd /usr/local/src
wget http://cn2.php.net/distributions/php-5.6.32.tar.gz
tar zxvf php-5.6.32.tar.gz
cd php-5.6.32
#先确保已安装:openssl-devel;libxml2-devel;bzip2-devel;libjpeg-turbo-devel;libpng-devel;freetype-devel;epel-release;php-mcrypt;libmcrypt-devel 这几个包
./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
#若报错:libtool: link: `ext/opcache/ZendAccelerator.lo' is not a valid libtool object;则执行make distclean #重新初始化安装
ls /usr/local/php-fpm/sbin/php-fpm #检查服务是否存在。
cp /usr/local/src/php-5.6.30/php.ini-production /usr/local/php-fpm/etc/php.ini
vim /usr/local/php-fpm/etc/php-fpm.conf #创建php-fpm.conf文件并添加以下内容:
[global]
pid = /usr/local/php-fpm/var/run/php-fpm.pid
error_log = /usr/local/php-fpm/var/log/php-fpm.log
[www]
listen = /tmp/php-fcgi.sock
listen.mode = 666
user = php-fpm
group = php-fpm
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
rlimit_files = 1024
cp /usr/local/src/php-5.6.30/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
/usr/local/php-fpm/sbin/php-fpm -t #检测php配置文件的语法是否有问题
Nginx介绍:
Nginx官网 nginx.org,最新版1.13,最新稳定版1.12
Nginx应用场景:web服务、反向代理、负载均衡
Nginx著名分支:淘宝基于Nginx开发的Tengine,使用上和Nginx一样,和Nginx的最大区别在于Tenging增加了一些定制化模块,在安全限速方面表现突出,支持对js,css合并
Nginx核心+lua相关的组件和模块组成了一个支持lua的高性能web容器openresty