CentOS6.5下LNMP环境的搭建,centos6.5lnmp搭建
CentOS6.5下LNMP环境的搭建,centos6.5lnmp搭建
#写的不好,大牛勿喷 #其实我很努力 OS:CentOS6.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.精简系统开机启动项: 一般情况下,服务器刚装完系统后有必要保留的开机自启动服务只有5个,具体如下: 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源的安装:[root@LNAP /]# rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm |
[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. |
[root@LNAP /] #yum install nginx -y ........ ....... ....... [root@LNAP /]# service nginx start Starting nginx: [ OK ] [root@LNAP /]# chkconfig nginx on //设置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. |
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; #这些内容根据自己的需求进行更改 } |
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; } } |
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; #} } |
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.
评论暂时关闭