Nginx轻量级、高并发、高度模块化设计、前端、静态页面快、配置简洁、作为负载均衡服务器支持7层负载均衡、反向代理还可做邮件代理服务器、社区活跃、启动简单容易,不间断服务下进行版本升级、异步进程模型,多个连接可以对应一个进程

Nginx安装IP:192.168.230.102

[root@localhost ~]# tar zxf nginx-1.14.0.tar.gz        //解压源代码包
[root@localhost ~]# cd nginx-1.14.0        //进入解压目录
[root@localhost ~]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/share/doc/pcre-7.8 && make && make install        //编译安装nginx
[root@localhost ~]# nginx -t    //校验完整性
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@localhost ~]# nginx        //启动服务
[root@localhost ~]#vim /usr/local/nginx/conf/nginx.conf        //编辑配置文件
  location ~ \.php$ {
              root           /nginx;
             fastcgi_pass   192.168.230.103:9000;
             fastcgi_index  index.php;
             fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
             include        fastcgi_params;
         }
[root@localhost ~]# vim /usr/local/nginx/conf/fastcgi.conf
fastcgi_param  REDIRECT_STATUS    200;
fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx;
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;
fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

Mysql安装IP:192.168.230.101

[root@localhost ~]# wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.11-1.el6.x86_64.rpm-bundle.tar    //下载MySQL最新版rpm包
[root@localhost ~]# tar xf mysql-8.0.11-1.el6.x86_64.rpm-bundle.tar    //解压下载的rpm包
[root@localhost ~]# rpm -e mysql –nodeps        //卸载系统默认mysql以免和安装冲突
[root@localhost ~]# rpm -e mysql-libs –nodeps        //卸载系统默认库以免和安装冲突
[root@localhost ~]# rpm -ivh mysql-community-common-8.0.11-1.el6.x86_64.rpm mysql-community-libs-8.0.11-1.el6.x86_64.rpm mysql-community-client-8.0.11-1.el6.x86_64.rpm mysql-community-server-8.0.11-1.el6.x86_64.rpm
[root@localhost ~]# service mysqld start        //初始化服务
[root@localhost ~]# grep 'temporary password' /var/log/mysqld.log |awk '{print $13}'    //查看系统初始化后的默认密码
2018-05-10T13:36:34.275298Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: YSwgfam)-39=
[root@localhost ~]# mysqladmin -uroot -p'YSwgfam)-39=' password abc123,        //修改MySQL数据库密码
[root@localhost ~]# mysql -uroot -pabc123,        //连接数据库
create user'backups'@'192.168.230.103' identified by 'abc123';    //创建用户
grant all on backups.* to 'backups'@'192.168.230.103';    //授权用户

PHP192.168.230.10 3:

[root@localhost ~]# yum -y install gd-devel zlib-devel libjpeg-devel libpng-devel libiconv-devel freetype-devel libxml2 libxml2-devel openssl openssl-devel curl-devel libxslt-devel libmcrypt-devel mhash mcrypt    //安装php-fpm依赖包
[root@localhost php-7.2.5]# ./configure --prefix=/usr/local/php --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-zip && make && make install        //配置安装选项
[root@localhost php-7.2.5]# cp php.ini-development /usr/local/php/lib/php.ini    //拷贝php主配置文件
[root@localhost php-7.2.5]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf    //拷贝php-fpm配置文件
[root@localhost php-7.2.5]# cp sapi/fpm/php-fpm /usr/local/bin/    //拷贝执行文件
[root@localhost php-7.2.5]# vim /usr/local/php/lib/php.ini    //编辑配置文件
cgi.fix_pathinfo=0
[root@localhost php-7.2.5]# useradd -M -s /sbin/nologin php    //创建程序用户
[root@localhost ~]# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf        //拷贝配置文件
[root@localhost ~]# vim /usr/local/php/etc/php-fpm.d/www.conf        //编辑配置文件
listen = 192.168.230.103:9000            //监听端口
user = nginx        //用户名                //*用户名和组的ID和NGINX服务器用户和组的ID必须一样
group = nginx        //组
[root@localhost ~]# ln -s /usr/local/bin/php-fpm /usr/bin/php-fpm    //优化链接
[root@localhost ~]# php-fpm    //启动php-fpm
[root@localhost /]# mkdir nginx
[root@localhost /]# chown -R nginx:nginx nginx
[root@localhost /]# cd nginx
[root@localhost nginx]# vim index.php
<?php
phpinfo();
?>
END

本文标题:LNMP分离安装

本文作者:宇宙最帅的男人

本文链接:https://www.ym68.cc/linux/20211529.html

版权声明:转载或者引用本文内容请注明来源及原作者,本文著作权归作者 (宇宙最帅的男人) 所有。

除非另有说明,本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议

最后修改:2021 年 06 月 15 日
如果觉得我的文章对你有用,请随意赞赏