LINUX搭建LAMP笔记

.YUM:Yum(全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及CentOS中的Shell前端软件包管理器。基于RPM包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软件包,无须繁琐地一次次下载、安装。

1.网络环境检测

centos7.2的网络配置:

vim /etc/sysconfig/network-scripts/ifcfg-eno16777736

参考以下网络配置:

TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=eno16777736
UUID=a90b6241-89da-450a-9742-d5b186a17084
DEVICE=eno16777736
ONBOOT=yes
IPADDR0=192.168.0.228
PREFIXO0=24
GATEWAY0=192.168.0.1
DNS1=192.168.0.1 配置完毕后,使用 systemctl restart network.service 重启网络,然后 ping www.baidu.com 测试是否网络连接通畅。

2.安装LAMP

1.安装apache

1.更新yum 源(包管理)
`yum update`
2.安装:apache
yum install -y httpd
运行:/bin/systemctl start httpd.service  执行完运行命令之后是看不到效果的,这时候再输入查看
 apache服务状态命令来查看服务是否已经启动:     systemctl stop httpd.service #停止apache 或者是:service httpd stop systemctl restart httpd.service #重启apache 或者是:service httpd restart systemctl enable httpd.service #设置apache开机启动 或者是:service httpd enable
    
 测试apache服务是否正常开启,在我们本地浏览器里输入云服务 器的公网ip,我这里以118.25.14.210为例

enter description here

看到此图片说明apache安装成功

2.安装mysql

1.rpm -qa | grep mysql  // 这个命令就会查看该操作系统上是否已经安装了mysql数据库
通过这个命令查看该系统中是否已经安装了mysql, 可以看到我的系统比较干净,没有安装任何版本的mysql,如果你系统有安装,那可以选择进行卸载 2. rpm -e mysql  // 普通删除模式 3. rpm -e --nodeps mysql  // 强力删除模式,如果使用上面命令删除时,提示有依赖的 其它文件,则用该命令可以对其进行强力删除 4.安装
wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
    rpm -ivh mysql-community-release-el7-5.noarch.rpm
    yum install mysql-community-server
    成功安装之后重启mysql服务    
    初次安装mysql是root账户是没有密码的
    设置密码的方法:     输入mysql -uroot进入mysql数据库
      mysql> set password for ‘root’@‘localhost’ = password('newpasswd');
      mysql> quit        远程授权连接mysql
所有权限
    mysql>grant all privileges on *.* to root@"%" identified by "123456" with grant option;
//只读权限
grant select on *.* to root@"%" identified by "123456";
    mysql>FLUSH PRIVILEGES; 刷新配置

提示:Linux软件编译安装都需要依赖两个安装包 gcc gcc-c++ make 可使用 yum -y install gcc gcc-c++ 在线安装。

3.安装php

卸载php
rpm -qa | grep php
按依赖顺序进行删除
rpm -e php-fpm-5.3.3-22.el6.x86_64 rpm-e php-pdo-5.3.3-22.el6.x86_64 rpm -e php-pear-1.9.4-4.el6.noarch rpm-e php-cli-5.3.3-22.el6.x86_64 rpm -e php-5.3.3-22.el6.x86_64 rpm-e php-xml-5.3.3-22.el6.x86_64 rpm -e php-gd-5.3.3-22.el6.x86_64 rpm-e php-common-5.3.3-22.el6.x86_64 1.通过安装包方式安装
下载需要的php 版本 http://www.php.net/downloads.php(.tar.gz)
上传到 /usr/local/src 目录 解压 文件 tar_zxvf php-7.0.30.tar.gz
编译安装
make && make intsall 2.
通过yum 源安装
yum -y install php 安装(5,4版本) 安装php7 首先要更新yum源,不然肯定是老版本,一般都在5.6及以下,但是php7都出来好久了,性能提升50%以上!
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm 安装php7及扩展
yum install php70w
yum install php70w-common php70w-fpm php70w-opcache php70w-gd php70w-mysqlnd php70w-mbstring php70w-pecl-redis php70w-pecl-memcached php70w-devel 安装其他扩展 譬如你要加装xml,那么可以直接,别怀疑就是这么简单: yum install php70w-xml php -v

enter description here
php -m 查看所有

4.虚礼目录配置

1.设置系统自动检测index.php文件
编辑httpd的配置文件(/etc/httpd/conf/httpd.conf) 2.在/etc/httpd/conf/conf.d 下新建一个.conf格式文件
最好不要直接修改httd.conf
写入解析到的目录
<VirtualHost *:80>
DocumentRoot 目录地址
ServerName 域名
</VirtualHost> 重启httpd (service httpd restart) 3.开启路由重写 4.修改/etc/httpd/conf/httpd.conf
<Directory />
AllowOverride none
Require all denied
</Directory>
改为
<Directory />
AllowOverride all
Require all denied
</Directory> 重启httpd

5.搭建git仓库

1.安装git
yum install -y git 2.搭建git仓库 创建一个git用户组和用户,用来运行git服务:
groupadd git
useradd git -g git
passwd git #参数是用户名
最好切换到git用户 不然后面新建的git仓库都要改权限 烦烦烦!! $ su - git 如何生成密钥:http://blog.csdn.net/permanent_2008/article/details/73839384 备注:下边虚线内容为多余内容,只是留着存档而已。于本教程没有关系 添加证书之前,还要做这么一步: Git服务器打开RSA认证 。在Git服务器上首先需要将/etc/ssh/sshd_config中将RSA认证打开, 即: 1.RSAAuthentication yes 2.PubkeyAuthentication yes 3.AuthorizedKeysFile .ssh/authorized_keys 这里我们可以看到公钥存放在.ssh/authorized_keys文件中。 所以我们在/home/git下创建.ssh目录,然后创建authorized_keys文件,并将刚生成的公钥导入进去。 然后再次clone的时候,或者是之后push的时候,就不需要再输入密码了: Zhu@XXX/E/testgit/8.34 $ git clone git@192.168.8.34:/data/git/learngit.git Cloning into 'learngit'... warning: You appear to have cloned an empty repository. Checking connectivity... done. =============================== 收集所有需要登录的用户的公钥,就是他们自己的id_rsa.pub文件,把所有公钥导入到/home/git/.ssh/authorized_keys文件里,一行一个。
$ cd /home/git/
$ mkdir .ssh #新建文件夹
$ chmod 700 .ssh
$ touch .ssh/authorized_keys #新建文件
$ chmod 600 .ssh/authorized_keys

初始化Git仓库

$ cd /home/git
$ git init --bare test.git
Initialized empty Git repository in /home/git/test.git/

本地克隆仓库

$ git clone git@your-ip:test.git
Cloning into 'test'...
warning: You appear to have cloned an empty repository.
Checking connectivity... done.
your-ip 为您 Git 所在服务器 ip

代码自动部署

cd /home/git/test.git
cd hooks
//这里我们创建post-receive文件
#!/bin/sh
unset GIT_DIR
DeployPath="/alidata/www/project"
LogPath="/alidata/gitroot/project.git/hooks" echo -e "\n================= `date +"%Y-%m-%d %H:%M:%S"` ===============\n" >> $LogPath/gitsync.log 2>&1
cd $DeployPath #git stash
#先拉取再合并
git pull origin master >> $LogPath/gitsync.log 2>&1 #强制与远程服务器同步,不与本地合并,只能通过提交的客户端提交的方式修改代码。
#git fetch --all
#git reset --hard origin/master #time=`date`
#echo "web server pull at webserver at time: $time."
echo "================================================" >> $LogPath/gitsync.log 2>&1 更改post-receive的所有者和权限
chmod -R 774 post-receive
chown phper:git post-receive 最后在www下
mkdir project
chown -R phper:git project
chmod -R 774 project
cd /alidata/www
git clone /gitroot/project.git 好了git的同步就弄好了 如果同步用不了,打开hooks/gitsync.log查看错误日志 可能预见的错误 1、fatal: /usr/libexec/git-core/git-pull cannot be used without a working tree. 同步的项目文件夹没有建立---------------解决办法:在www下建立project项目文件夹 2、fatal: Not a git repository (or any of the parent directories): .git 项目文件里没有git初始化------------------解决办法:在www路径下执行git clone /alidata/gitroot/project.git 3、error: cannot open .git/FETCH_HEAD: Permission denied git在项目目录没有写入权限---------------解决办法:修改所有者以及权限 chown -R phper:git project / chmod -R 774 project 4、每次pull push的时候还是要输入密码
image.png 秘钥没有起作用-----------------------------解决办法:/var/log/secure查看一下日志,是否是.ssh的权限问题
chmod 700 .ssh
chmod 600 .ssh/authorized_keys

搭建SVN
https://blog.csdn.net/baidu_30000217/article/details/51396016?locationNum=1

contos LAMP环境搭建的更多相关文章

  1. lamp环境搭建(ubuntu)

    系统:Ubuntu14.04 方法一.最简单的在线安装 (参考网址:http://os.51cto.com/art/201307/405333.htm) 具体过程: [1]打开终端,执行命令 # su ...

  2. LAMP环境搭建教程(原创)

    学习PHP脚本编程语言之前,必须先搭建并熟悉开发环境,开发环境有很多种,例如LAMP.WAMP.MAMP等.这里我介绍一下LAMP环境的搭建,即Linux.Apache.MySQL.PHP环境. 一. ...

  3. LAMP环境搭建教程

    原文:LAMP环境搭建教程 学习PHP脚本编程语言之前,必须先搭建并熟悉开发环境,开发环境有很多种,例如LAMP.WAMP.MAMP等.这里我介绍一下LAMP环境的搭建,即Linux.Apache.M ...

  4. 转载自php100中文网 centos下lamp 环境搭建

    学习PHP脚本编程语言之前,必须先搭建并熟悉开发环境,开发环境有很多种,例如LAMP.WAMP.MAMP等.这里我介绍一下LAMP环境的搭建,即Linux.Apache.MySQL.PHP环境. 一. ...

  5. LAMP 环境搭建之源码包编译安装

    mysql用的二进制包安装. Apache php 用的源码包 mysql版本5.5.46    Apache版本2.4.7  PHP版本:5.5 mysql安装部分参考了阿铭linux的内容. 这是 ...

  6. Lamp环境搭建Linux CentOS6.5编译安装mysql5.6

    经典web开发组合Lamp环境搭建之mysql安装详解 安装前准备 通过rpm命令检查centos上是否已经安装mysql,然后卸载已经存在的mysql版本 [root@localhost src]# ...

  7. ubuntu上lamp环境搭建

    首先,介绍个彻底删除linux已经安装的软件的方法. sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-5. ...

  8. linux的基本操作(LAMP环境搭建)

    LAMP 环境搭建 经过前部分章节的学习,你已经掌握了linux的基础知识了.但是想成为一名系统管理员恐怕还有点难度,因为好多单位招聘这个职位的时候都要求有一定的工作经验.然而真正的经验一天两天是学不 ...

  9. lamp环境搭建(centos6.9+apache2.4+mysql5.7+php7.1)

    lamp环境搭建(centos6.9+apache2.4+mysql5.7+php7.1) 安装前准备:CentOS 6.9 64位 最小化安装 yum install -y make gcc gcc ...

随机推荐

  1. 智力大冲浪(洛谷P1230)

    题目描述 小伟报名参加中央电视台的智力大冲浪节目.本次挑战赛吸引了众多参赛者,主持人为了表彰大家的勇气,先奖励每个参赛者m元.先不要太高兴!因为这些钱还不一定都是你的?!接下来主持人宣布了比赛规则: ...

  2. 解决jsp上传文件,重启tomcat后文件和文件夹自动删除

    吼吼,我遇到的问题是这样的......我写了一个图片上传的方法,上传时,判断没有这个目录就自动建立一个.然后开始上传图片,能成功,能在服务器找到文件夹和相应的文件. 但是,重启项目,或者清理缓存之后, ...

  3. 巨蟒python全栈开发数据库攻略3:行记录的操作&单表查询3

    1.数据行的增删改 2.单表查询 select&where条件 3.group by&having&order by&limit

  4. Powershell数据处理

    1.导出csv文档 Export-Csv D:\ps\xxx.csv -Encoding UTF8 -NoTypeInformation 2.发送mail $from="frommailad ...

  5. 微信支付 统一订单 $order = WxPayApi::unifiedOrder($input); 断点调试

    定位至 CODE /** * 将xml转为array * @param string $xml * @throws WxPayException */ public static function I ...

  6. python生成百分数

    >>> a = float(5.69875) >>> b = float(8.49385) >>> print a/b 0.67092661160 ...

  7. python - 常用的小方法

    常用的小方法: bin() oct() hex() chr() ord() dir() id() len() int() str() type() help() range(10)   /  rang ...

  8. SpringMVC是单例的,高并发情况下,如何保证性能的?

    首先在大家的思考中,肯定有影响的,你想想,单例顾名思义:一个个排队过...  高访问量的时候,你能想象服务器的压力了... 而且用户体验也不怎么好,等待太久~ 实质上这种理解是错误的,Java里有个A ...

  9. Cocos2dx3.1-Android环境搭建初体验

    初玩Cocos2dx,多多包涵. 感觉版本号之间的差异比較大.相对前面的版本号来说.3.X更easy上手.更方便了. 一.安装python.我的python-2.7.3. 配置环境变量 系统变量里:在 ...

  10. kotlin写的几个小例子

    Kotlin-AdapterDemo kotlin语言下BaseAdapter,ArrayAdapter,SimpleAdapter,SimpleCursorAdapter四种适配器的示例 工具and ...