#写的不好,大牛勿喷
#其实我很努力
OSCentOS6.5

1.关闭SELinux,关闭防火墙
原因:1.SELinux确实可以提高服务器的安全性,但是对于服务器的性能存在一定的影响,同时它的复杂规则对于管理人员来说非常头疼,所以暂时关掉吧,非要开启也是可以的;
     2.关闭防火墙是为了让初学者学习更加方便,对防火墙技术好的人可以开启防火墙。在企业环境中,只有配置了外网IP的服务器再会开启防火墙,但是即使是外网IP,一般情况下也不轻易的开启防火墙,高并发、高流量的业务服务器仍然不能开启防火墙,防火墙对性能存在一定的损耗,集群环境下的服务器防火墙一般都是关闭的,安全性可以借助硬件防火墙等设备进行提高,而且,现在机房的网络整体架构都依托于物理防火墙。
2.安装完成系统后进行软件升级
#service iptables stop
#chkconfig iptables off
#sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/’/etc/selinux/config
此步骤是快速修改的方法,也可以通过vi进行修改,SELINUX修改完成后我们需要重启服务器,但是我们暂时不重启服务器,对服务器软件进行升级完成和启动项做了优化后再重启服务器;
#yum update -y   //更新软件包,这个选项根据个人喜好吧
2.精简系统开机启动项:
个,具体如下:
1.sshd :远程连接ssh,不多说;
2.rsyslog:日志相关文件,这是操作系统提供的一种机制
3.network:服务器要联网,必须开启这个服务啊
4.crond:这个服务主要用来执行系统及用户配置的任务计划,有周期性执行的任务的时候必须开启,生产环境下必须开启这个服务
5.sysstat:服务器性能检测工具,收集服务器运行数据,判断运行是否正常
操作命令如下:
[root@localhost ~]# LANG=en
[root@localhost ~]# for root in `chkconfig --list|grep 3:on|awk '{print $1}'`;do chkconfig --level 3 $root off;done
[root@localhost ~]# for root in crond network rsyslog sshd sysstat;do chkconfig --level 3 $root on;done  //sysstat服务在服务器中很可能没有,如果系统提示,我们只需把这个服务在这条命令中去掉就可以了
[root@localhost ~]# chkconfig --list|grep 3:on
crond              0:off    1:off    2:on    3:on    4:on    5:on    6:off
network            0:off    1:off    2:on    3:on    4:on    5:on    6:off
rsyslog            0:off    1:off    2:on    3:on    4:on    5:on    6:off
sshd               0:off    1:off    2:on    3:on    4:on    5:on    6:off
sysstat            0:off    1:on     2:on    3:on    4:on    5:on    6:off

接下来我们重启服务器就可以了,重启的过程中,你会发现速度非常快;

安装配置

.Nginx的安装部署
由于CentOS6.5默认是没有Nginx源的,我们需要手动安装nginx的yum源
1. 先执行下条命令进行nginx源的安装:
2. 查看 yum nginx 信息
[root@LNAP /]# yum info nginx
已加载插件:fastestmirror
Determining fastest mirrors
 * base: mirrors.yun-idc.com
 * extras: mirrors.neusoft.edu.cn
 * updates: mirrors.neusoft.edu.cn
base                     | 3.7 kB     00:00    
extras                   | 3.4 kB     00:00    
extras/primary_db      |  37 kB     00:00    
nginx                    | 2.9 kB     00:00    
nginx/primary_db        |  22 kB     00:00    
updates                  | 3.4 kB     00:00    
updates/primary_db       | 4.3 MB     00:05    

可安装的软件包
Name        : nginx
Arch        : x86_64
Version     : 1.10.3
Release     : 1.el6.ngx
Size        : 861 k
Repo        : nginx
Summary     : High performance web server
URL         : http://nginx.org/
License     : 2-clause BSD-like license
Description : nginx [engine x] is an HTTP and reverse proxy server, as well as

            : a mail proxy server.
3,安装并启动nignx
[root@LNAP /] #yum install nginx -y

........
.......
.......
[root@LNAP /]# service nginx start
Starting nginx:                                            [  OK  ]
[root@LNAP /]# chkconfig nginx on     //设置nginx开机自启动
,然后进入浏览器,根据你的Linux服务器的IP输入 http://x.x.x.x 测试,如果看到一下内容,就说明Nginx已经安装成功了
Welcome to nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.
Thank you for using nginx.
如果不能连接到nginx,原因很多,但是可以先检查 
  1,nginx服务是否真的起来了
  2,linux服务器防火墙是否打开
.Nginx配置SSL支持的HTTPS
默认情况下ssl模块并未被安装,如果要使用该模块则需要在编译时指定–with-http_ssl_module参数,安装模块依赖于OpenSSL库和一些引用文件,通常这些文件并不在同一个软件包中。通常这个文件名类似libssl-dev。
安装opennssl
[root@LNAP /]# yum install openssl -y
生成证书
可以通过以下步骤生成一个简单的证书:
首先,进入你想创建证书和私钥的目录,
[root@LNAP /]# cd /etc/nginx/
创建服务器私钥,命令会让你输入一个口令:
[root@LNAP /]# openssl genrsa -des3 -out nginx.key 2048
创建签名请求的证书(CSR):
[root@LNAP /]# openssl req -new -key nginx.key -out nginx.csr
在加载SSL支持的Nginx并使用上述私钥时除去必须的口令:
[root@LNAP /] # cp nginx.key nginx.key.org
[root@LNAP /] # openssl rsa -in nginx.key.org -out nginx.key
最后标记证书使用上述私钥和CSR:
[root@LNAP /] # openssl x509 -req -days 365 -in nginx.csr -signkey nginx.key -out nginx.crt
配置nginx
修改Nginx下你的www某一个网站的配置文件,让其包含新标记的证书和私钥:
#vim /etc/nginx/conf.d/default.conf  //例如这个默认的
server {

     listen       443;
     server_name  localhost;
      ssl on;
      ssl_certificate       server.crt;
      ssl_certificate_key   server.key;
#     ssl_protocols SSLv3 SSLv2 TLSv1 TLSv1.1 TLSv1.2;
#     ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
#     ssl_prefer_server_ciphers on;
#这些内容根据自己的需求进行更改
 }
我们可以复制这个默认的配置文件到conf.d目录下面,因为在nginx的nginx.conf中有这么一项
 include /etc/nginx/conf.d/*.conf;  这样才显得规整一点,容易控制调节,不建议在nginx.conf文件中直接进行修改。
也就是说,只要这个配置文件下所有的虚拟主机端口IP不冲突,所有运行的网站都是可访问的;所以默认的哪的default.conf仅仅是其中一个,nginx给我们提供的一个模板,我们可以对它进行复制成自己想要的另外一个修改,用来使用。
重启nginx。
这样就可以通过以下方式访问:https://192.168.34.5
 
有时候我们还有这种需求,为了防止用户去访问80不安全的网页,我们在nginx中可以配置端口重定向,在用户访问http://192.168.34.8的时候服务器自动跳转到
https://192.168.34.8,如果我们还是存在php访问支持,则按照下面的方法进行设置
server {
        listen       80;
        server_name  www.cloud.com;
       rewrite ^(.*)$ https://$host$1 permanent;
 
        location / {
            root   /data/html/phpwind/;
            index  index.html index.htm index.php;
          }
       location ~ \.php$ {
         root           /data/html/phpwind/;
         fastcgi_pass   127.0.0.1:9000;
         fastcgi_index  index.php;
         fastcgi_param  SCRIPT_FILENAME  /data/html/phpwind/$fastcgi_script_name;
         include        fastcgi_params;
          }
}
 
.安装PHP环境,并配置Nginx,支持PHP环境
如果yum安装不存在问题,可以利用yum进行安装,本人曾经安装的时候遇到过问题:
1.如果yum install php* -y这条命令没有问题,直接进行安装就可以,如果不行,依次执行下面的命令:
#yum install php -y
#yum install php-fpm -y
让php开机自启动的命令不是chkconfig php on,而是chkconfig php-fpm on;在这里,我们将php-fpm设置未开机自启动;
配置php-ngin环境:
#vim /etc/nginx/conf.d/default.conf
server {
-----------省略部分内容-----------
location ~ \.php$ {
  root           html;
  fastcgi_pass   127.0.0.1:9000;
  fastcgi_index  index.php;
  fastcgi_param  SCRIPT_FILENAME /data/html/phpwind/$document_root$fastcgi_script_name;
  include        fastcgi_params;
  }
-----------省略部分内容-----------
}
这里这个SCRIPT_FILENAM其实就是index.php所在的目录,因为nginx的所有网页文件都存放于/usr/share/nginx/html/目录下,在这个目录下可以存放多个网站的网页文件,但都是以目录的形式存放的,比如在这个目录下存放了一个www目录,且www目录下面有index.php,这里的SCRIPT_FILENAME就写成
fastcgi_param  /user/share/nginx/html/www/$document_root$fastcgi_script_name;
如果把网页文件放在了别的目录,如/data/nginx/html/www/,则改成
fastcgi_param  /data/nginx/html/www/$document_root$fastcgi_script_name;
所有的文件路径建议使用绝对路径
 
所以,一份正常的www.conf配置文件应该是这样的:
 
server {
    listen       443;
    server_name  www.tcloud.com;
    #charset koi8-r;
    #access_log  /var/log/nginx/log/host.access.log  main;
    ######SSL#############
    ssl on;
    ssl_certificate       /etc/nginx/cert/discuz.crt;
    ssl_certificate_key   /etc/nginx/cert/discuz.key;
    ssl_protocols SSLv3 SSLv2 TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
    ssl_prefer_server_ciphers on;     
    ########SSL模块##########
    location / {
        root   /data/html/phpwind/;
        index  index.html index.htm index.php;
    }
     error_page  404              /404.html;
    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #location ~ \.php$ {
    # proxy_pass   http://127.0.0.1;
    #}
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
   ##########PHP模块###########  
   location ~ \.php$ {
         root           /data/html/phpwind/;
         fastcgi_pass   127.0.0.1:9000;
         fastcgi_index  index.php;
         fastcgi_param  SCRIPT_FILENAME  /data/html/phpwind/$fastcgi_script_name;
         include        fastcgi_params;
    }
    ##########PHP#############
    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #location ~ /\.ht {
    #    deny  all;
    #}
}
 
.安装MySQL数据库:
#yum install mysql* -y
直接安装就可以了,
修改mysql 默认密码:
: 用SET PASSWORD命令
  mysql -u root
  mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpasswd');
:用mysqladmin
  mysqladmin -u root password "newpasswd"
  如果root已经设置过密码,采用如下方法
  mysqladmin -u root password oldpass "newpasswd"
: 用UPDATE直接编辑user表
  mysql -u root
  mysql> use mysql;
  mysql> UPDATE user SET Password = PASSWORD('newpasswd') WHERE user = 'root';
  mysql> FLUSH PRIVILEGES;
在丢失root密码的时候,可以这样
  mysqld_safe --skip-grant-tables&
  mysql -u root mysql
  mysql> UPDATE user SET password=PASSWORD("newpasswd") WHERE user='root';
  mysql> FLUSH PRIVILEGES;
登陆Mysql数据库:
mysql -u username -p
输入密码即可登录
mysql -u root -p
[root@LNAP ~]# mysql -u root -p
Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

CentOS6.5下LNMP环境的搭建的更多相关文章

  1. Linux:LNMP环境的搭建

    LNMP环境的搭建 安装DNS服务器 安装DNS服务 yum install bind -y DNS的配置 创建正向解析 以创建一个名为"lsy.com"的正向查找区域为例: 第一 ...

  2. lnmp环境快速搭建及原理解析

    刚开始学习php的时候是在wamp环境下开发的,后来才接触到 lnmp 环境当时安装lnmp是按照一大长篇文档一步步的编译安装,当时是真不知道是在做什么啊!脑袋一片空白~~,只知道按照那么长的一篇文档 ...

  3. Mac下PHP环境的搭建

    Mac下PHP环境的搭建 目录 Mac下PHP环境的搭建(基于XAMPP) phpmyadmin Mac下PHP环境的搭建(基于XAMPP) 下载XAMPP的Mac版 启动Apache Web Ser ...

  4. myEclipse 8.5下SVN环境的搭建

    myEclipse 8.5下SVN环境的搭建 在应用myEclips 8.5做项目时,svn会成为团队项目的一个非常好的工具,苦苦在网上寻求了一下午,终于整合好了这个环境,在这里简单介绍下,希望能为刚 ...

  5. 记一次Linux下JavaWeb环境的搭建

    今天重装了腾讯云VPS的系统,那么几乎所有运行环境都要重新部署了.过程不难懂,但是也比较繁琐,这次就写下来,方便他人也方便自己日后参考参考. 我采用的是JDK+Tomcat的形式来进行JavaWeb初 ...

  6. CentOS6.8下MySQL MHA架构搭建笔记

    转载请注明出处,本文地址:http://www.cnblogs.com/ajiangg/p/6552855.html 以下是CentOS6.8下MySQL MHA架构搭建笔记 IP资源规划: 192. ...

  7. Ubuntu下hadoop环境的搭建(伪分布模式)

    Ubuntu下hadoop环境的搭建(伪分布模式) 一.必要资源的下载 1.Java jdk(jdk-8u25-linux-x64.tar.gz)的下载 具体链接为: http://www.oracl ...

  8. Windows下UEFI环境的搭建

    Windows下UEFI环境的搭建 一.环境准备 1. 安装2012及以上VS https://visualstudio.microsoft.com/ 2.下载NASM 2.13.03  http:/ ...

  9. Ubuntu系统下lnmp环境搭建和Nginx多站点配置

    最近需要使用Ubuntu作为服务器搭建Lnmp环境,顺便将操作过程写下来,与大家分享.如有不足之处,欢迎大家提出不同意见.(本文默认读者已经熟悉相关linux命令的使用,比如创建文件和文件夹,编辑文件 ...

随机推荐

  1. EXT中导出表格中的数据到Excel

    { itemId: 'excel', text: '导出', iconCls: 'btnExportExcel', disabled: false, handler: function () { // ...

  2. 浅谈JavaScript和DOM中的类数组对象

    JavaScript是一门弱类型语言,它的数据类型分为两大类:简单数据类型(5种:Undefined.Null.Boolean.Number.String)和复杂数据类型(1种:Object).Obj ...

  3. 使用 Git 同步时出现ssl错误

    错误提示 fatal: unable to access 'https://android.googlesource.com/platform/prebuilts/qemu-kernel/': gnu ...

  4. F数圈圈

    Description 幼儿园的小朋友对数字其实不是很感兴趣,他们更感兴趣的是形状,现在给你一个数字,小朋友都会数出其中一共有多少圆圈圈 Input 一个数字n长度不超过19位 Output 输出其中 ...

  5. MQ选型对比文档

    几种MQ产品说明:     ZeroMQ :  扩展性好,开发比较灵活,采用C语言实现,实际上他只是一个socket库的重新封装,如果我们做为消息队列使用,需要开发大量的代码    RabbitMQ  ...

  6. Modelsimse10.1如何编译altera库文件以支持IP仿真

    前言 se版本默认没有ip之类的库支持,如果你用到了pll之类的ip,仿真前就得把库编译好. 流程 本例用的是altera的verilog库. 1.首先在modelsim安装目录下新建altera文件 ...

  7. python进阶(8):常用模块2+异常处理

    前段时间讲了很多的模块应为当时面向对象没有讲有几个没有说今天补上,再说一个异常处理. 一.hashlib模块 Python的hashlib提供了常见的摘要算法,如MD5,SHA1等等. 摘要算法又称哈 ...

  8. shell编程之数组

    bash 编程只支持一维数组,不支持多维,类似c语言,数组下标从0开始,下标可以是整数,也可以是表达式 数组的定义 在shell中用括号来表示数组,中间用空格来隔开 主要有两种种定义形式: arr=( ...

  9. Angular企业级开发(10)-Smart Table插件开发

    1.Smart Table内置的分页功能 Smart Table是基于AngularJS模块特性开发出来的一款优秀的表格组件,默认就支持过滤.排序等核心功能.开发者基于它也可以开发插件,满足个性化需求 ...

  10. CSS float 属性

    Float定义: float 属性定义元素在哪个方向浮动.以往这个属性总应用于图像,使文本围绕在图像周围,不过在 CSS 中,任何元素都可以浮动. 浮动元素会生成一个块级框,而不论它本身是何种元素.如 ...