在平时运维工作中,经常需要用到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. [Leetcode Week6]Reorder List

    Reorder List 题解 原创文章,拒绝转载 题目来源:https://leetcode.com/problems/reorder-list/description/ Description G ...

  2. 安全测试===Mysql 注入技巧学习 MySQL注入技巧(2)

    原文地址:http://websec.files.wordpress.com/2010/11/sqli2.pdf 0x00.介绍 也可以参考瞌腄龙的mysql注入科普:http://drops.woo ...

  3. V-Hyper安装ubuntu-13.10-server-amd64

    1.在windws8上的V_Hyper虚拟机上安装Ubuntu虚拟机服务器版.遇到的问题和解决方案 2.正确的在V-Hyper配置方法参考文章:在Hyper-V中安装和配置Ubuntu Server ...

  4. 【 Ngnix 】配置路径转发至后端Apache多台虚拟主机

    一.安装apache并开启端口 [root@server ~]# netstat -ntplu | grep httpd tcp /httpd tcp /httpd 二.nginx配置 locatio ...

  5. SpringMVC框架入门配置 IDEA下搭建Maven项目(zz)

    SpringMVC框架入门配置 IDEA下搭建Maven项目 这个不错哦 http://www.cnblogs.com/qixiaoyizhan/p/5819392.html

  6. Scanner类的个人分析

    Scanner类读取键盘输入(java中Scanner类nextLine()和next()的区别和使用方法&&java 中的Scanner(非常详细不看后悔)): 2017/3/18 ...

  7. 以前在win7上死活安装不上的pymssql,现在可以安装了

    作SQL发布时,支持了mssql,在linux上,pymssql安装一直没问题,但在windows7上就不可以. 今天要用了,心血来潮,下载了一个新的pymssql的exe文件, 就安装成功了... ...

  8. fastxml Jackson annotation使用小记

    dependencies: compile("com.fasterxml.jackson.core:jackson-annotations") compile("com. ...

  9. 单调队列练习题(oj p1157 p1158 p1159)

    p1157是很气人的...自从评测机挂了后,速度就特别慢,cin已经过不了了,然而我不知道,就各种**的提交 惨兮兮惨兮兮,这还是开了小号(通过率堪忧.jpg...)... 思路就是单调队列维护,用队 ...

  10. Floyd【p1841】[JSOI2007]重要的城市

    Description 参加jsoi冬令营的同学最近发现,由于南航校内修路截断了原来通向计算中心的路,导致去的路程比原先增加了近一公里.而食堂门前施工虽然也截断了原来通向计算中心的路,却没有使路程增加 ...