centos6.8下安装部署LNMP(备注:nginx1.8.0+php5.6.10+mysql5.6.12)

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

1)前期准备:为了安装顺利,建议先使用yum安装依赖库
[[email protected] ~]#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
[[email protected] ~]#cd /opt/src
[[email protected] ~]#wget http://nginx.org/download/nginx-1.8.0.tar.gz
[[email protected] ~]#tar -zxvf nginx-1.8.0.tar.gz
[[email protected] ~]#cd nginx-1.8.0
添加www用户,其中-M参数表示不添加用户家目录,-s参数表示指定shell类型
[[email protected] ~]#useradd www -M -s /sbin/nologin
[[email protected] ~]#vim auto/cc/gcc
将这句注释掉取消Debug编译模式 大概在179行
#CFLAGS="$CFLAGS -g"

我们再配置下nginx编译参数
[[email protected] ~]#./configure --prefix=/opt/nginx --user=www --group=www --with-http_stub_status_module --with-http_ssl_module
[[email protected] ~]#make
[[email protected] ~]#make install clean
添加开机自启动
[[email protected] ~]#vim /etc/rc.local
在这个文件里面添加:/opt/nginx/sbin/nginx
[[email protected] ~]#/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
[[email protected] ~]#cd /opt/src/
[[email protected] ~]#wget http://cn2.php.net/distributions/php-5.6.10.tar.gz
[[email protected] ~]#tar -zxvf php-5.6.10.tar.gz
[[email protected] ~]#cd php-5.6.10
我们先配置下PHP的编译参数
[[email protected] ~]#./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
[[email protected] ~]#make
[[email protected] ~]#make install clean
复制php.ini
[[email protected] ~]#cp php.ini-development /opt/php/lib/php.ini
[[email protected] ~]#cd /opt/php/etc/
[[email protected] ~]#cp php-fpm.conf.default php-fpm.conf        //在php-fpm.conf文件中可以定义php的服务端口、进程启动的用户和组权限(最好和nginx服务启动权限一直)等。
使用PHP-FPM管理脚本,在编译包里面已经配置好了,只需要复制到/etc/init.d/中即可
[[email protected] ~]#cd /opt/src/php-5.6.10/sapi/fpm/
[[email protected] ~]#cp init.d.php-fpm /etc/init.d/php-fpm
[[email protected] ~]#chmod +x /etc/init.d/php-fpm
启动php-fpm
[[email protected] ~]#service php-fpm start   or   /etc/init.d/php-fpm restart
加入开机启动策略
[[email protected] ~]#chkconfig --add php-fpm
[[email protected] ~]#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;"

  

原文地址:https://www.cnblogs.com/nulige/p/9318862.html

时间: 2024-10-11 03:12:34

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

编译安装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*4核,内存2G) 系统版本:CentOS-6.5-x86_64-minimal.iso 安装步骤: 0.虚拟系统安装 0.1 使用VMware 虚拟机进行安装,进行安装界面 (分配内存必须大于1G,否则不会显示图型安装界面,网络设置使用“桥接模式” 即"Bridged"模式) 0.2 选择

安装部署LNMP/大并发nginx优化/php性能加速 实战

安装部署LNMP及Nginx优化.PHP加速进行压力测试 部署LNMP环境: 主机 IP 主机名 Centos7.2 192.168.5.128 www.benet.com 部署步骤如下: 使用yum仓库安装Nginx依赖包 yum -y install  gcc gcc-c++ make libtool zlib zlib-devel pcre pcre-devel openssl openssl-devel 创建Nginx用户 组解压Nginx软件包 编译安装Nginx ./configur

Python实现一键安装部署LNMP环境

最近一直在学Python,东西比较多,时间持续的也比较长,为了能够学以致用,想到了原来写过的shell一键安装部署LNMP脚本,既然shell能写,Python也一定能写,就用学到的知识写了下面这个版本,这可能并不是最优版本,等学到更多东西的时候再进行优化升级! 环境介绍: Python 2.6.6 Centos 6.5 nginx 1.10.1 mysql 5.6.34 php 5.3.3 代码如下: #!/bin/env python import os import sys def ent

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#apache22apr-1.5.1.tar.gz 下载地址:http://apache.spd.co.il/apr/apr-util-1.5.3.tar.gz下载地址:http://apache.spd.co.il/apr/ 安装apr-1.5.1.tar.gz 1.Copy root文件夹2. Cd /root

在基于阿里云服务器CentOS6.5下安装Subversion 1.6.5服务

最近阿里云搞了个1元免费提供云服务器的活动,偶心痒痒就申请了一个. 正好可以作为团队的SVN服务器了,下面就来部署SVN服务吧. 一.安装基础环境 apr-1.5.0.tar.gz apr-util-1.5.3.tar.gz pcre-8.35.tar.gz zlib-1.2.8.tar.gz subversion-1.5.6.tar.gz tar -xzvf apr-1.5.0.tar.gz cd apr-1.5.0 ./configure --prefix=/usr/local/apr ma

Linux下安装部署AWStats日志分析系统实例

AWStats是使用Perl语言开发的一款开放性日志分析系统,可分析Apache网站服务器的访问日志,还可以用来分析Samba.Vsftpd.IIS等日志信息.       此文章主要讲解如何在linux系统下安装部署关于对Apache网站服务站日志分析的AWStats. 实验步骤一,安装部署AWStats分析软件. 一,安装AWStats软件包. 直接将其解压到/usr/local/awstats目录下即可完成安装. 使用命令:mkdir -p /usr/local/awstats tar z

centos6.5下安装python3安装、python3虚拟环境创建venv

原因:在安装完centos6.5后,通过命令行键入python时,默认为python2.6.6版本,系统并没有安装python3版本.又想学习python3,因此需要在centos6.5下安装python3版本. <python3安装> 1.下载python3的安装包: (1)如果能够联网,则直接: [[email protected] 3pyex]# wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz 其中,我这里安装的

CentOS6.5下安装配置MySQL

CentOS6.5下安装配置MySQL,配置方法如下: 安装mysql数据库:# yum install -y mysql-server mysql mysql-deve 查看mysql-server版本:# rpm -qi mysql-server 初始化mysql数据库:#service mysqld start 重启mysql数据库:#service mysql restart 设置mysql开机启动:# chkconfig mysqld on 为数据库设置用户名和密码:# mysqlad

CentOS6.5下安装Open vSwitch

准备 # yum install openssl-devel redhat-rpm-config kernel-devel -y #yum install kvm libvirt python-virtinst qemu-kvm virt-viewer 编译 # wget http://openvswitch.org/releases/openvswitch-1.9.3.tar.gz #tar -zxf openvswitch-1.9.3.tar.gz # cd openvswitch-1.9.