1,LNMP架构介绍。
(1)和LAMP不同的是,提供web服务的是Ngnix。
(2)php是作为一个独立服务存在的,这个服务叫做php-fpm。
(3)Nginx直接处理静态请求,动态请求会转发给php-fpm。
关系如下图:
2,MySQL的安装。安装步骤和LAMP的一样。
香港高仿服务器。
cd /usr/local/src
wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz
tar zxvf mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz
mv mysql-5.6.36-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
在my.cnf和mysqld中定义basedir=/usr/local/mysql
datadir=/data/mysql
/etc/init.d/mysqld start
3,PHP安装。和LAMP安装PHP方法有差别,需要开启php-fpm服务。
首先清除之前安装的PHP。梦飞科技。服务器租用。国内外服务器。
# cd /usr/local/src/
#useradd -s /sbin/nologin php-fpm
# cd php-5.6.32# ls
acinclude.m4 INSTALL pear README.UNIX-BUILD-SYSTEM
aclocal.m4 install-sh php5.spec README.WIN32-BUILD-SYSTEM
build libs php5.spec.in run-tests.php
buildconf libtool php.gif sapi
buildconf.bat LICENSE php.ini-development scripts
CODING_STANDARDS ltmain.sh php.ini-production server-tests-config.php
config.guess main README.EXT_SKEL server-tests.php
config.log makedist README.GIT-RULES snapshot
config.nice Makefile README.input_filter stamp-h.in
config.status Makefile.frag README.MAILINGLIST_RULES stub.c
config.sub Makefile.fragments README.md tests
configure Makefile.gcov README.namespaces travis
configure.in Makefile.global README.NEW-OUTPUT-API TSRM
CREDITS Makefile.objects README.PARAMETER_PARSING_API UPGRADING
ext makerpm README.REDIST.BINS UPGRADING.INTERNALS
EXTENSIONS meta_ccld README.RELEASE_PROCESS vcsclean
footer missing README.SELF-CONTAINED-EXTENSIONS win32
generated_lists mkinstalldirs README.STREAMS Zend
genfiles modules README.SUBMITTING_PATCH
header netware README.TESTING
include NEWS README.TESTING2
[root@wwan-01 php-5.6.32]# make clean
find . -name \*.gcno -o -name \*.gcda | xargs rm -f
find . -name \*.lo -o -name \*.o | xargs rm -f
find . -name \*.la -o -name \*.a | xargs rm -f
find . -name \*.so | xargs rm -f
find . -name .libs -a -type d|xargs rm -rf
rm -f libphp5.la sapi/cli/php sapi/cgi/php-cgi libphp5.la modules/* libs/*
编译配置
./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: Please reinstall the libcurl distribution -
easy.h should be in <curl-dir>/include/curl/
[root@wwan-01 php-5.6.32]# yum install libcurl-devel
重新编译配置后make&&make install.
接下来执行如下操作:
vi /usr/local/php-fpm/etc/php-fpm.conf
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 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
4,Ngnix介绍。
Nginx官网 nginx.org。
Nginx应用场景:web服务、反向代理、负载均衡。
Nginx著名分支,淘宝基于Nginx开发的Tengine,使用上和Nginx一致,服务名,配置文件名都一样,和Nginx的最大区别在于Tenging增加了一些定制化模块,在安全限速方面表现突出,另外它支持对js,css合并。
ginx核心+lua相关的组件和模块组成了一个支持lua的高性能web容器openresty。
(责任编辑:joker) 部分网站内容及图片来源于网络,如有侵权或违规内容请联系管理员删除!