在平时运维工作中,经常需要用到LNMP应用框架。
以下对LNMP环境部署记录下:

1)前期准备:为了安装顺利,建议先使用yum安装依赖库
[root@opd ~]#yum install -y make cmake gcc gcc-c++ autoconf automake libpng-devel libjpeg-devel zlib libxml2-devel ncurses-devel bison libtool-ltdl-devel libiconv libmcrypt mhash mcrypt libmcrypt-devel pcre-devel openssl-devel freetype-devel libcurl-devel

2)安装nginx
[root@opd ~]#cd /opt/src
[root@src ~]#wget http://nginx.org/download/nginx-1.8.0.tar.gz
[root@src ~]#tar -zxvf nginx-1.8.0.tar.gz
[root@src ~]#cd nginx-1.8.0
添加www用户,其中-M参数表示不添加用户家目录,-s参数表示指定shell类型
[root@nginx-1.8.0 ~]#useradd www -M -s /sbin/nologin
[root@nginx-1.8.0 ~]#vim auto/cc/gcc
将这句注释掉取消Debug编译模式 大概在179行
#CFLAGS="$CFLAGS -g"

我们再配置下nginx编译参数
[root@nginx-1.8.0 ~]#./configure --prefix=/opt/nginx --user=www --group=www --with-http_stub_status_module --with-http_ssl_module
[root@nginx-1.8.0 ~]#make
[root@nginx-1.8.0 ~]#make install clean
添加开机自启动
[root@nginx-1.8.0 ~]#vim /etc/rc.local
在这个文件里面添加:/opt/nginx/sbin/nginx
[root@nginx-1.8.0 ~]#/opt/nginx/sbin/nginx

----------------------------------顺便说下:Centos7采用yum方式安装nginx-----------------------------------
centos7系统库中默认是没有nginx的rpm包的,所以我们自己需要先更新下rpm依赖库
1)使用yum安装nginx需要包括Nginx的库,安装Nginx的库
# rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

2)使用下面命令安装nginx
# yum install nginx

3)启动Nginx
# service nginx start

# systemctl start nginx.service
---------------------------------------------------------------------------------------------------------

3)安装PHP
由于PHP需要这些类库的支撑
先下载PHP
[root@opd ~]#cd /opt/src/
[root@src ~]#wget http://cn2.php.net/distributions/php-5.6.10.tar.gz
[root@src ~]#tar -zxvf php-5.6.10.tar.gz
[root@src ~]#cd php-5.6.10
我们先配置下PHP的编译参数
[root@php-5.6.10 ~]#./configure --prefix=/opt/php --with-mysql --with-mysqli --with-iconv-dir --with-zlib --with-libxml-dir --enable-xml --with-curl --enable-fpm --enable-mbstring --with-gd --with-openssl --with-mhash --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-libdir=/usr/lib64 --with-jpeg-dir=/usr/lib64 --with-freetype-dir=/usr/lib64 --with-png-dir=/usr/lib64
[root@php-5.6.10 ~]#make
[root@php-5.6.10 ~]#make install clean
复制php.ini
[root@php-5.6.10 ~]#cp php.ini-development /opt/php/lib/php.ini
[root@php-5.6.10 ~]#cd /opt/php/etc/
[root@php-5.6.10 ~]#cp php-fpm.conf.default php-fpm.conf        //在php-fpm.conf文件中可以定义php的服务端口、进程启动的用户和组权限(最好和nginx服务启动权限一直)等。
使用PHP-FPM管理脚本,在编译包里面已经配置好了,只需要复制到/etc/init.d/中即可
[root@php-5.6.10 ~]#cd /opt/src/php-5.6.10/sapi/fpm/
[root@php-5.6.10 ~]#cp init.d.php-fpm /etc/init.d/php-fpm
[root@php-5.6.10 ~]#chmod +x /etc/init.d/php-fpm
启动php-fpm
[root@php-5.6.10 ~]#service php-fpm start   or   /etc/init.d/php-fpm restart
加入开机启动策略
[root@php-5.6.10 ~]#chkconfig --add php-fpm
[root@php-5.6.10 ~]#chkconfig php-fpm on

---------------------------------------------------------------------------------------------------------

安装mysql5.6.36

#!/bin/bash
#卸载系统自带的Mysql
/bin/rpm -e $(/bin/rpm -qa | grep mysql|xargs) --nodeps
/bin/rm -f /etc/my.cnf #安装编译代码需要的包
/usr/bin/yum -y install make gcc-c++ cmake bison-devel ncurses-devel #编译安装mysql5.6
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql -M -s /sbin/nologin cd /usr/local/src
wget -c http://ftp.ntu.edu.tw/MySQL/Downloads/MySQL-5.6/mysql-5.6.36.tar.gz
/bin/tar -zxvf mysql-5.6.36.tar.gz
cd mysql-5.6.36/
/usr/bin/cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql/data -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
make && make install #修改/usr/local/mysql权限
mkdir -p /data/mysql/data
/bin/chown -R mysql:mysql /usr/local/mysql
/bin/chown -R mysql:mysql /data/mysql/data #执行初始化配置脚本,创建系统自带的数据库和表
/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mysql/data --user=mysql #配置my.cnf
cat > /usr/local/mysql/my.cnf << EOF
[client]
port = 3306
socket = /usr/local/mysql/var/mysql.sock [mysqld]
port = 3306
socket = /usr/local/mysql/var/mysql.sock basedir = /usr/local/mysql/
datadir = /data/mysql/data
pid-file = /data/mysql/data/mysql.pid
user = mysql
bind-address = 0.0.0.0
server-id = 1
sync_binlog=1
log_bin = mysql-bin skip-name-resolve
#skip-networking
back_log = 600 max_connections = 3000
max_connect_errors = 3000
##open_files_limit = 65535
table_open_cache = 512
max_allowed_packet = 16M
binlog_cache_size = 16M
max_heap_table_size = 16M
tmp_table_size = 256M read_buffer_size = 1024M
read_rnd_buffer_size = 1024M
sort_buffer_size = 1024M
join_buffer_size = 1024M
key_buffer_size = 8192M thread_cache_size = 8 query_cache_size = 512M
query_cache_limit = 1024M ft_min_word_len = 4 binlog_format = mixed
expire_logs_days = 30 log_error = /data/mysql/data/mysql-error.log
slow_query_log = 1
long_query_time = 1
slow_query_log_file = /data/mysql/data/mysql-slow.log performance_schema = 0
explicit_defaults_for_timestamp ##lower_case_table_names = 1 skip-external-locking default_storage_engine = InnoDB
##default-storage-engine = MyISAM
innodb_file_per_table = 1
innodb_open_files = 500
innodb_buffer_pool_size = 1024M
innodb_write_io_threads = 1000
innodb_read_io_threads = 1000
innodb_thread_concurrency = 8
innodb_purge_threads = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 4M
innodb_log_file_size = 32M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120 bulk_insert_buffer_size = 8M
myisam_sort_buffer_size = 8M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1 interactive_timeout = 28800
wait_timeout = 28800 [mysqldump]
quick
max_allowed_packet = 16M [myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
port = 3306
EOF #启动mysql服务
cd /usr/local/mysql
/bin/mkdir var
/bin/chown -R mysql.mysql var
cp support-files/mysql.server /etc/init.d/mysql
/sbin/chkconfig mysql on
service mysql start #设置环境变量
echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
source /etc/profile #设置mysql登陆密码,初始密码为123456
/bin/mkdir -p /var/lib/mysql
ln -s /usr/local/mysql/var/mysql.sock /var/lib/mysql/mysql.sock
mysql -e "SET PASSWORD = PASSWORD('123456');"
mysql -p123456 -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;"
mysql -p123456 -e "FLUSH PRIVILEGES;"

  

centos6.8下安装部署LNMP(备注:nginx1.8.0+php5.6.10+mysql5.6.12)的更多相关文章

  1. centos6.8下LNMP (nginx1.8.0+php5.6.10+mysql5.6.12) - 部署手册

    在平时运维工作中,经常需要用到LNMP应用框架.以下对LNMP环境部署记录下: 1)前期准备:为了安装顺利,建议先使用yum安装依赖库[root@opd ~]#yum install -y make ...

  2. CentOS6.7安装部署LNMP(nginx1.8.0+php5.6.10+mysql5.6.12)

    IP-10.0.0.8 1.安装nginx mkdir -p /server/tools cd /server/tools yum install -y pcre pcre-devel openssl ...

  3. Linux Centos6.9下安装部署VNC的实操详述

    VNC (Virtual Network Console)是虚拟网络控制台的缩写.它 是一款优秀的远程控制工具软件,由著名的AT&T的欧洲研究实验室开发的.VNC 是在基于 UNIX和 Lin ...

  4. 编译安装LNMP Centos 6.5 x64 + Nginx1.6.0 + PHP5.5.13 + Mysql5.6.19

    (来自:http://www.cnblogs.com/vicowong/archive/2011/12/01/2116212.html) 环境: 系统硬件:vmware vsphere (CPU:2* ...

  5. CentOS6.5下安装JDK1.7+MYSQL5.5+TOMCAT7+nginx1.7.5环境安装文档

    ----------------CentOS6.5下安装JDK1.7+MYSQL5.5+TOMCAT7+nginx1.7.5环境安装文档----------------------- [JDK1.7安 ...

  6. 在ConoHa上Centos7环境下源码安装部署LNMP

    本文记录了从源码,在Centos 7上手动部署LNMP环境的过程,为了方便以后对nginx和mariadb进行升级,这里采用yum的方式进行安装. 1.建立运行网站和数据库的用户和组 groupadd ...

  7. CentOS6.5下安装apache2.2和PHP 5.5.28

    CentOS6.5下安装apache2.2 1. 准备程序 :httpd-2.2.27.tar.gz 下载地址:http://httpd.apache.org/download.cgi#apache2 ...

  8. 最新版CentOS6.5上安装部署ASP.NET MVC4和WebApi

    最新版CentOS6.5上安装部署ASP.NET MVC4和WebApi 使用Jexus5.8.1独立版 http://www.linuxdot.net/ ps:该“独立版”支持64位的CentOS ...

  9. 【转载】CentOS6.5_X64下安装配置MongoDB数据库

    [转载]CentOS6.5_X64下安装配置MongoDB数据库 2014-05-16 10:07:09|  分类: 默认分类|举报|字号 订阅      下载LOFTER客户端 本文转载自zhm&l ...

随机推荐

  1. Ansible 创建用户 Playbook 脚本

    创建用户,设置wheel组sudo不需要密码,然后将用户添加到wheel组,并将用户的公钥传输到节点上: --- - name: Linux Create User and Upload User P ...

  2. LeetCode 4 Median of Two Sorted Array

    There  are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted ...

  3. python 多进程锁Lock和共享内存

    多进程锁 lock = multiprocessing.Lock() 创建一个锁 lock.acquire() 获取锁 lock.release() 释放锁 with lock: 自动获取.释放锁 类 ...

  4. krpano--控制热点跳转到场景的指定视角

    krpano课堂(肥宗) · 2015-07-13 19:32 有这么一种情况,假设我们用三个场景,这三个场景恰好是一条街道的同一方向的三个拍摄点.如上图. 我们可以通过设置A.B.C三个场景中的vi ...

  5. Log4Net的控制台,WinForm,WebApplication使用

    一.Log4Net的控制台,WinForm,WebApplication使用 1.首先使用nuget 添加log4Net 到控制台项目中 log4j每个符号的具体含义:%d %5p %c{1}:%L ...

  6. docker从零开始(四)集群初体验,docker-machine swarm

    介绍 在第三节中,选择了第二节中编写的应用程序,并通过将其转换为服务来定义它应如何在生产中运行,并生成五个应用实例 在本节中,将此应用程序部署到群集上,在多台计算机上运行它.多容器,多机应用程序通过连 ...

  7. 两个sql设计方案的比较

    我有一个买方表Buyer,大概1万条记录:一个卖方表Sale,大概5万条记录.有一些买方和卖方之间是有某种关联的,这种关联关系被记录在Partner表里,Partner表中的关键字段包括BuyerID ...

  8. Nessus home与Nexpose community 对比

    转载请注明来源:http://www.cnblogs.com/phoenix--/p/3345569.html 更新:Nessus home版限制了,总量:16,Nexpose限制了总量为32,全部没 ...

  9. 山东省第六届省赛 BIGZHUGOD and His Friends II(赛瓦定理)

    Description BIGZHUGOD and his three friends are playing a game in a triangle ground. The number of B ...

  10. owasp zap 安全审计工具 功能详解

    一.persist session 该功能主要保存扫描分析的结果,方便下次继续分析 二.扫描策略 1.修改策略 A.入口 B.具体设置页面 C.设置完成后,发起主动扫描,在弹出的窗口可以选择策略 D. ...