相思资源网 Design By www.200059.com

1:查看环境:

 [root@localhost ~]# cat /etc/redhat-release

2:关掉防火墙

#重启后生效开启
[root@localhost ~]# chkconfig iptables off

or

#即时生效,重启后失效开启
[root@localhost ~]# service iptables stop

关闭selinux

#即时生效,重启后失效
[root@localhost ~]#setenforce 0

 //将SELINUX=enforcing修改为disabled然后重启生效
[root@localhost ~]# vi /etc/selinux/config  

3.配置CentOS 6.7 第三方yum源(CentOS默认的标准源里没有nginx软件包)

 

[root@localhost ~]#wget http://www.atomicorp.com/installers/atomic

 [root@localhost ~]#sh ./atomic

 [root@localhost ~]#yum check-update

4:安装开发包和库文件

复制代码 代码如下:#注意不要换行
[root@localhost ~]#yum -y install ntp make openssl openssl-devel pcre pcre-devel libpng libpng-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-devel zlib zlib-devel gcc gcc-c++ libXpm libXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2 libxml2-devel imake autoconf automake screen sysstat compat-libstdc++-33 curl curl-devel

5:卸载已安装的apache、mysql、php

# yum remove httpd
# yum remove mysql
# yum remove php

6:安装nginx

# yum install nginx
# service nginx start
# chkconfig --levels 235 nginx on     //设2、3、5级别开机启动

7:安装mysql

# yum install mysql mysql-server mysql-devel
# service mysqld start
# chkconfig --levels 235 mysqld on

//登陆MySQL删除空用户,修改root密码
mysql>select user,host,password from mysql.user;
 
mysql>drop user ''@localhost;
 
mysql>update mysql.user set password = PASSWORD('your password') where user='root';
 
mysql>flush privileges;

8:安装php

//同样注意不要换行
# yum install php lighttpd-fastcgi php-cli php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mssql php-snmp php-soap
//安装php和所需组件使PHP支持MySQL、FastCGI模式
#yum install php-tidy php-common php-devel php-fpm php-mysql
# service php-fpm start
# chkconfig --levels 235 php-fpm on

9:配置nginx支持php

//将配置文件改为备份文件
# mv /etc/nginx/nginx.conf /etc/nginx/nginx.confbak

//由于原配置文件要自己去写因此可以使用默认的配置文件作为配置文件
# cp /etc/nginx/nginx.conf.default /etc/nginx/nginx.conf

//修改nginx配置文件server段,添加fastcgi支持
# vi /etc/nginx/nginx.conf
//加入index.php
index index.php index.html index.htm;

//将下列代码注释去掉,并修改成nginx默认路径
location ~ \.php$ {
   root   html;
   fastcgi_pass 127.0.0.1:9000;
   fastcgi_index index.php;
   fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
   include  fastcgi_params;
  }

10:配置php

//编辑文件php.ini,在文件末尾添加cgi.fix_pathinfo = 1 

[root@CentOS ~]# vi /etc/php.ini

11:重启nginx php-fpm

# service nginx restart
# service php-fpm restart

12:建立info.php文件

# vi /usr/share/nginx/html/info.php
<"theimg" src="/UploadFiles/2021-04-10/2016102085330069.jpg">

  显示phpinfo界面  环境搭建成功

标签:
centos,lnmp环境搭建,centos6,lnmp环境搭建,centos安装lnmp环境

相思资源网 Design By www.200059.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
相思资源网 Design By www.200059.com

评论“CentOS6.7系统中配置LNMP环境”

暂无CentOS6.7系统中配置LNMP环境的评论...