CentOS7 安装lnmp简单教学

lnmp简单教学

去以上链接把需要的的关键包进行下载:https://pan.baidu.com/s/12rPq3A8tsCyevOnn1dZZgw
提取码:gskm

安装mysql

打开自己的虚拟机连接 xshell
把所有的 Inmp相关包上传到虚拟机


在这里插入图片描述
将相关lnmp的依赖环境进行安装
[root@localhost src]# yum -y install gcc gcc-c++ lrzsz pcre-devel zlib-devel cmake ncurses-devel libxml2-devel bzip2-devel bzip2-devel readline-devel openssl-devel libcul-devel
创建用户和属组
[root@localhost src]# groupadd mysql

[root@localhost src]# useradd -s /sbin/nologin -M -g mysql mysql
开始解压mysql
[root@localhost src]# tar -zxf mysql-5.5.22.tar,gz
进入 mysql包中
[root@localhost src]# cd mysql-5.5.22
进行编译和安装
[root@localhost mysql-5.5.22]# cmake -DCMAKE_INSTALL_PREFIX=/data/server/mysql -DSYSCONFDIR=/etc/ -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all

[root@localhost mysql-5.5.22]# make -j4 && make install
设置权限
root@localhost mysql-5.5.22]# chown -R mysql:mysql /data/server/mysql/

[root@localhost mysql-5.5.22]# cp support-files/my-medium.cnf /etc/my.cnf
[root@localhost mysql-5.5.22]# cp support-files/my-medium.cnf /etc/my.cnf
cp: overwrite ‘/etc/my.cnf’? y

初始化环境
[root@localhost mysql-5.5.22]# /data/server/mysql/scripts/mysql_install_db --user=mysql --basedir=/data/server/mysql --datadir=/data/server/mysql/data
创建优化路径
[root@localhost mysql-5.5.22]# ln -s /data/server/mysql/bin/* /usr/local/bin/
添加系统服务和开启服务
[root@localhost mysql-5.5.22]# cp support-files/mysql.server /etc/init.d/mysqld
[root@localhost mysql-5.5.22]# cp support-files/mysql.server /etc/init.d/mysqld
cp: overwrite ‘/etc/init.d/mysqld’? y

[root@localhost mysql-5.5.22]# chmod a+x /etc/init.d/mysqld

[root@localhost mysql-5.5.22]# chkconfig --add mysqld

[root@localhost mysql-5.5.22]# systemctl start mysqld

[root@localhost mysql-5.5.22]# netstat -anput |grep mysqld
进入交互模式
在这里插入图片描述

安装nginx

开始解压nginx
[root@localhost src]# tar -zxf nginx-1.11.5.tar.gz
创建用户和属组
[root@localhost src]# groupadd nginx

[root@localhost src]# useradd -s /sbin/nologin -M -g nginx nginx nginx
进入 nginx包
root@localhost src]# cd nginx-1.11.5
编译和安装
[root@localhost nginx-1.11.5]# ./configure --prefix=/data/server/nginx --user=nginx --group=nginx

[root@localhost nginx-1.11.5]# make && make install
优化路径
[root@localhost nginx-1.11.5]# ln -s /data/server/nginx/sbin/nginx /usr/local/sbin/
进入root 开启服务 关闭防火墙
root@localhost nginx-1.11.5]# cd

[root@localhost ~]# nginx

[root@localhost ~]# systemctl stop firewalld
在浏览器上输入自己设置虚拟机的 ip
在这里插入图片描述

安装php服务

开始解压php
[root@localhost src]# tar -zxf php-7.2.0.tar.gz
进入 php包中
[root@localhost src]# cd php-7.2.0
进行编译
root@localhost php-7.2.0]# ./configure --prefix=/data/server/php --with-config-file-path=/etc --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-opcache=no --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gettext --enable-mbstring --with-iconv --with-mcrypt --with-mhash --with-openssl --enable-bcmath --enable-soap --with-libxml-dir --enable-pcntl --enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-sockets --with-curl --with-zlib --enable-zip --with-bz2 --with-readline --without-sqlite3 --without-pdo-sqlite --with-pear

退入libmcrypt进行解压依赖包
[root@localhost php-7.2.0]# cd …

[root@localhost src]# tar -zxf libmcrypt-2.5.8.tar.gz

[root@localhost src]# cd libmcrypt-2.5.8
进行编译和安装
[root@localhost libmcrypt-2.5.8]# ./configure

[root@localhost libmcrypt-2.5.8]# make && make install

退入安装包目录然后进入php
[root@localhost libmcrypt-2.5.8]# cd …

[root@localhost src]# cd php-7.2.0
安装一个依赖环境
[root@localhost php-7.2.0] yum -y install libcurl-devel
进行重新的编译和安装
[root@localhost php-7.2.0]# ./configure --prefix=/data/server/php --with-config-file-path=/etc --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-opcache=no --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gettext --enable-mbstring --with-iconv --with-mcrypt --with-mhash --with-openssl --enable-bcmath --enable-soap --with-libxml-dir --enable-pcntl --enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-sockets --with-curl --with-zlib --enable-zip --with-bz2 --with-readline --without-sqlite3 --without-pdo-sqlite --with-pear

[root@localhost php-7.2.0]# make -j4 && make install
复制配置文件
[root@localhost php-7.2.0]# cp php.ini-development /data/server/php/etc/php.ini

[root@localhost php-7.2.0]# cp /data/server/php/etc/php-fpm.conf.default /data/server/php/etc/php-fpm.conf
[root@localhost php-7.2.0]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
发现抱错
[root@localhost php-7.2.0]# groupadd www

[root@localhost php-7.2.0]# useradd -s /sbin/nologin -M -g www www

给相关权限
[root@localhost php-7.2.0]# chmod +x /etc/init.d/php-fpm

[root@localhost php-7.2.0]# /etc/init.d/php-fpm start

进入
[root@localhost php-7.2.0]# cd /data/server/php/etc

[root@localhost etc]# cd php-fpm.d
复制相关文件
[root@localhost php-fpm.d]# cp www.conf.default www.conf
[root@localhost php-fpm.d]# /etc/init.d/php-fpm start
进行修改脚本
[root@localhost php-fpm.d]# vi /data/server/nginx/conf/nginx.conf
看下方图片进行修改
在这里插入图片描述

在这里插入图片描述在这里插入图片描述在这里插入图片描述之后退出并保存

编译lnmp环境
[root@localhost php-fpm.d]# vi /data/server/nginx/html/cui.php
如图
在这里插入图片描述
重启nginx
[root@localhost php-fpm.d]#nginx -s reload
在电脑的浏览器输入自己的 IP+cui.phpce验证
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值