标签:Linux学习
12.1 LNMP架构介绍和LAMP不同的是,提供web服务的是 Nginx
并且 PHP 是作为一个独立服务存在的,这个服务叫做php-fpm
Nginx 直接处理静态请求,动态请求会转发给php-fpm
12.2 MySQL安装
cd /usr/local/src
wget https://mirrors.tuna.tsinghua.edu.cn/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 (或 useradd -r -m -d /data/mysql -s /sbin/nologin 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
basedir=/usr/local/mysql
datadir=/data/mysql
/etc/init.d/mysqld start
12.3-4 PHP安装
PHP安装
和LAMP安装PHP方法有差别,需要开启php-fpm服务
cd /usr/local/src
wget http://cn2.php.net/distributions/php-5.6.34.tar.gz
tar zxvf php-5.6.34.tar.gz
useradd -r -s /sbin/nologin php-fpm
cd php-5.6.34
./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
yum install -y libcurl-devel
/usr/local/php-fpm/sbin/php-fpm -m
/usr/local/php-fpm/sbin/php-fpm -i
/usr/local/php-fpm/sbin/php-fpm -t
ls /usr/local/php-fpm/etc/
cp php.ini-production /usr/local/php-fpm/etc/php.ini
vim /usr/local/php-fpm/etc/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 = 127.0.0.1:9000
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 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@linux01 ~]# cd /usr/local/src/
[root@linux01 src]# tar zxvf php-7.2.4.tar.gz
[root@linux01 src]# cd php-7.2.4/
[root@linux01 php-7.2.4]# useradd -r -s /sbin/nologin php-fpm
[root@linux01 php-7.2.4]# yum install -y libcurl-devel
[root@linux01 php-7.2.4]# yum install -y libxml2-devel
[root@linux01 php-7.2.4]# yum install -y openssl-devel
[root@linux01 php-7.2.4]# yum install -y libjpeg-turbo-devel
[root@linux01 php-7.2.4]# yum install -y libpng-devel
[root@linux01 php-7.2.4]# yum install -y freetype-devel
[root@linux01 php-7.2.4]# ./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@linux01 php-7.2.4]# make
[root@linux01 php-7.2.4]# make install
[root@linux01 php-7.2.4]# /usr/local/php-fpm/sbin/php-fpm -m
[root@linux01 php-7.2.4]# /usr/local/php-fpm/sbin/php-fpm -i
[root@linux01 php-7.2.4]# /usr/local/php-fpm/sbin/php-fpm -t
[root@linux01 php-7.2.4]# ls /usr/local/php-fpm/etc/
pear.conf php-fpm.conf.default
[root@linux01 php-7.2.4]# cp php.ini-production /usr/local/php-fpm/etc/php.ini
[root@linux01 php-7.2.4]# vim /usr/local/php-fpm/etc/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
[root@linux01 php-7.2.4]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@linux01 php-7.2.4]# chmod 755 /etc/init.d/php-fpm
[root@linux01 php-7.2.4]# chkconfig -add php-fpm
[root@linux01 php-7.2.4]# chkconfig php-fpm on
[root@linux01 php-7.2.4]# service php-fpm start
[root@linux01 php-7.2.4]# ps aux |grep php-fpm
12.5 Nginx介绍
Nginx官网 nginx.org,最新版1.13,最新稳定版1.12
Nginx应用场景:web服务、反向代理、负载均衡
Nginx著名分支,淘宝基于Nginx开发的Tengine,使用上和Nginx一致,服务名,配置文件名都一样,和Nginx的最大区别在于Tenging增加了一些定制化模块,在安全限速方面表现突出,另外它支持对js,css合并
Nginx核心+lua相关的组件和模块组成了一个支持lua的高性能web容器openresty,参考http://jinnianshilongnian.iteye.com/blog/2280928
标签:Linux学习
原文地址:http://blog.51cto.com/9298822/2107014