因为公司要求用RedHat配,顺便让我练习一下Linux里面的操作什么的。

折腾来折腾去终于搞好了,其实也没那么难嘛。但是也要记录一下。

首先,是在服务器里面用VMware搭建的RedHat6.2 x86系统。在RedHat里面yum里面的源基本是收费的。CentOS呢,是RedHat的衍生版,目的就是打破redhat的收费,所以两者也没啥区别。直接就用CentOS6的yum包来配置了。

首先,在终端里输入:

cd /etc/yum.repos.d/

这里面是放yum源的地方。默认里面会有一个rhel-source.repo后缀的文件,咱们把他删了或者重命名成.bak

然后下一步就是添加centos的源了。新建一个centos.base.repo文件。在里面输入:

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
# [base]
name=CentOS-6 - Base - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos/6/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=os
gpgcheck=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6 #released updates
[updates]
name=CentOS-6 - Updates - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos/6/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=updates
gpgcheck=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6 #additional packages that may be useful
[extras]
name=CentOS-6 - Extras - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos/6/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=extras
gpgcheck=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6 #additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-6 - Plus - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos/6/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=centosplus
gpgcheck=0
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6 #contrib - packages by Centos Users
[contrib]
name=CentOS-6 - Contrib - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos/6/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=contrib
gpgcheck=0
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6

保存之后,我们就有一个centos的源了。执行一下:yum -y update  试一下吧!

下面是安装Nginx了。我们需要执行:

yum -y --enablerepo=remi,remi-test install nginx 

有些朋友可能会遇到:No Nginx package!,这很简单就能解决。

在刚才创建源的yum.repos.d文件夹里面,再创建一个nginx.repo文件。输入以下内容:

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/6/$basearch/
gpgcheck=0
enabled=1

OK,这是单独添加一个Nginx的源。再执行一次上面的安装Nginx的命令就Ok了!

继续,安装php以及php-fpm

yum -y --enablerepo=remi,remi-test install php php-fpm php-common  

安装PHP5.4.4模块扩展,有些会提示No package,这些都是没用的,不要管它!

yum -y --enablerepo=remi,remi-test install php-pecl-apc php-cli php-pear php-pdo php-mysql php-pgsql php-pecl-mongo php-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml  

这样就OK了。运行下面的命令,如果出现错误,说明你上面的步骤出错了。

启动Nginx:
service nginx start
启动php-fpm:
service php-fpm start

下面是配置Nginx使用php-fpm,进入:

/etc/nginx/conf.d/

打开:default.conf 文件。找到:

location / {
root /usr/share/nginx/html; #这一行是网站的根目录,你的网站文件就放在这个里面!
index index.html index.htm; #这一行是添加网站的默认主页的。当然,你也可以添加一个index.php!
}

再找到下面的内容,把它们前面的#去掉:

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

然后把redhat的防火墙文件打开,把80端口添加进白名单:

cd /etc/sysconfig/

打开iptables文件,输入以下内容:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT  

重启防火墙:

service iptables restart 

到此为止,php与Nginx已经搭建好了。我们来试一下。先重启Nginx与php-fpm:

service nginx restart
service php-fpm restart

在你RedHat网页里输入:http://localhost/,成功出现 Welcome to nginx!则Nginx安装成功。

然后进入你网站的根目录:/usr/share/nginx/html

新建一个phpinfo.php文件:

<?php
phpinfo();
?>

然后访问http://localhost/phpinfo.php

看是不是出现php配置的页面了。如果出现就说明php安装成功了。

开始安装mysql!!!!!在终端里输入:

yum -y --enablerepo=remi,remi-test install mysql mysql-server 

启动mysql and 设置自启动:

service mysqld start
chkconfig --levels 235 mysqld on

然后,进入/usr/bin/文件夹,运行mysql_secure_installation文件:

cd /usr/bin/
./mysql_secure_installation

这是配置mysql的安全模式。第一次装mysql最好都配置一下。增加安全性!

执行上面的文件之后,会出现一些配置问题。

1、Enter current password for root (enter for none): (输入当前的root密码) 当前的密码是空,所以直接回车。

2、Set root password? [Y/n] (是否设置密码)输入Y 回车。

3、New password:  (新密码)

4、Re-enter new password:  (再输一次)

5、Remove anonymous users? [Y/n]  (删除匿名账户)

6、Disallow root login remotely? [Y/n] (禁止root用户远程登录)

7、Remove test database and access to it? [Y/n] (删除默认创建的test数据库)

8、Reload privilege tables now? [Y/n] (重载权限表)

安全模式配置完毕!

然后把redhat的防火墙文件打开,把3306端口添加进白名单:

cd /etc/sysconfig/

打开iptables文件,输入以下内容:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT 

重启防火墙:

service iptables restart 

OK!LNMP配置完毕!

RedHat6.2 x86手动配置LNMP环境的更多相关文章

  1. LNMP笔记:阿里云32位 CentOS 5.4 配置 LNMP环境

    最近比较郁闷的是 WordPress大学 服务器故障,由于诸多原因没及时处理,导致10多天无法访问.倡萌也是刚接触服务器环境配置,维护的确力不从心,没办法排查出错误根源,所以只好重置系统盘,重新配置L ...

  2. 手动部署LNMP环境(CentOS 7)

    手动部署LNMP环境(CentOS 7) 一.修改 yum 源 [root@localhost ~]# rpm -Uvh https://dl.fedoraproject.org/pub/epel/e ...

  3. 新手配置LNMP环境教程

    回顾一下这几天自己配置LNMP环境踩得坑,希望帮助更多人 前期准备:VMtool.Linux.Nginx.Mysql.PHP.cmake 版本如下:Centos6.nginx1.6.0.mysql5. ...

  4. c++篇 cad.grx 入门,手动配置编译环境

    安装vs2010+sp1补丁; 安装浩辰2018(64位版本); 下载浩辰Grx开发的SDK,注意对应版本年份., 解压到E盘目录下, E:\grxsdk 在他们的官方用户群下载,搜sdk, 找到gr ...

  5. Hibernate3.3.2 手动配置annotation环境

    简单记录Hibernate3.3.2如何快速配置环境 一.下载hibernate-distribution-3.3.2.GA-dist.zip文件,建立User libraries. 打开window ...

  6. Ubuntu环境下手动配置Java环境

    /×××××××××××××××××××××××××××××××××××××××××/ Author:xxx0624 HomePage:http://www.cnblogs.com/xxx0624/ ...

  7. Linux的学习--配置LNMP环境

    最近,回到公司,发现电脑都换成linux系统了...很无力... 配置环境,跑起项目来就花了一天...额...在这里记录一下-- 系统是ubuntu 12.04. 一.安装nginx1:ubuntu因 ...

  8. CentOS中配置LNMP环境打开提示File not found

    在centos系统中配置好php环境了,但是发现能运行html页面并不能运行php文件了,这样我就在gg的帮助下一步不解决了,下面来看问题的具体解决过程.     安装之后测试发现,怎么Html能运行 ...

  9. centos下配置LNMP环境(源码安装)

    准备工作,安装依赖库 yum -y install gcc automake autoconf libtool make gcc-c++ glibc libxslt-devel libjpeg lib ...

随机推荐

  1. Swift try try! try?使用和区别

    Swift try try! try?使用和区别 一.异常处理try catch的使用 1. swift异常处理 历史由来 Swift1.0版本 Cocoa Touch 的 NSError ,Swif ...

  2. JS理解之闭包

    首先,闭包是什么?这个问题,百度上一大堆,然后我也是,现在学的有点累,来回顾一下吧算是,懂的自动略过,小弟不才,道行入不了你们法眼. 我认为的闭包是,就是取到,不是在自己作用域内或者按照js的规则,娶 ...

  3. [C#学习]0.发表之前想说的

    在这里我将学习C#编程,首先我也只是一个初学者,只是为了以后的学习,并且方便复习,所以决定在这里记录总结一些知识,简单的写一个教程.所以在这里或许难免有一些错误,欢迎大家指出,一起进步. 在这里我使用 ...

  4. vue的Virtual Dom实现- snabbdom解密

    vue在官方文档中提到与react的渲染性能对比中,因为其使用了snabbdom而有更优异的性能. JavaScript 开销直接与求算必要 DOM 操作的机制相关.尽管 Vue 和 React 都使 ...

  5. mysql导入导出sql文件(包括数据库和数据表的操作)

    废话不多说直接开始. 在windows命令行下登录mysql,创建一个test_01数据库,创建一个user表,并插入一条数据,如下 一.导出数据库test_01 1.退出数据库,在命令行中输入 my ...

  6. window系统下sbt的安装

    最近进了一个新公司,用playframework,不用maven,用sbt,然后就来写一下自己的心酸sbt安装进程吧. 第一步: 安装java8,配置好环境变量,这些不用多说吧,之所以是要8版本,是因 ...

  7. 使用Angular 4、Bootstrap 4、TypeScript和ASP.NET Core开发的Apworks框架案例应用:Task List

    最近我为我自己的应用开发框架Apworks设计了一套案例应用程序,并以Apache 2.0开源,开源地址是:https://github.com/daxnet/apworks-examples,目的是 ...

  8. 1014 Uniform Generator

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission( ...

  9. [刷题]Codeforces 746G - New Roads

    Description There are n cities in Berland, each of them has a unique id - an integer from 1 to n, th ...

  10. 【小错误】WPF代码报错:未将对象引用设置到对象的实例。

    今天编写动态创建Image对象的代码时候,报出了下面的错误: 起初还以为我创建的BitmapImage对象出现了问题,设置断点调试了下代码发现BitmapImage里面是有数据的. 我就郁闷了,后来发 ...