十二周一次课(3月12日)
12.1 LNMP架构介绍
12.2 MySQL安装
LNMP中MySQL的安装和LAMP中基本是一致的,安装配置步骤如下:
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
vi /etc/my.cnf
定义basedir和datadir:
datadir=/data/mysql
socket=/tmp/mysql.sockcp support-files/mysql.server /etc/init.d/mysqld
vi /etc/init.d/mysqld
定义basedir和datadir:
basedir=/usr/local/mysql
datadir=/data/mysql/etc/init.d/mysqld start #启动mysql
检查mysql是否启动并删除相应文件
之后进入LNMP的mysql安装
将服务加入到启动列表里方法:
chkconfig --add mysqld
chkconfig mysqld on //设置开机启动
12.3/12.4 PHP安装
LNMP和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 需要创建用户php-fpm以用于php-fpm服务
cd php-5.6.30
配置php-fpm:
./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编译和安装php-fpm:
make && make install配置php-fpm的配置文件和启动脚本:
cp php.ini-production /usr/local/php-fpm/etc/php.ini 拷贝php-fpm的配置文件
vi /usr/local/php-fpm/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 拷贝php-fpm的启动脚本
chmod 755 /etc/init.d/php-fpm 设置拷贝启动脚本权限为755
chkconfig --add php-fpm 将php-fpm加入启动列表
chkconfig php-fpm on 设置开机启动
service php-fpm start 启动php-fpm服务
ps aux |grep php-fpm 查看php-fpm进程
先删除之前文件
配置配置文件
或监听内部网络
12.5 Nginx介绍
扩展
Nginx为什么比Apache Httpd高效:原理篇 http://www.toxingwang.com/linux-unix/linux-basic/1712.html
apache和nginx工作原理比较 http://www.server110.com/nginx/201402/6543.html
mod_php 和 mod_fastcgi以及php-fpm的比较 http://dwz.cn/1lwMSd
概念了解:CGI,FastCGI,PHP-CGI与PHP-FPM http://www.nowamagic.net/librarys/veda/detail/1319/
https://www.awaimai.com/371.html