linux下安装lnmp环境

 时间:2024-10-19 04:20:31

这里是教大家如何在linux下利用Yum安装LNMP环境。

工具/原料

服务器一台

自用电脑一台

putty软件一个

安装nginx

1、检查是否安装该程序:whichnginx#查看nginx是否存在whichphp#查看php是否存在whichmysql#查看mysql是否存在

linux下安装lnmp环境

2、yumlistnginx#列出nginxyuminstallnginx#安装nginx#看见{Complete!}安装成功。

linux下安装lnmp环境

linux下安装lnmp环境

3、whichnginx#查看nginx是否存在servicenginxstart#启动nginx进程方法[1]/etc/init.d/nginxstart#启动nginx进程方法[2]ps-ef|grepnginx#查看nginx进程

linux下安装lnmp环境

4、ifconfig#查看网卡信息打开浏览器:http://182.92.73.109/看到{欢迎界面}说明安装成功!

linux下安装lnmp环境

linux下安装lnmp环境

安装PHP

1、安装PHP:yumlistphpphp-fpm#列出php和php-fpm是否存在yum-yinstallphpphp-fpm#安装php和php-fpm软件包#看见{Complete!}安装成功。------------------------------------启动php-fpm:/etc/init.d/php-fpmstart#1servicephp-fpmstart#2

linux下安装lnmp环境

2、修改nginx配置文件让PHP擢爻充种的请求转发到php-fpm所绑定的ip和端口上:vi/etc/nginx/艘早祓胂conf.d/default.conf#行[37-43]去掉#号:location~\.php${root/usr/share/nginx/html;fastcgi_pass127.0.0.1:9000;fastcgi_indexindex.php;fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;includefastcgi_params;}代码解释:当用户的请求URL是以.php为结尾的时候则执行这个区块的内容:root指定的目录pass转发端口[e]index如果是指定目录结尾的时候自动加上index.phpparam要执行documnetRoot里的文件传递过来的文件名include在家配置文件[e]注:(1):wq#保存(2)i#插入(3):q!#不保存退出

linux下安装lnmp环境

linux下安装lnmp环境

3、重启nginx:/etc/init.d/nginxrestart#1servicenginxrestart#2--------------------------------------------------验证是否处理请求PHP文件:vi/usr/share/nginx/html/info.php<?phpphpinfo();---------------------------------------------------访问IP网址:http://182.92.73.109/info.php

linux下安装lnmp环境

linux下安装lnmp环境

安装mysql

1、yumlistmysqlmysql-server#搜索mysql数据包yum-yinstallmysqlmysql-server#不需要提示安装#看见{Complete!}安装成功。

linux下安装lnmp环境

2、查看mysq盟敢势袂lmysql-server是否存在:whichmysql#查看mysql是否存在whi艘早祓胂chmysqld_safe#查看mysqld_safe是否存在-------------------------------------------------------mysql_install_db#mysql初始化,在mysql中建立起系统表mysqld_safe&#启动mysqlps-ef|grepmysqld#mysqld是否存在----------------------------------------------mysql-uroot#链接进入mysql数据库Ctrl-C--exit!#退出终端

linux下安装lnmp环境

安装php对mysql操作的扩展

1、yum-yinstallphp-mysql#安装php-mysql扩展servicephp-fpmrestart#重启php-fpm进程

linux下安装lnmp环境

2、检查是否可以通过php操作mysql数据库:vi/usr/sha筠续师诈re/nginx/html/db.php<?php@mysq造婷用痃li_connect("localhost","root","","mysql")ordie("connectmysqlfailed\n");echo"connectok\n";---------------------------------------------------------php/usr/share/nginx/html/db.php#用命令行执行phphttp://182.92.73.109/db.php#在浏览器执行

linux下安装lnmp环境

linux下安装lnmp环境

3、/etc/init.d/mysqldstop#停止mysql进程[1]servic娣定撰钠emysq造婷用痃ldstop#停止mysql进程[2]--------------------------------------------------php/usr/share/nginx/html/db.php#用命令行执行phphttp://182.92.73.109/db.php#在浏览器执行---------------------------------------------------看到以下效果就是说明数据链接没有问题安装PHP模块详细信息稍后发表,暂就这么多。

linux下安装lnmp环境

thinkphp 3.1.3 的安装和配置 win7怎么设置电脑开机密码 如何用pycharm编写python程序:[6]range和list chrome浏览器怎么设置地址栏的默认搜索引擎? 最省钱的装修攻略
热门搜索
hello kitty图片 h动漫电影 广汽传祺gs4图片 基本全是肉的动漫 中秋节手抄报图片