• LNMP环境搭建


    yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers

    一、mysql

    wget http://lnamp-web-server.googlecode.com/files/cmake-2.8.4.tar.gz

    wget http://downloads.skysql.com/archives/mysql-5.5/mysql-5.5.10.tar.gz

    重编译:

    1. make clean 
    2. rm config.cache 

    (1)先安装cmake(mysql5.5以后是通过cmake来编译的)

    [root@ rhel5 local]#tar -zxv -f cmake-2.8.4.tar.gz
    [root@ rhel5 local]#cd cmake-2.8.4
    [root@ rhel5 cmake-2.8.4]#./configure
    [root@ rhel5 cmake-2.8.4]#make
    [root@ rhel5 cmake-2.8.4]#make install


    (2)创建mysql的安装目录及数据库存放目录

     /usr/sbin/groupadd mysql
     /usr/sbin/useradd -g mysql mysql
    [root@ rhel5~]#mkdir -p /home/service/mysql //安装mysql
    [root@ rhel5~]#mkdir -p /home/web/db //存放数据库

      chmod +w /home/service/mysql
      chown -R mysql:mysql /home/service/mysql

    (4)安装mysql

     
    [root@ rhel5 local]#tar -zxv -f mysql-5.5.10.tar.gz
    [root@ rhel5 local]#cd mysql-5.5.10
    [root@ rhel5 mysql-5.5.10]#cmake .
    -DCMAKE_INSTALL_PREFIX=/home/service/mysql -DMYSQL_DATADIR=/home/web/db -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1
    [root@ rhel5 mysql-5.5.10]#make
    [root@ rhel5 mysql-5.5.10]#make install

    rm -R -f /home/web/db
    mkdir -p /home/web/db
    mkdir -p /home/web/db/binlog
    mkdir -p /home/web/db/relaylog
    chown -R mysql:mysql /home/web/db



    /home/service/mysql/scripts/mysql_install_db --basedir=/home/service/mysql --datadir=/home/web/db --user=mysql


    vi /home/web/db/my.cnf
    输入以下内容:
    [client]
    character-set-server = utf8
    port = 3306
    socket = /home/service/mysql/mysql.sock

    [mysqld]
    character-set-server = utf8
    replicate-ignore-db = mysql
    replicate-ignore-db = test
    replicate-ignore-db = information_schema
    user = mysql
    port = 3306
    socket = /home/service/mysql/mysql.sock
    basedir = /home/service/mysql
    datadir = /home/web/db
    log-error = /home/web/db/mysql_error.log
    pid-file = /home/web/db/mysql.pid
    open_files_limit = 10240
    back_log = 600
    max_connections = 5000
    max_connect_errors = 6000
    table_cache = 614
    external-locking = FALSE
    max_allowed_packet = 32M
    sort_buffer_size = 1M
    join_buffer_size = 1M
    thread_cache_size = 300
    #thread_concurrency = 8
    query_cache_size = 512M
    query_cache_limit = 2M
    query_cache_min_res_unit = 2k
    default-storage-engine = MyISAM
    thread_stack = 192K
    transaction_isolation = READ-COMMITTED
    tmp_table_size = 246M
    max_heap_table_size = 246M
    long_query_time = 3
    log-slave-updates
    log-bin = /home/web/db/binlog/binlog
    binlog_cache_size = 4M
    binlog_format = MIXED
    max_binlog_cache_size = 8M
    max_binlog_size = 1G
    relay-log-index = /home/web/db/relaylog/relaylog
    relay-log-info-file = /home/web/db/relaylog/relaylog
    relay-log = /home/web/db/relaylog/relaylog
    expire_logs_days = 30
    key_buffer_size = 256M
    read_buffer_size = 1M
    read_rnd_buffer_size = 16M
    bulk_insert_buffer_size = 64M
    myisam_sort_buffer_size = 128M
    myisam_max_sort_file_size = 10G
    myisam_repair_threads = 1
    myisam_recover

    interactive_timeout = 120
    wait_timeout = 120

    skip-name-resolve
    #master-connect-retry = 10
    slave-skip-errors = 1032,1062,126,1114,1146,1048,1396

    #master-host = 192.168.1.2
    #master-user = username
    #master-password = password
    #master-port = 3306

    server-id = 1

    innodb_additional_mem_pool_size = 16M
    innodb_buffer_pool_size = 512M
    innodb_data_file_path = ibdata1:256M:autoextend
    innodb_file_io_threads = 4
    innodb_thread_concurrency = 8
    innodb_flush_log_at_trx_commit = 2
    innodb_log_buffer_size = 16M
    innodb_log_file_size = 128M
    innodb_log_files_in_group = 3
    innodb_max_dirty_pages_pct = 90
    innodb_lock_wait_timeout = 120
    innodb_file_per_table = 0

    #log-slow-queries = /home/web/db/slow.log
    #long_query_time = 10

    [mysqldump]
    quick
    max_allowed_packet = 32M

    创建管理MySQL数据库的shell脚本:
    vi /home/web/db/mysql-sh
    输入以下内容(这里的用户名xxx和密码xxx接下来的步骤会创建):
    #!/bin/sh
    #chkconfig: 2345 80 90
    #description:auto_run

    mysql_port=3306
    mysql_username="root"
    mysql_password="viewo_admin_z6f2"

    function_start_mysql()
    {
    printf "Starting MySQL... "
    /bin/sh /home/service/mysql/bin/mysqld_safe --defaults-file=/home/web/db/my.cnf 2>&1 > /dev/null &
    }

    function_stop_mysql()
    {
    printf "Stoping MySQL... "
    /home/service/mysql/bin/mysqladmin -u ${mysql_username} -p${mysql_password} -S /home/service/mysql/mysql.sock shutdown
    }

    function_restart_mysql()
    {
    printf "Restarting MySQL... "
    function_stop_mysql
    sleep 5
    function_start_mysql
    }

    function_kill_mysql()
    {
    kill -9 $(ps -ef | grep 'bin/mysqld_safe' | grep ${mysql_port} | awk '{printf $2}')
    kill -9 $(ps -ef | grep 'libexec/mysqld' | grep ${mysql_port} | awk '{printf $2}')
    }

    if [ "$1" = "start" ]; then
    function_start_mysql
    elif [ "$1" = "stop" ]; then
    function_stop_mysql
    elif [ "$1" = "restart" ]; then
    function_restart_mysql
    elif [ "$1" = "kill" ]; then
    function_kill_mysql
    else
    printf "Usage: /home/web/db/mysql {start|stop|restart|kill} "
    fi

    赋予shell脚本可执行权限:
    chmod +x /home/web/db/mysql-sh

    启动MySQL:
    /home/web/db/mysql-sh start

    通过命令行登录管理MySQL服务器(提示输入密码时直接回车):
    /home/service/mysql/bin/mysql -u root -p -S /home/service/mysql/mysql.sock

    输入以下SQL语句,创建一个具有root权限的用户(root)和密码(viewo_admin_z6f2):
    GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'viewo_admin_z6f2';
    GRANT ALL PRIVILEGES ON *.* TO 'root'@'127.0.0.1' IDENTIFIED BY 'viewo_admin_z6f2';

    (可选)停止MySQL:
    /home/web/db/mysql-sh stop

    创建 Mysql 开机启动脚本
    cp /home/web/db/mysql-sh /etc/init.d/mysql
    chmod +x /etc/init.d/mysql

    添加mysql为系统服务(开机自动启动)
    chkconfig --add mysql
    chkconfig mysql on

    启动 Mysql
    service mysql start

    二、php5.5安装

    tar zxvf php-5.5.16.tar.gz

    ./configure --prefix=/home/service/php --with-config-file-path=/home/service/php/etc  --enable-fpm --enable-mbstring --disable-pdo --with-curl --disable-debug  --disable-rpath --enable-inline-optimization --with-bz2  --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-zip --with-pcre-regex --with-mysql --with-mysqli --with-gd --with-jpeg-dir

    make all install

    配置:

    # pass the PHP scripts to FastCGI server listening on 127 . 0 . 0 . 1 : 9000
    #
    server {
    listen 80 ;
    server_name www.abc.com ;
    root /usr/html/abc/ ;
    location / {
    index index.html 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 ;
    }
    }

    三、yum install nginx

  • 相关阅读:
    百度和谷歌,你选择谁?
    数据库的另一种设计方法
    超级IO操作类
    WEB工具类,很强很大
    JS在AJAX中获取鼠标坐标
    弃掉HTML标记的小巧代码
    XML工具操作类,很强大
    FTP 下载功能代码
    db4o开门之篇
    ASP.NET程序中常用代码汇总(转载)
  • 原文地址:https://www.cnblogs.com/killallspree/p/3518692.html
Copyright © 2020-2023  润新知