LNMP架构搭建编译安装详细部署
- LNMP架构搭建编译安装详细部署
- 环境准备
- 安装nginx
- 安装mysql
- 安装php
- 配置nginx
- 测试PHP程序
LNMP架构搭建编译安装详细部署
环境准备
关闭防火墙和SElinux
[root@yxr ~]# systemctl stop firewalld
[root@yxr ~]# systemctl disable firewalld
[root@yxr ~]# sed -ri 's/(SELINUX=).*/\1disabled/g' /etc/selinux/config
[root@yxr ~]# setenforce 0
安装nginx
创建系统用户nginx
[root@yxr ~]# useradd -r -M -s /sbin/nologin nginx安装依赖环境
[root@yxr ~]# yum -y install pcre-devel openssl openssl-devel gd-devel
[root@yxr ~]# yum -y groups mark install 'Development Tools'创建日志存放目录
[root@yxr ~]# mkdir -p /var/log/nginx
[root@yxr ~]# chown -R nginx.nginx /var/log/nginx下载nginx
[root@yxr ~]# cd /usr/src/
[root@yxr src]# yum -y install wget
[root@yxr src]# wget http://nginx.org/download/nginx-1.12.0.tar.gz
[root@yxr src]# ls
debug kernels nginx-1.12.0.tar.gz
[root@yxr src]# tar xf nginx-1.12.0.tar.gz
[root@yxr src]# cd nginx-1.12.0/
[root@yxr nginx-1.12.0]# ./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-debug \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_image_filter_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--http-log-path=/var/log/nginx/access.log \
--error-log-path=/var/log/nginx/error.log
[root@yxr nginx-1.12.0]# make -j $(grep 'processor' /proc/cpuinfo | wc -l) && make installnginx安装后配置环境变量
[root@yxr nginx-1.12.0]# echo 'export PATH=/usr/local/nginx/sbin:$PATH' > /etc/profile.d/nginx.sh
[root@yxr nginx-1.12.0]# . /etc/profile.d/nginx.sh启动nginx
[root@yxr nginx-1.12.0]# nginx
[root@yxr nginx-1.12.0]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:80 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
安装mysql
安装依赖包
[root@yxr nginx-1.12.0]# yum -y install ncurses-devel openssl-devel openssl cmake mariadb-devel创建用户和组
[root@yxr nginx-1.12.0]# groupadd -r -g 306 mysql
[root@yxr nginx-1.12.0]# useradd -M -s /sbin/nologin -g 306 -u 306 my
sql
[root@yxr nginx-1.12.0]# id mysql
uid=306(mysql) gid=306(mysql) groups=306(mysql)下载二进制格式的mysql软件包
[root@yxr nginx-1.12.0]# cd /usr/src/
[root@yxr src]# wget https://downloads.mysql.com/archives/get/file/mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz
解压软件至/usr/local/
[root@yxr src]# tar xf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[root@yxr src]# cd /usr/local/
[root@yxr local]# ls
bin include libexec sbin
etc lib mysql-5.7.22-linux-glibc2.12-x86_64 share
games lib64 nginx src
[root@yxr local]# ln -sv mysql-5.7.22-linux-glibc2.12-x86_64/ mysql
‘mysql’ -> ‘mysql-5.7.22-linux-glibc2.12-x86_64/’修改目录/usr/local/mysql的属主属组
[root@yxr local]# chown -R mysql.mysql /usr/local/mysql
[root@yxr local]# ll /usr/local/mysql -d
lrwxrwxrwx. 1 mysql mysql 36 Sep 2 15:16 /usr/local/mysql -> mysql-5.7.22-linux-glibc2.12-x86_64/添加环境变量
[root@yxr local]# ls /usr/local/mysql
bin COPYING docs include lib man README share support-files
[root@yxr local]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[root@yxr local]# . /etc/profile.d/mysql.sh
[root@yxr local]# echo $PATH
/usr/local/mysql/bin:/usr/local/nginx/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin建立数据存放目录
[root@yxr local]# mkdir /opt/data
[root@yxr local]# chown -R mysql.mysql /opt/data/
[root@yxr local]# ll /opt/
total 0
drwxr-xr-x. 2 mysql mysql 6 Sep 2 15:20 data初始化数据库
[root@yxr local]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/opt/data/
2018-09-02T07:21:29.854503Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-09-02T07:21:32.515522Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-09-02T07:21:32.930110Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-09-02T07:21:32.999081Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: d1941708-ae80-11e8-a733-000c29989243.
2018-09-02T07:21:33.001639Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-09-02T07:21:33.071597Z 1 [Note] A temporary password is generated for root@localhost: Ayrd-rQd>3rp //随机密码配置mysql
[root@yxr ~]# ln -sv /usr/local/mysql/include/ /usr/local/include/mysql
‘/usr/local/include/mysql’ -> ‘/usr/local/mysql/include/’
[root@yxr ~]# echo '/usr/local/mysql/lib' > /etc/ld.so.conf.d/mysql.conf
[root@yxr ~]# ldconfig -v
[root@yxr ~]# ldconfig -p |grep mysqllibmysqlclient.so.20 (libc6,x86-64) => /usr/local/mysql/lib/libmysqlclient.so.20libmysqlclient.so.18 (libc6,x86-64) => /usr/lib64/mysql/libmysqlclient.so.18libmysqlclient.so (libc6,x86-64) => /usr/lib64/mysql/libmysqclient.solibmysqlclient.so (libc6,x86-64) => /usr/local/mysql/lib/libmysqlclient.so生成配置文件
[root@yxr ~]# cat > /etc/my.cnf <<EOF
> [mysqld]
> basedir = /usr/local/mysql
> datadir = /opt/data
> socket = /tmp/mysql.sock
> port = 3306
> pid-file = /opt/data/mysql.pid
> user = mysql
> skip-name-resolve
> EOF配置服务启动脚本
[root@yxr ~]# cp -a /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@yxr ~]# sed -ri 's#^(basedir=).*#\1/usr/local/mysql#g' /etc/init.d/mysqld
[root@yxr ~]# sed -ri 's#^(datadir=).*#\1/opt/data#g' /etc/init.d/mysqld启动mysql
[root@yxr ~]# service mysqld start
Starting MySQL.Logging to '/opt/data/yxr.err'.SUCCESS!
[root@yxr ~]# ps -ef | grep mysql
root 4639 1 0 15:27 pts/1 00:00:00 /bin/sh /usr/localmysql/bin/mysqld_safe --datadir=/opt/data --pid-file=/opt/data/mysql.pid
mysql 4817 4639 3 15:27 pts/1 00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/opt/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=yxr.err --pid-file=/opt/data/mysql.pid --socket=/tmp/mysql.sock --port=3306
root 4847 1552 0 15:28 pts/1 00:00:00 grep --color=auto mysql
[root@yxr ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:80 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 80 :::3306 :::* 修改密码,使用临时密码登录
[root@yxr ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.22Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.设置新密码
mysql> set password = password('yaoxiaorong!');
Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> exit
Bye
安装php
配置yum 源
[root@yxr ~]# cd /etc/yum.repos.d/
[root@yxr yum.repos.d]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
[root@yxr yum.repos.d]# sed -i 's/\$releasever/7/g' /etc/yum.repos.d/CentOS7-Base-163.repo
[root@yxr yum.repos.d]# sed -i 's/^enabled=.*/enabled=1/g' /etc/yum.repos.d/CentOS7-Base-163.repo
[root@yxr yum.repos.d]# yum -y install epel-release安装依赖包
[root@yxr yum.repos.d]# yum -y install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel mhash mhash-devel下载php
[root@yxr yum.repos.d]# cd /usr/src/
[root@yxr src]# wget http://cn.php.net/distributions/php-7.2.8.tar.xz编译安装php
[root@yxr src]# cd php-7.2.8/
[root@yxr php-7.2.8]# ./configure --prefix=/usr/local/php7 \
--with-curl \
--with-freetype-dir \
--with-gd \
--with-gettext \
--with-iconv-dir \
--with-kerberos \
--with-libdir=lib64 \
--with-libxml-dir=/usr \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-openssl \
--with-pcre-regex \
--with-pdo-mysql \
--with-pdo-sqlite \
--with-pear \
--with-jpeg-dir \
--with-png-dir \
--with-xmlrpc \
--with-xsl \
--with-zlib \
--with-config-file-path=/etc \
--with-config-file-scan-dir=/etc/php.d \
--with-bz2 \
--enable-fpm \
--enable-bcmath \
--enable-libxml \
--enable-inline-optimization \
--enable-mbregex \
--enable-mbstring \
--enable-opcache \
--enable-pcntl \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvsem \
--enable-xml \
--enable-zip
[root@yxr php-7.2.8]# make -j 2 && make install安装后配置
[root@yxr php-7.2.8]# echo 'export PATH=/usr/local/php7/bin:$PATH' > /etc/profile.d/php7.sh
[root@yxr php-7.2.8]# source /etc/profile.d/php7.sh
[root@yxr php-7.2.8]# which php
/usr/local/php7/bin/php
[root@yxr php-7.2.8]# php -v
PHP 7.2.8 (cli) (built: Sep 2 2018 16:04:46) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies配置php-fpm
[root@yxr php-7.2.8]# cp php.ini-production /etc/php.ini
[root@yxr php-7.2.8]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@yxr php-7.2.8]# chmod +x /etc/rc.d/init.d/php-fpm
[root@yxr php-7.2.8]# cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
[root@yxr php-7.2.8]# cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf配置fpm的相关选项为你所需要的值:
[root@yxr php-7.2.8]# vim /usr/local/php7/etc/php-fpm.conf
; Relative path can also be used. They will be prefixed by:
; - the global prefix if it's been set (-p argument)
; - /usr/local/php7 otherwise
include=/usr/local/php7/etc/php-fpm.d/*.conf
pm.max_children = 50 //最多同时提供50个进程提供50个并发服务
pm.start_servers = 5 //启动时启动5个进程
pm.min_spare_servers = 2 //最小空闲进程数
pm.max_spare_servers = 8 //最大空闲进程数启动php-fpm
[root@yxr php-7.2.8]# service php-fpm start
Starting php-fpm done查看端口
[root@yxr php-7.2.8]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:80 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 127.0.0.1:9000 *:*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 80 :::3306 :::* [root@yxr php-7.2.8]# ps -ef |grep php
root 57567 1 0 16:16 ? 00:00:00 php-fpm: master process (/usr/local/php7/etc/php-fpm.conf)
nobody 57568 57567 0 16:16 ? 00:00:00 php-fpm: pool www
nobody 57569 57567 0 16:16 ? 00:00:00 php-fpm: pool www
nobody 57570 57567 0 16:16 ? 00:00:00 php-fpm: pool www
nobody 57571 57567 0 16:16 ? 00:00:00 php-fpm: pool www
nobody 57572 57567 0 16:16 ? 00:00:00 php-fpm: pool www
root 57575 1552 0 16:17 pts/1 00:00:00 grep --color=auto php
配置nginx
修改nginx配置文件/usr/local/nginx/conf/nginx.conf
[root@yxr ~]# vim /usr/local/nginx/conf/nginx.conf
...location / {root html;index index.php index.html index.htm;}
...
去掉以下的注释并修改以下内容:
[root@yxr ~]# vim /usr/local/nginx/conf/nginx.conf
...location ~ \.php$ {root html;fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;include fastcgi_params;}
... 将/scripts修改成$document_root[root@yxr ~]# 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@yxr ~]# nginx -s reload
[root@yxr ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:80 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 127.0.0.1:9000 *:*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 80 :::3306 :::*
测试PHP程序
在nginx下的html目录下创建test.php文件并打印配置php
[root@yxr ~]# cd /usr/local/nginx/
[root@yxr nginx]# cd html/
[root@yxr html]# cat >test.php <<EOF
> <?php
> phpinfo();
> ?>
> EOF
验证:通过浏览器输入IP访问,这里IP是192.168.228.23
LNMP架构搭建编译安装详细部署相关推荐
- LNMP架构搭建以及一键部署
LNMP架构搭建以及一键部署 前言 一.数据流向 1.1 Nginx服务安装 1.1.1 关闭防火墙 1.1.2 将所需软件包拖入/opt目录下 1.1.3 安装依赖包 1.1.4 创建运行用户.组 ...
- LNMP架构搭建(源码编译)
1. LNMP架构介绍 LNMP代表的就是:Linux系统下Nginx+MySQL+PHP这种网站服务器架构. Linux是一类Unix计算机操作系统的统称,是目前最流行的免费操作系统.代表版本有:d ...
- 企业级LNMP架构搭建实例(基于Centos6.x)
1.1 部署LNMP架构说明 1.1.1 LNMP架构内容 01.部署linux系统 02.部署nginx网站服务 03.部署mysql数据库服务 04.部署php动态解析服务 1.1.2 配置LNM ...
- LNMP架构搭建实操
目录 一.安装Nginx服务 二.安装Mysql服务 三.安装PHP服务 四.使用LNMP架构搭建bbs论坛 LNMP架构是指Linux+Nginx+Mysql+PHP(Perl.Python) 首先 ...
- Chukwa搭建、安装、部署、应用
hadoop培训课程:Chukwa搭建.安装.部署.应用 1.搭建环境 部署节点操作系统为CentOS,防火墙和SElinux禁用,创建了一个shiyanlou用户并在系统根目录下创建/app目录,用 ...
- Qt最新版5.14在Windows环境静态编译安装和部署的完整过程 VS 2019-Qt static link build Windows 32 bit/64 bit
文章目录 为什么要静态编译(static link) 1.源码下载/source code download 2. 编译工具下载/compiler download 编译环境选择:MinGW/MSVC ...
- Qt最新版5.13在Windows环境静态编译安装和部署的完整过程(VS 2017/VS 2019)
文章目录 为什么要静态编译 1.源码下载 2. 编译工具下载 ActivePerl Python Ruby 编译环境选择 3.编译 1.修改源码里的qtbase\mkspecs\common\msvc ...
- Qt最新版5.12在Windows环境静态编译安装和部署的完整过程(VS2017)
文章目录 为什么要静态编译 1.源码下载 2. 编译工具下载 ActivePerl Python Ruby 编译环境选择 3.编译 1.修改源码里的qtbase\mkspecs\common\msvc ...
- CRFPP/CRF++编译安装与部署
CRFPP/CRF++编译安装与部署 下载CRF++ https://taku910.github.io/crfpp/#download 说明:在上面网站中下载CRF++ 0.58 解压 tar zx ...
- LNMP源码编译安装及一键部署LNMP架构
目录 一.LNMP 1.LNMP介绍 1.1 LNMP工作原理 1.2.LAMP工作原理 2.LAMP和LNMP的区别 3.编译安装的优点 4.各组件的主要作用 三.LNMP架构的部署 1.安装ngi ...
最新文章
- 在Zf2中实现Controller按照URL自动注册
- Python 基础 - Day 5 Assignment - ATM
- Webpack 打包太慢?来试试 Bundleless
- JS面向对象——Object对象的方法补充、原型继承关系图
- 设z=〖(1+xy)〗^y,求 ∂z/∂y
- 阿里云服务器从购买,备案,安装部署中遇到的一些坑
- 07_Redis事务
- 试用cmd markdown
- vue 使用百度地图api_高水准 Vue 百度地图组件Vue-BaiduMap
- rpm安装mysql指定数据仓库_linux(center OS7)安装JDK、tomcat、mysql 搭建java web项目运行环境-Go语言中文社区...
- Django 、 uWSGI 和 nginx 搭建服务器python应用环境
- 任务管理三部曲 - 模板使用说明(超实用模板下载)
- 佛系前端面试题记录--第六周
- 使用C++调用Socket接口实现简易TCP服务器
- 计算机中安装音乐软件是一种,电脑必装的八款软件,你装了吗?
- 18.Excel vba开发-计算个人所得税
- 可持久化入门 ի( ‘▿ ‘ )
- 18篇文章系统解读:中台规划如何撬动企业IT基础设施转型升级
- 微信小程序 — 二维码海报分享到好友功能
- WordPress重要文件wp-seting.php文件详解