yum 安装nginx-php-mysql二进制

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介:

参考:http://nginx.org/en/linux_packages.html
#1 配置repo源
$ cat /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/6/$basearch/
gpgcheck=0
enabled=1
 
#2 安装
yum install nginx
/etc/init.d/nginx start 

#3 测试
curl 192.168.119.130

#4 nginx配置文件:
mkdir /data/log/svr/nginx -p

vi /etc/nginx/nginx.conf    

user  nginx;
worker_processes  4;
error_log  logs/error.log  notice;
pid        /var/run/nginx.pid;
events {
    use epoll;
    worker_connections  65535;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    server_tokens off;
 
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
 
    access_log  /data/log/svr/nginx/access.log  main;
 
    sendfile        on;
    tcp_nopush     on;
    tcp_nodelay on;
    keepalive_timeout  65;
 
    server_names_hash_bucket_size 128;
    client_header_buffer_size 32k;
    large_client_header_buffers 4 32k;
    client_body_temp_path /tmp;
    client_max_body_size 500m;
 
 
    fastcgi_connect_timeout 600;
    fastcgi_send_timeout 300;
    fastcgi_read_timeout 3600;
    fastcgi_buffer_size 400k;
    fastcgi_buffers 16 1m;
    fastcgi_busy_buffers_size 10m;
    fastcgi_temp_file_write_size 20m;
    fastcgi_intercept_errors on;
 
    gzip  on;
    gzip_min_length  1k;
    gzip_buffers     4 16k;
    gzip_http_version 1.0;
    gzip_comp_level 2;
    gzip_disable        "MSIE [1-6].";
    gzip_types  text/plain application/x-javascript text/css text/javascript application/x-httpd-php image/jpeg image/gif image/png;
    gzip_vary on;

    include conf.d/*.conf;
}
 
3)虚拟主机
配置文件都在这个目录下:
/etc/nginx/conf.d/

$ cat /etc/nginx/conf.d/abc.com.conf    
server {
    listen       127.0.0.1:80;
    server_name  www.abc.com;
    root   /data/website/abc;
    access_log  /data/log/www/abc.access.log  main;
}

$ mkdir /data/log/www  -p 
  > /data/log/www/abc.access.log
  mkdir /data/website/abc -p


 
使用php需要的配置
$ cat /etc/nginx/conf.d/test.com.conf 
server {
    listen       127.0.0.1:80;
    server_name  www.test.com;
    root   /data/website/test;
    charset utf-8;
    access_log  /data/log/www/test.access.log  main;
    location / {
        index  index.php;
     }
    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
 
}
 
$ > /data/log/www/test.access.log
  mkdir /data/website/test -p


###安装php
yum remove php php-bcmath php-cli php-common php-devel php-fpm php-gd php-imap php-ldap php-mbstring php-mcrypt php-mysql php-odbc php-pdo php-pear php-pecl-igbinary php-xml php-xmlrpc
rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
yum install php54w php54w-bcmath php54w-cli php54w-common php54w-devel php54w-fpm php54w-gd php54w-imap php54w-ldap php54w-mbstring php54w-mcrypt php54w-mysql php54w-odbc php54w-pdo php54w-pear php54w-pecl-igbinary php54w-xml php54w-xmlrpc php54w-opcache php54w-intl php54w-pecl-memcache



############################# php nginx mysql 安装

###3 nginx 安装
  http://wiki.nginx.org/Install
  vi /etc/yum.repos.d/CentOS-Base.repo
     [nginx]
     name=nginx repo
     baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
     gpgcheck=0
     enabled=1

  yum install nginx -y
  cd /etc/nginx
  cp nginx.conf nginx.bac
  egrep -v '#|$^' nginx.conf > nginx.conf.r
  mv nginx.conf.r nginx.conf
  /etc/init.d/nginx start
  cat /var/run/nginx.pid
  pgrep -o nginx
  curl -I 192.168.119.130
###4 php(5.4) 安装
  yum remove php php-bcmath php-cli php-common php-devel php-fpm php-gd php-imap php-ldap php-mbstring php-mcrypt php-mysql php-odbc php-pdo php-pear php-pecl-igbinary php-xml php-xmlrpc
  rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
  yum install php54w php54w-bcmath php54w-cli php54w-common php54w-devel php54w-fpm php54w-gd php54w-imap php54w-ldap php54w-mbstring php54w-mcrypt php54w-mysql php54w-odbc php54w-pdo php54w-pear php54w-pecl-igbinary php54w-xml php54w-xmlrpc php54w-opcache php54w-intl php54w-pecl-memcache
  php -v
###5 mysql 安装
    mysql安装为什么大部分使用二进制安装。而不是源码手动去编译?
    mysql使用的glibc进行开发的。glibc库是一个底层api,所以只要是linux,都会有glibc库。
    所以,mysql安装不需要考虑环境是否符合要求。移植性很方便。直接将编译好的二进制代码复制到另外一个机器上,也是可以用的。

    二进制安装
     wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.25-linux-glibc2.5-x86_64.tar.gz
     groupadd mysql
     useradd -g mysql  mysql
    检查并卸载
      rpm -qa|grep mysql
      rpm -e mysql
      rpm -e --nodeps mysql-libs-5.1.73-5.el6_6.x86_64
    解压安装
      tar -zxvf mysql-5.6.25-linux-glibc2.5-x86_64.tar.gz -C /usr/local/
      cd /usr/local/
      ln -s mysql-5.6.25-linux-glibc2.5-x86_64/ mysql
      cd /usr/local/mysql
      chown -R mysql.mysql .
    初始化数据库
      yum install libaio-dev*
      或者
      yum install -y libaio-devel
      mkdir /mysql/mysqldata -p
      cd /usr/local/mysql
      ./scripts/mysql_install_db  --user=mysql --basedir=/usr/local/mysql --datadir=/mysql/mysqldata
      cp support-files/my-default.cnf /etc/my.cnf

      vi /etc/my.conf
      [client]
    socket = /mysql/mysqldata/mysql.sock
      [mysqld]
     basedir = /usr/local/mysql 
     datadir = /mysql/mysqldata
     port = 3306
     server_id = 111
     socket = /mysql/mysqldata/mysql.sock
     sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

    修改环境变量
      vi /etc/profile
      PATH=/usr/local/mysql/bin/:$PATH
      export PATH
      . /etc/profile
      echo $PATH
    启动mysql
        cp support-files/mysql.server /etc/init.d/mysqld
    chmod u+x /etc/init.d/mysqld
    chkconfig --add mysqld
        /etc/init.d/mysqld start

    tail -f /usr/local/mysql/data/mode.err
    mysql -S mysql.sock
    mysqld_safe 
========================= 生成案例优化配置文件

# Example MySQL config file for medium systems.
#
# This is for a system with little memory (32M - 64M) where MySQL plays
# an important part, or systems up to 128M where MySQL is used together with
# other programs (such as a web server)
#
# MySQL programs look for option files in a set of
# locations which depend on the deployment platform.
# You can copy this option file to one of those
# locations. For information about these locations, see:
# http://dev.mysql.com/doc/mysql/en/option-files.html
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.

# The following options will be passed to all MySQL clients
[client]
#password    = your_password
port        = 3306
socket        = /data/mysql/mysql.sock

# Here follows entries for some specific programs

# The MySQL server
[mysqld]
port = 3306
socket = /data/mysql/mysql.sock
user = mysql
character_set_server = utf8
collation_server = utf8_general_ci

pid-file = /data/mysql/3306.pid
datadir = /data/mysql/data
tmpdir = /data/mysql/tmp
max_allowed_packet = 128M

max_connections = 2000
max_connect_errors = 1000

#Query Cache
query_cache_type = 0 
query_cache_size = 256M 
query_cache_limit = 2M 
query_cache_min_res_unit = 2K 

#Common
skip-name-resolve
lower_case_table_names=1
back_log = 512
table_open_cache = 2048
thread_cache_size = 256
thread_concurrency = 16

#Error Log 
log-error=../logs/error.log 
log_warnings = 2 

#Slow Query Log
slow_query_log_file=../logs/slow.log 
long_query_time=1 
slow_query_log=1 

#General Query Log
general_log_file =../logs/general.log #查询日志,通常只有特殊情况才打开。
general_log = 0 #不启用查询日志

#Relay Log
relay_log = ../logs/relay-bin

#binlog
log-bin=../logs/mysql-bin
binlog_cache_size = 2M
max_heap_table_size = 64M
log-bin-trust-function-creators 
binlog-format = statement
#expire_logs_days=7

#Session variables
sort_buffer_size = 2M
join_buffer_size = 2M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
read_rnd_buffer_size = 256k 
thread_stack = 192K
tmp_table_size = 64M
bulk_insert_buffer_size = 16M

#Innodb 
innodb_file_per_table=1
innodb_data_home_dir = /data/mysql/data
innodb_log_group_home_dir = /data/mysql/data
default-storage-engine = innodb
transaction_isolation = REPEATABLE-READ
innodb_additional_mem_pool_size = 64M
innodb_buffer_pool_size = 5G
innodb_data_file_path = ibdata1:1024M:autoextend
innodb_file_io_threads = 16
innodb_thread_concurrency = 16
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 64M
innodb_log_file_size = 300M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 60
innodb_lock_wait_timeout = 50
innodb_thread_concurrency = 16 
innodb_flush_method=O_DIRECT
innodb_stats_on_metadata=0
innodb_change_buffering=inserts 
innodb_adaptive_flushing=1
innodb_io_capacity=3000
innodb_open_files= 2048

#MyISAM 
key_buffer_size = 512M
read_buffer_size = 16M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 128M
myisam_repair_threads = 1
myisam_recover

#Memory variables
max_heap_table_size = 64M

#Replication
server-id = 2043306
relay_log_info_file=relay-log.info
master-info-file=master.info 
relay-log-purge = 1
#skip_slave_start=0
#replicate-do-db = cdned
#replicate-do-db = cdnms
log-slave-updates
relay-log-recovery =1
replicate-ignore-db = mysql
#auto for dual master
auto_increment_offset = 1
auto_increment_increment = 2

#Timeout
connect_timeout=10
delayed_insert_timeout =300
lock_wait_timeout = 120
innodb_rollback_on_timeout=OFF
#net_read_timeout=30 
#net_write_timeout=60 
#slave_net_timeout=30 
#interactive_timeout=2048000 

[mysqldump]
quick
max_allowed_packet = 256M

[mysql]
no-auto-rehash
prompt=[\u@\d \R:\m]>
default-character-set =utf8
# Remove the next comment character if you are not familiar with SQL
#safe-updates

[myisamchk]
key_buffer_size = 128M
sort_buffer_size = 128M
read_buffer = 8M
write_buffer = 8M

[mysqlhotcopy]
interactive-timeout
[mysqld_safe]
open-files-limit = 81920



本文转自cloves 51CTO博客,原文链接:http://blog.51cto.com/yeqing/1649689

相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
15天前
|
Linux C语言
linux yum安装ffmpeg 图文详解
linux yum安装ffmpeg 图文详解
35 0
|
15天前
|
Linux
linux yum 安装rar和unrar
linux yum 安装rar和unrar
50 0
|
16天前
|
关系型数据库 MySQL 数据库
mysql卸载、下载、安装(window版本)
mysql卸载、下载、安装(window版本)
|
5天前
|
关系型数据库 MySQL 数据库
《MySQL 简易速速上手小册》第1章:MySQL 基础和安装(2024 最新版)
《MySQL 简易速速上手小册》第1章:MySQL 基础和安装(2024 最新版)
28 4
|
1天前
|
Linux
centos 6.5安装yum
centos 6.5安装yum
9 0
|
1天前
|
关系型数据库 MySQL Windows
windows安装MySQL5.7教程
windows安装MySQL5.7教程
6 0
|
1天前
|
SQL 存储 关系型数据库
MySQL Cluster集群安装及使用
MySQL Cluster集群安装及使用
|
2天前
|
存储 Linux 网络安全
centos7使用yum网络安装
这些是使用Yum进行网络安装的基本步骤。根据你的需求,你可以重复步骤3和4来安装其他软件包。请注意,执行Yum操作需要root或具有sudo权限的用户。
14 1
|
6天前
|
应用服务中间件 nginx
yum 安装报错 No package nginx available Error:Nothing to do
yum 安装报错 No package nginx available Error:Nothing to do
17 1
|
8天前
|
关系型数据库 MySQL Linux
Linux联网安装MySQL Server
Linux联网安装MySQL Server
20 0