centos7 yum安装lnmp(php5.4)

2019年01月08日 | 1 条评论 | 485

centos7 yum安装lnmp,目前版本用php5.4+mysql5.6+nginx1.14.2,后续推出php7.0+的安装方式


一、安装虚拟机VirtualBox

1、下载虚拟机;

 

二、安装centos7

    1、下载centos7安装

2、选择桥接网路进行安装

3man yum 查看yum的描述信息,ls -1 /etc/yum.repo.d/*.repo所有源在这里;

 

三、yum安装nginx

        

1、yum search nginx搜索

2、nginx的yum源,配置yum源的地址http://nginx.org/en/linux_packages.html

To set up the yum repository for RHEL/CentOS, create the file named /etc/yum.repos.d/nginx.repo with the following contents:

[nginx]

name=nginx repo

baseurl=http://nginx.org/packages/OS/OSRELEASE/$basearch/

gpgcheck=0

enabled=1

Replace “OS” with “rhel” or “centos”, depending on the distribution used, and “OSRELEASE” with “6” or “7”, for 6.x or 7.x versions, respectively.

 

3whereis nginx 

1、目录/etc/nginx 

2/etc/nginx/conf.d/配置虚拟

3、主配置文件nginx.conf

 

3、yum –y install nginx(yum –y install xxx 使用这个就不会老询问你要不要yes他会自动的同意,也就不需要你老确认)

 

 

启动: systemctl start nginx

关闭: systemctl stop nginx

查看状态: systemctl status nginx

开机禁用  systemctl disable nginx

开机启用   systemctl enable nginx

重新加载配置: systemctl  reload nginx

 

4、用ps –aux | grep nginx 查看nginx启动状态

 

5、关闭防火墙或者开启80端口让外网可以访问

firewalld的基本使用

启动: systemctl start firewalld

关闭: systemctl stop firewalld

查看状态: systemctl status firewalld 

开机禁用  systemctl disable firewalld

开机启用   systemctl enable firewalld

6ifconfig查看ip,在window用浏览器访问ip即可

 

7whereis default.php查看nginx虚拟安装目录配置在/etc/nginx/conf.d/default.conf,可进行配置

   find / -name html查看nginx的网站根目录,在/usr/share/nginx/html

8、访问linux系统ip即可访问到根目录index.html文件

 

9、/var/log/nginx访问日记和错误日记存放处 access.log和error.log在这里

 

10、网站访问日记

 

四、yum安装phpnginx支持php

  1/usr/share/nginx/html  添加探针phpinfo();

  2yum –y install php-fpm进行云安装php,作者安装到的是php5.4

启动: systemctl start php-fpm

关闭: systemctl stop php-fpm

查看状态: systemctl status php-fpm

开机禁用  systemctl disable php-fpm

开机启用   systemctl enable php-fpm

重新加载配置: systemctl  reload php-fpm

 

   3、配置nginx支持php

      ①配置/etc/nginx/conf.d/default.conf

   添加index.php文件

location / {

        root   /usr/share/nginx/html;

        index  index.html index.htm index.php;

}

 

然后配置.php请求被传送到后端的php-fpm模块,默认情况下php配置块是被注释的,此时去掉注释并修改为以下内容:

location ~ \.php$ {

    root    /usr/share/nginx/html;//注意这里之前是html,要是用这个可能报错

    fastcgi_pass   127.0.0.1:9000;

    fastcgi_index  index.php;

       fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

    include        fastcgi_params;

}

 

然后重新加载配置并重新启动php-fpm即可

 

 

 

yum安装 mysql 配置nginx支持

 

[linux]centos7下解决yum install mysql-server没有可用包

第一步:安装从网上下载文件的wget命令

[root@master ~]# yum -y install wget

 

第二步:下载mysqlrepo

[root@master ~]# wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

 

第三步:安装mysql-community-release-el7-5.noarch.rpm

[root@master ~]# rpm -ivh mysql-community-release-el7-5.noarch.rpm

 

第四步:查看下

[root@master ~]# ls -1 /etc/yum.repos.d/mysql-community*

/etc/yum.repos.d/mysql-community.repo

/etc/yum.repos.d/mysql-community-source.repo

会获得两个mysqlyum repo源:/etc/yum.repos.d/mysql-community.repo/etc/yum.repos.d/mysql-community-source.repo

第五步:安装mysql

[root@master ~]# yum -y install mysql-server

 

安装成功后,启动等命令

 

启动: systemctl start mysqld

关闭: systemctl stop mysqld

查看状态: systemctl status mysqld

开机禁用  systemctl disable mysqld

开机启用   systemctl enable mysqld

重新加载配置: systemctl  reload mysqld

 

2nginx安装mysql模块进行连接

 

               yum search php进行查看已下载好的模块,找到mysql模块安装

               yum –y install php-mysql安装好模块

               安装好后进行连接测试如下:

$con = mysql_connect("localhost","root","root");

if (!$con){

  die('Could not connect: ' . mysql_error());

}

echo 'ok';

 

3、命令直接修改mysql密码

 

/usr/bin/mysqladmin -u root password '密码'

 

 

 

 

 


技术咨询
换一个