学习四十三

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了学习四十三相关的知识,希望对你有一定的参考价值。

12.1 LNMP架构介绍
12.2 mysql安装
12.3/12.4 php安装
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~~

LNMP架构介绍

技术分享图片

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
此处报错按一下提示操作:

一.
FATAL ERROR: please install the following Perl modules before executing ./scripts/mysqlinstalldb:
Data::Dumper
[[email protected] mysql]# ^C
[[email protected] mysql]# yum install -y perl-Module-Install.noarch
二.
Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
[[email protected] mysql]# yum install libaio -y

vim /etc/my.cnf
[mysqld]
datadir=/data/mysql
socket=/tmp/mysql.sock
[mysqld_safe]
#log-error=/var/log/mysql/mysql.log
#pid-file=/var/run/mysqld/mysqld.pid

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
#添加服务进去
chkconfig --add mysql
设置开机启动
chkconfig mysql on
service mysql start

[[email protected] mysql]# service mysqld start
Starting MySQL [ OK ]

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
可能会报错
一.

configure: error: xml2-config not found. Please check your libxml2 installation

[[email protected] php-5.6.30]#yum install libxml2
[[email protected] php-5.6.30]#yum install libxml2-devel -y
二.
configure: error: Cannot find OpenSSL‘s <evp.h>
[[email protected] php-5.6.30]# yum install openssl openssl-devel -y
三.
configure: error: Please reinstall the libcurl distribution -
easy.h should be in <curl-dir>/include/curl/
[[email protected] php-5.6.30]# yum install curl curl-devel -y
四.
configure: error: jpeglib.h not found.
[[email protected] php-5.6.30]# yum -y install libjpeg-devel
五.
configure: error: png.h not found.
yum install -y libpng
yum install -y libpng-devel
六.
configure: error: freetype-config not found.
yum install -y freetype-devel.x86_64
七.
configure: error: mcrypt.h not found. Please reinstall libmcrypt
yum install -y epel-release
yum install -y libmcrypt-devel

安装成功
技术分享图片
make && make install
cp php.ini-production /usr/local/php-fpm/etc/php.ini
cd /usr/local/php-fpm/etc/
mv php-fpm.conf.default 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

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

[[email protected] php-5.6.30]# service php-fpm start
Starting php-fpm [23-Apr-2018 22:51:37] ERROR: failed to open configuration file ‘/usr/local/php-fpm/etc/php-fpm.conf‘: No such file or directory (2)
[23-Apr-2018 22:51:37] ERROR: failed to load configuration file ‘/usr/local/php-fpm/etc/php-fpm.conf‘
[23-Apr-2018 22:51:37] ERROR: FPM initialization failed
failed

此时可以用/usr/local/php-fpm/sbin/php-fpm -t
如果报错以下信息
[[email protected] php-5.6.30]# /usr/local/php-fpm/sbin/php-fpm -t
[23-Apr-2018 22:57:25] NOTICE: configuration file /usr/local/php-fpm/etc/php-fpm.conf test is successful

useradd -s /sbin/nologin php-fpm
启动成功
[[email protected] php-5.6.30]# service php-fpm start
Starting php-fpm done

ps aux |grep php-fpm

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

以上是关于学习四十三的主要内容,如果未能解决你的问题,请参考以下文章

C++项目三代码参考(改进版)

日常Geetest滑动验证码(三代canvas版)处理小结(以B站登录验证为例)

[从零开始学习FPGA编程-47]:视野篇 - 第三代半导体技术现状与发展趋势

webpack优化篇(四十三):多进程/多实例构建:资源并行解析可选方案

马哥教育第四十一至四十三学习总结

Vue 教程(四十九)Vuex 核心概念和项目结构