centos7.0之Lnmp和Lamp

首先配置防火墙

CentOS 7.0默认使用的是firewall作为防火墙

1.关闭firewall:

systemctl stop firewalld.service #停止firewall
  systemctl disable firewalld.service #禁止firewall开机启动

2.关闭SELINUX

vi /etc/selinux/config
#SELINUX=enforcing #注释掉
SELINUX=disabled #增加
:wq! #保存退出
setenforce 0 #使配置立即生效

Lnmp安装

1.安装nginx

yum install yum-priorities -y
wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum install nginx

2.启动nginx

systemctl start nginx.service #启动nginx
systemctl stop nginx.service #停止
systemctl restart nginx.service #重启
systemctl enable nginx.service #设置开机启动

3.更改nginx端口号(根据自己需求)

cd /etc/nginx/conf.d/
vim default.conf
把listen 80改成listen 81
然后重启nginx
systemctl restart nginx.service #重启nginx

4.访问http://ip:81即可看到nginx首页

5.下一步安装PHP-fpm

yum install php-fpm
安装完毕后
systemctl start php-fpm.service #启动php-fpm
systemctl enable php-fpm.service #设置开机启动

6.更改nginx配置文件识别php  vi /etc/nginx/conf.d/default.conf,把之前的#给去掉就可以了,顺手改一下fastcgi_param

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;
  }

7.访问test.php

在 /usr/share/nginx/html中新建一个test.php <?php echo 123;?>

访问http://ip:81/test.php即可看到nginx中的php页面

8.负载配置

进入 vi /etc/nginx/conf.d/default.conf

upstream site{
      server 172.16.170.138;
      server 172.16.170.139;
  }
  server {
    listen    80;
    server_name necodon.cc; 

    #charset koi8-r;
    #access_log /var/log/nginx/log/host.access.log main; 

    location / {
      root  /usr/share/nginx/html;
      index index.html index.htm;
      proxy_pass http://necodon.cc;
    }

9.域名修改  把上面(necodon.cc)site,localhost改为www.a.com

Lamp安装

1.安装apache

yum install httpd #根据提示,输入Y安装即可成功安装
  systemctl start httpd.service #启动apache
  systemctl stop httpd.service #停止apache
  systemctl restart httpd.service #重启apache
  systemctl enable httpd.service #设置apache开机启动

2.安装mariadb(MySQL)

yum install mariadb mariadb-server #询问是否要安装,输入Y即可自动安装,直到安装完成
  systemctl start mariadb.service #启动MariaDB
  systemctl stop mariadb.service #停止MariaDB
  systemctl restart mariadb.service #重启MariaDB
  systemctl enable mariadb.service #设置开机启动

3.修改mysql密码,安装后默认为空

修改mysql密码:set password for ‘root‘@‘localhost‘=password ‘root‘;

mysql授权远程连接(navicat等): grant all on *.* to root identified by ‘root‘;

4.安装PHP以及组件,使PHP支持 MariaDB

yum install php php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash
#这里选择以上安装包进行安装,根据提示输入Y回车
systemctl restart mariadb.service #重启MariaDB
systemctl restart httpd.service #重启apache

5.访问测试

cd /var/www/html
vi index.php #输入下面内容
 <?php
  phpinfo();
?>
:wq! #保存退出

在客户端浏览器输入服务器IP地址,可以看到如下图所示相关的配置信息!

时间: 2024-08-10 02:11:08

centos7.0之Lnmp和Lamp的相关文章

CentOS7.0 x86_64系统上构建php开发环境--Lamp(包括设置虚拟目录,添加SELinux对httpd的支持等知识)

一.安装mysql,直接用yum安装即可,mysql在centos7.0版本中被mariadb替代了. 命令: yum install mysql-server mysql 安装好了,选择修改mysql默认的root用户的密码,启动mysql服务. 命令: service mysqld start 二.安装apache,直接yum安装,与mysql安装方式相近,不再赘述. 安装完毕,开启apache服务. 命令: systemctl start httpd.service 测试以下apache是

lnmp、lamp、lnmpa一键安装包(Updated: 2016-4-12)

lnmp.lamp.lnmpa一键安装包(Updated: 2016-4-12) 文章目录 脚本特性 安装步骤 如何添加虚拟主机? 如何删除虚拟主机? 如何管理ftp账号? 数据备份 如何管理服务? 如何更新版本? 如何卸载? 如何重装? 更新日志 这个脚本是使用shell编写,为了快速在生产环境上部署lnmp/lamp/lnmpa(Linux.Nginx/Tengine/OpenResty.MySQL/MariaDB/Percona.PHP),适用于CentOS 5~7(包括redhat).D

centos7.3搭建LNMP并部署wordpress站点

centos7.3搭建LNMP并部署wordpress站点 一.拓扑图 二.准备工作: 1.三台独立主机(虚拟机) nginx:10.0.0.11 php-fpm:10.0.0.2 mariadb:10.0.0.13 准备好yum环境(推荐阿里云yum源,请百度搜索) 2.相关的软件包准备 10.0.0.11(nginx) yum install nginx -y 10.0.0.2(php-fpm) yum install php-fpm php-mysql  php-mbstring php-

lnmp、lamp、lnmpa一键安装包(Updated: 2015-10-25)

lnmp.lamp.lnmpa一键安装包(Updated: 2015-10-25) 2014-12-26 Posted by yeho 这个脚本是使用shell编写,为了快速在生产环境上部署lnmp/lamp/lnmpa(Linux.Nginx/Tengine.MySQL/MariaDB/Percona.PHP),适用于CentOS 5~7(包括redhat).Debian 6-8.Ubuntu 12.04-15.04的32位和64位. 脚本特性  持续不断更新 源码编译安装,大多数源码是最新s

CentOS7 编译安装LNMP

LNMP(Linux-Nginx-Mysql-PHP),本文在CentOS7.0上编译LNMP尝尝鲜,全文基本上都是采用手动编译部署...依赖yum帮我安装了GCC和automake..写这个东西耗时有点久了...尼玛 太花时间啦,Linux运维交流群:344177552 主要软件版本: nginx-1.6.0php-5.3.5mysql-5.5.6 yum源配置(其实没什么改动) [[email protected] ~]# cat /etc/yum.repos.d/1.repo [1]nam

Mac下用brew搭建LNMP和LAMP开发环境

Mac下搭建lamp开发环境很容易,有xampp和mamp现成的集成环境.但是集成环境对于经常需要自定义一些配置的开发者来说会非常麻烦,而且Mac本身自带apache和php,在brew的帮助下非常容易手动搭建,可控性很高 Brew brew对于mac,就像apt-get对于ubuntu,安装软件的好帮手,不能方便更多- brew的安装方式如下: ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go/install)"

【CNMP系列】CentOS7.0下安装Nginx服务

话步前言,CNMP之路,系统起步:http://www.cnblogs.com/riverdubu/p/6425028.html 这回我来讲解下CentOS7.0下如何安装和配置Nginx服务 Nginx的历史不在此赘述,轻量,快是它的特性.只是因为现在的模块没有达到apache的模块数量级,未来有超越apache的势头. 首先,我们要安装个必要的软件(上节提到过,可能有人并未安装) #yum install wget 因为Nginx以来与gcc的编译环境,所以,在mini centos中需要安

【CNMP系列】CentOS7.0下安装PHP5.6.30服务

上一节我们讲过了如何在CentOS7.0下安装MySql服务,如果没有看到欢迎页面的朋友,可以加我的个人微信详聊:litao514148204 附上一节地址:http://www.cnblogs.com/riverdubu/p/6426852.html 关于php-fpm nginx本身不能处理PHP,它只是个web服务器,当接收到请求后,如果是php请求,则发给php解释器处理,并把结果返回给客户端. nginx一般是把请求发fastcgi管理进程处理,fascgi管理进程选择cgi子进程处理

【CNMP系列】CentOS7.0下安装MySql5.6服务

接上一回的话,CentOS7.0下安装好了Nginx服务,对于我们的CNMP,我们可以开始我们的M啦,就是传统意义上的MySql服务 MySql简介 MySQL是一个关系型数据库管理系统,由瑞典MySQL AB 公司开发,目前属于 Oracle 旗下产品.在 WEB 应用方面,MySQL是最好的 RDBMS (Relational Database Management System,关系数据库管理系统) 应用软件. 官网:https://www.mysql.com/ 与其他大型数据库例如 Or