首先,浏览器发送http request请求到服务器(Nginx),服务器响应并处理web请求,将一些静态资源(CSS,图片,视频等)保存服务器上,然后将php脚本通过接口传输协议(网关协议)PHP-FCGI(fast-cgi)传输给PHP-FPM(进程管理程序),PHP-FPM不做处理,然后PHP-FPM调用PHP解析器进程,PHP解析器解析php脚本信息。PHP解析器进程可以启动多个,进行并发执行。然后将解析后的脚本返回到PHP-FPM,PHP-FPM再通过fast-cgi的形式将脚本信息传送给Nginx.服务器再通过Http response的形式传送给浏览器。
需要用的安装包:
mysql-boost-5.7.17.tar.gz
cmake-2.8.12.2-4.el6.x86_64.rpm
[root@server1 ~]# ls
mysql-boost-5.7.17.tar.gz ##安装包
cmake-2.8.12.2-4.el6.x86_64.rpm ##安装包
[root@server1 ~]# tar zxf mysql-boost-5.7.17.tar.gz ##解压Mysql
[root@server1 ~]# yum install cmake-2.8.12.2-4.el6.x86_64.rpm -y ##安装cmake
[root@server1 ~]# cd mysql-5.7.17/
[root@server1 mysql-5.7.17]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql \ #安装目录
> -DMYSQL_DATADIR=/usr/local/lnmp/mysql/data \ #数据库存放目录
> -DMYSQL_UNIX_ADDR=/usr/local/lnmp/mysql/data/mysql.sock \ #Unix socket 文件路径
> -DWITH_MYISAM_STORAGE_ENGINE=1 \ #安装 myisam 存储引擎
> -DWITH_INNOBASE_STORAGE_ENGINE=1 \ #安装 innodb 存储引擎
> -DDEFAULT_CHARSET=utf8 \ #使用 utf8 字符
> -DDEFAULT_COLLATION=utf8_general_ci \ #校验字符
> -DEXTRA_CHARSETS=all / #安装所有扩展字符集
[root@server1 mysql-5.7.17]# yum install gcc gcc-c++ -y ##安装gcc gcc-c++
[root@server1 mysql-5.7.17]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql -DMYSQL_DATADIR=/usr/local/lnmp/mysql/data -DMYSQL_UNIX_ADDR=/usr/local/lnmp/mysql/data/mysql.sock -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all ##再次编译
[root@server1 mysql-5.7.17]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql -DMYSQL_DATADIR=/usr/local/lnmp/mysql/data -DMYSQL_UNIX_ADDR=/usr/local/lnmp/mysql/data/mysql.sock -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_BOOST=boost/boost_1_59_0/ ##添加最后一个路径
[root@server1 mysql-5.7.17]# rm -fr CMakeCache.txt ##清空缓存文件
[root@server1 mysql-5.7.17]# yum install -y ncurses-devel
[root@server1 mysql-5.7.17]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql -DMYSQL_DATADIR=/usr/local/lnmp/mysql/data -DMYSQL_UNIX_ADDR=/usr/local/lnmp/mysql/data/mysql.sock -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_BOOST=boost/boost_1_59_0/ ##再次编译
[root@server1 mysql-5.7.17]# make
[root@server1 mysql-5.7.17]# make install
[root@server1 mysql-5.7.17]# cd /usr/local/lnmp/mysql/
[root@server1 mysql]# cd support-files/
[root@server1 support-files]# cp my-default.cnf /etc/my.cnf ##会被覆盖
cp: overwrite `/etc/my.cnf'? y
[root@server1 support-files]# vim /etc/my.cnf ##mysql配置文件
[root@server1 support-files]# ls
[root@server1 support-files]# file mysql.server
mysql.server: POSIX shell script text executable
[root@server1 support-files]# cp mysql.server /etc/init.d/mysqld
[root@server1 support-files]# ll /etc/init.d/mysqld
[root@server1 support-files]# id mysql
id: mysql: No such user ##报错,查找不到mysql用户
[root@server1 support-files]# groupadd -g 27 mysql ##建立mysql组
[root@server1 support-files]# useradd -u 27 -g 27 -M -d /usr/local/lnmp/mysql/data -s /sbin/nologin mysql ##建立mysql用户
[root@server1 support-files]# cd ..
[root@server1 mysql]# ll
[root@server1 mysql]# chown -R mysql.mysql . ##将用户和组改为mysql
[root@server1 mysql]# pwd
/usr/local/lnmp/mysql
[root@server1 mysql]# cd bin/
[root@server1 bin]# cd
[root@server1 ~]# vim .bash_profile ##更改
[root@server1 mysql]# mysqld --initialize --user=mysql ##按提示完成 mysql 安全设置,生产环境推荐使用
[root@server1 mysql]# cd data/
[root@server1 data]# ll #检查是否更改成功
[root@server1 data]# /etc/init.d/mysqld start ##检查是否能开启
[root@server1 data]# /etc/init.d/mysqld stop ##关闭mysql
[root@server1 data]# pwd
[root@server1 data]# cd ..
[root@server1 mysql]# chown root.root . -R ##将用户和组更改为root
[root@server1 mysql]# ll ##查看更改成功
[root@server1 mysql]# chown mysql data/ -R ##只将data目录的用户更改为mysql
[root@server1 mysql]# ll ##查看
[root@server1 mysql]# /etc/init.d/mysqld start ##打开mysql
[root@server1 mysql]# mysql_secure_installation ##注册
[root@server1 php-5.6.35]# tar jxf php-5.6.35.tar.bz2
[root@server1 php-5.6.35]# yum install -y openssl-devel
[root@server1 ~]# yum install -y libmcrypt-devel-2.5.8-9.el6.x86_64.rpm libmcrypt-2.5.8-9.el6.x86_64.rpm
[root@server1 ~]# yum install -y gmp-devel
[root@server1 ~]# yum install -y curl-devel
[root@server1 ~]# yum install -y libxml2-devel
[root@server1 php-5.6.35]# yum install -y gd-devel-2.0.35-11.el6.x86_64.rpm
[root@server1 ~]# yum install -y net-snmp-devel
[root@server1 php-5.6.35]# ./configure --prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc --with-mysql=mysqld --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-snmp --with-gd --with-zlid --with-curl --with-libxml-dir --with-png-dir --with-jpeg-dir --with-freetype-dir --with-pear --with-gettext --with-gmp --enable-inline-optimization --enable-soap --enable-ftp --enable-sockets --enable-mbstring --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-mcrypt --with-mhash
[root@server1 php-5.6.35]# make
[root@server1 php-5.6.35]# make install
[root@server1 php-5.6.35]# cd /usr/local/lnmp/php/
[root@server1 php]# ls
bin etc include lib php sbin var
[root@server1 php]# cd etc/
[root@server1 etc]# ls
pear.conf php-fpm.conf.default
[root@server1 etc]# cp php-fpm.conf.default php-fpm.conf
[root@server1 etc]# ls
pear.conf php-fpm.conf php-fpm.conf.default
[root@server1 etc]# cd
[root@server1 ~]# cd php-5.6.35
[root@server1 php-5.6.35]# cp php.ini-production /usr/local/lnmp/php/etc/php.ini
[root@server1 php-5.6.35]# cd /usr/local/lnmp/php/
[root@server1 php]# cd etc/
[root@server1 etc]# vim php.ini
[root@server1 etc]# vim php-fpm.conf
[root@server1 etc]# id nginx
id: nginx: No such user
[root@server1 etc]# useradd -M -d /usr/local/lnmp/nginx -s /sbin/nologin nginx ##建立用户
[root@server1 etc]# cd
[root@server1 ~]# cd php-5.6.35
[root@server1 php-5.6.35]# cd sapi/
[root@server1 sapi]# cd fpm/
[root@server1 fpm]# ls
[root@server1 fpm]# file init.d.php-fpm
[root@server1 fpm]# cp init.d.php-fpm /etc/init.d/php-fpm
[root@server1 fpm]# chmod +x /etc/init.d/php-fpm ##赋予权限
[root@server1 fpm]# /etc/init.d/php-fpm start
[root@server1 ~]# ls
nginx-1.10.1.tar.gz nginx-sticky-module-ng.tar.gz
[root@server1 ~]# tar zxf nginx-1.10.1.tar.gz
[root@server1 ~]# tar zxf nginx-sticky-module-ng.tar.gz
[root@server1 ~]# cd nginx-1.10.1
[root@server1 nginx-1.10.1]# vim src/core/nginx.h
[root@server1 nginx-1.10.1]# vim auto/cc/gcc
[root@server1 nginx-1.10.1]# ./configure --prefix=/usr/local/lnmp/nginx --with-http_ssl_module --with-http_stub_status_module --user=nginx --group=nginx --with-threads --with-file-aio
[root@server1 nginx-1.10.1]# yum install pcre-devel -y
[root@server1 nginx-1.10.1]# make
[root@server1 nginx-1.10.1]# make install
[root@server1 nginx-1.10.1]# cd /usr/local/
[root@server1 local]# ls
bin etc games include lib lib64 libexec lnmp sbin share src
[root@server1 local]# cd lnmp/
[root@server1 lnmp]# ls
mysql nginx php
[root@server1 lnmp]# cd nginx/
[root@server1 nginx]# ls
conf html logs sbin
[root@server1 nginx]# cd conf/
[root@server1 conf]# vim nginx.conf
[root@server1 conf]# vim /etc/security/limits.conf
[root@server1 conf]# vim nginx.conf
在 nginx.conf文件
在 /etc/security/limits.conf 文件
在nginx.conf文件
[root@server1 conf]# cd
[root@server1 ~]# cd nginx-1.10.1
[root@server1 nginx-1.10.1]# cd contrib/
[root@server1 contrib]# ls
geo2nginx.pl README unicode2nginx vim
[root@server1 contrib]# cd /usr/local/lnmp/nginx/sbin/
[root@server1 sbin]# ls
nginx
[root@server1 sbin]# pwd
/usr/local/lnmp/nginx/sbin
[root@server1 sbin]# vim .bash_profile
[root@server1 sbin]# cd
[root@server1 ~]# vim .bash_profile
[root@server1 ~]# source .bash_profile
[root@server1 ~]# nginx -t
[root@server1 ~]# nginx
网页访问:172.25.41.1
[root@server1 ~]# cd /usr/local/lnmp/nginx/html/
[root@server1 html]# vim index.php
[root@server1 html]# cat index.php
[root@server1 html]# pwd
/usr/local/lnmp/nginx/html
[root@server1 html]# cd ..
[root@server1 nginx]# cd conf/
[root@server1 conf]# vim nginx.conf ##设置默认首页