搭建LNMP环境 nginx fastcgi 连接php
来源:互联网 发布:开票软件重装 编辑:程序博客网 时间:2024/05/22 04:26
软件版本:redhat6.5 php5.538 mysql5.1 nginx1.10.2
一、关闭SELinux setenforce 0二、安装mysql
1、yum 安装mysql
2、yum -y install mysql*
3、安装完后启动mysql
4、service mysqld start 检查是否可以正常启动
5、输入mysql可以进入到mysql
三、编译安装php
1、下载php-5.5.38.tar.bz2 php5.3以后自带php-fpm
2、yum安装下列支持文件
gcc gcc-c++ libxml2 libxml2-devel autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel
3、解压php-5.5.38.tar.bz2
4、进入php-5.5.38
5、#./configure --prefix=/usr/local/php --enable-fpm --with-mysql --with-mysqli (开启fpm 支持mysql php5.4以后支持--with-mysql --with-mysqli 省略后面参数)
# make
# make install
#cp php.ini-dist /usr/local/php/lib/php.ini 复制php配置文件
6.启动php-fpm
cd /usr/local/php/sbin
./php-fpm
查看 9000端口是否监听 lsof -i:9000
四、安装nginx
1.下载nginx,解压
2、yum安装依赖程序: zlib pcre openssl
3、安装
./configure --prefix=/usr/local/nginx
make
make install
4.启动nginx:/usr/local/nginx/sbin ./nginx
5.检查80端口是否被监听 访问nginx自带测试页面是否正常 注:关闭linux防火墙 service iptables stop
6.修改nginx配置文件 nginx.conf
location / {
root html;
index index.html index.htm index.php; 增加index.php
}
取消下面的注释
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 代理的目录 或改为 /usr/local/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
7.重启nginx ./nginx -s reload 或kill掉80端口再启动nginx
8.在nginx的html目录下建立php测试页
vim /usr/local/nginx/html/index.php
<?php
phpinfo();
?>
9.访问主机IP 出现php版本信息说明解析php成功
php连接mysql
nginx php-fpm mysql 服务都是正常启动
vim /usr/local/nginx/html/index.php
<?php
$link=mysqli_connect("127.0.0.1","root",""); 注:此处用localhost会连接失败 localhost使用套接字连接 127.0.0.1使用tcp连接
if($link)
echo "success";
else
echo "fail---------";
phpinfo();
?>
保存退出后 连接服务器地址
如果输出success说明连接数据库成功
阅读全文
0 0
- 搭建LNMP环境 nginx fastcgi 连接php
- Nginx+PHP(FastCGI)环境搭建
- CentOS5.5安装Nginx、PHP(FastCGI)、MySQL --搭建LNMP环境安装wordpress
- Debian+Nginx+PHP(FastCGI)+MySQL搭建LNMP服务器(最新版)
- LNMP(Linux+Nginx+MySQL+PHP)环境搭建
- LNMP(linux+nginx+mysql+php)环境搭建
- LNMP(Linux+nginx+MySQL+PHP)环境搭建
- 使用putty连接linux服务器/VPS,并搭建lnmp集成环境(nginx+mysql+php)
- LNMP搭建,nginx整合php-fpm即fastCGI实现,以及nginx的多虚拟主机配置
- 自己手动搭建lnmp环境、linux+php+nginx环境搭配
- CmsTop 大众版运行环境搭建 (CentOS+Nginx+PHP FastCGI)
- Debian+Nginx+PHP(FastCGI)+MySQL搭建LNMP服务器(三版)
- Debian+Nginx+PHP(FastCGI)+MySQL搭建LNMP服务器(三版)
- nginx+python+fastcgi环境搭建
- 搭建LNMP(linux+nginx+mysql+php)服务器环境配置实例教程
- 配置nginx支持php yum搭建lnmp环境(CentOS6)
- lnmp 环境搭建 源代码包安装 linux,nginx,mysql,php
- 从零搭建LNMP环境(二) - 集成Nginx与PHP
- mysql基础
- 双绞线的制作,T568A线序,T568B线序
- Java开发实战1200例(第1卷+第2卷)pdf教程+随书光盘源码
- 数据库之select的执行顺序
- java研发方向校招复习知识点汇总
- 搭建LNMP环境 nginx fastcgi 连接php
- docker 的安装以及常见使用的命令
- Unreal 4 BumpOffset Material 凸块偏移
- 小白成长日记
- jQuery常用的一些方法
- 4行CSS实现【表格内容超过一行的部分,用省略号代替】【支持IE6】
- RecyclerView 滑动检测 (上滑 up)(下滑 down)(顶部 top)(底部 bottom)e
- 【自动化测试工具】QTP/UFT入门--雷锋
- 0-1背包问题 python