• LNMP架构基础搭建


    LNMP架构+wordpress博客

    环境:

    • centos6.7 2.6.32-573.el6.x86_64
    • nginx-1.6.3
    • mysql-5.5.49
    • php-5.3.27
    • wordpress-4.9.4

    Linux环境:

    [root@web01 ~]# cat /etc/redhat-release

    CentOS release 6.7 (Final)

    [root@web01 ~]# uname -m

    x86_64

    [root@web01 ~]# uname -r

    2.6.32-573.el6.x86_64

    [root@web01 ~]#

    安装Nginx:

    yum install pcre pcre-devel openssl openssl-devel -y

    mkdir -p /home/oldboy/tools

    cd /home/oldboy/tools

    wget -q http://nginx.org/download/nginx-1.6.3.tar.gz

    useradd nginx -s /sbin/nologin -M

    tar xf nginx-1.6.3.tar.gz

    cd nginx-1.6.3

    ./configure --user=nginx --group=nginx --prefix=/application/nginx-1.6.3 --with-http_stub_status_module --with-http_ssl_module

    make

    make install

    ln -s /application/nginx-1.6.3 /application/nginx

    cd ../

    /application/nginx/sbin/nginx

    lsof -i:80

    安装MySQL:

    cd /home/oldboy/tools/

    rz

    mysql-5.5.49-linux2.6-x86_64.tar.gz

    useradd -s /sbin/nologin mysql -M

    tar -xf mysql-5.5.49-linux2.6-x86_64.tar.gz

    mv mysql-5.5.49-linux2.6-x86_64 /application/mysql-5.5.49

    ln -s /application/mysql-5.5.49/ /application/mysql

    cd /application/mysql

    /bin/cp support-files/my-small.cnf /etc/my.cnf

    chown -R mysql.mysql /application/mysql/

    /application/mysql/scripts/mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data/ --user=mysql

    cp support-files/mysql.server /etc/init.d/mysqld

    chmod +x /etc/init.d/mysqld 

    sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe /etc/init.d/mysqld 

    /etc/init.d/mysqld start

    echo 'export PATH=/application/mysql/bin:$PATH' >>/etc/profile

    source /etc/profile

    mysqladmin -u root password '123456'

    lsof -i:3306

    安装PHP:

    cd /home/oldboy/tools

    rz

    libtool-ltdl-devel-2.2.6-15.5.el6.x86_64.rpm

    rpm -ivh libtool-ltdl-devel-2.2.6-15.5.el6.x86_64.rpm

    yum install -y zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel

    wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz

    tar -xf libiconv-1.14.tar.gz

    cd libiconv-1.14

    ./configure --prefix=/usr/local/libiconv

    make

    make install

    cd ../

    rpm -ivh http://mirrors.sohu.com/fedora-epel/6/i386/epel-release-6-8.noarch.rpm

    yum update

    yum install libmcrypt-devel mhash mcrypt -y

    rz

    php-5.3.27.tar.gz

    tar -xf php-5.3.27.tar.gz

    cd php-5.3.27/

    ./configure

    --prefix=/application/php5.3.27

    --with-mysql=/application/mysql

    --with-iconv-dir=/usr/local/libiconv

    --with-freetype-dir

    --with-jpeg-dir

    --with-zlib

    --with-libxml-dir=/usr

    --enable-xml

    --enable-rpath

    --enable-safe-mode

    --enable-bcmath

    --enable-shmop

    --enable-sysvsem

    --enable-inline-optimization

    --with-curl

    --with-curlwrappers

    --enable-mbregex

    --enable-fpm

    --enable-mbstring

    --with-mcrypt

    --with-gd

    --enable-gd-native-ttf

    --with-openssl

    --with-mhash

    --enable-pcntl

    --enable-sockets

    --with-xmlrpc

    --enable-zip

    --enable-soap

    --enable-short-tags

    --enable-zend-multibyte

    --enable-static

    --with-xsl

    --with-fpm-user=nginx

    --with-fpm-group=nginx

    --enable-ftp

    ln -s /application/mysql/lib/libmysqlclient.so.18 /usr/lib64/

    touch ext/phar/phar.phar

    make

    make install

    ln -s /application/php5.3.27/ /application/php

    cp php.ini-production /application/php/lib/php.ini

    cd /application/php/etc/

    cp php-fpm.conf.default php-fpm.conf

    /application/php/sbin/php-fpm

    lsof -i:9000

    上传wordpress:

    mkdir /application/nginx/html/blog/ -p

    cd /application/nginx/html/blog/

    rz

    wordpress-4.9.4.zip

    unzip wordpress-4.9.4.zip

    mv wordpress/* ./

    rm -rf wordpress

    chown -R nginx.nginx /application/nginx/html/blog/

    编辑nginx配置文件,使用网站上线

    grep -vE "#|^$" ./conf/nginx.conf.default >./conf/nginx.conf

    [root@web01 nginx]# vim ./conf/nginx.conf

    worker_processes  1;

    events {

        worker_connections  1024;

    }

    http {

        include       mime.types;

        default_type  application/octet-stream;

        sendfile        on;

        keepalive_timeout  65;

        incule extra/blog.conf;

    }

    [root@web01 nginx]# mkdir ./conf/extra

    [root@web01 nginx]# vim ./conf/extra/blog.conf

    [root@web01 conf]#

    [root@web01 conf]# cat /application/nginx/conf/extra/blog.conf

        server {

            listen      80;

            server_name  blog.etiantian.org;

            root    html/blog;

            index  index.php index.html index.htm;

            location / {

                if (-f $request_filename/index.html){

                  rewrite (.*) $1/index.html break;

                }

                if (-f $request_filename/index.php){

                  rewrite (.*) $1/index.php;

                }           

                if (!-f $request_filename){

                  rewrite (.*) /index.php;

                } 

            }

            location ~ .*.(php|php5)?$ {

                fastcgi_pass 127.0.0.1:9000;

                fastcgi_index index.php;

                include fastcgi.conf;

            }

    }

    [root@web01 conf]#

    使PHP程序连接数据库

    cp /application/nginx/html/blog/wp-config-sample.php /application/nginx/html/blog/wp-config.php

    [root@web01 conf]# vim /application/nginx/html/blog/wp-config.php

    <?php

    ……

    define('DB_NAME', 'wordpress');

    /** MySQL database username */

    define('DB_USER', 'wordpress');

    /** MySQL database password */

    define('DB_PASSWORD', '123456');

    /** MySQL hostname */

    define('DB_HOST', 'localhost');

    /** Database Charset to use in creating database tables. */

    define('DB_CHARSET', 'utf8');

    /** The Database Collate type. Don't change this if in doubt. */

    define('DB_COLLATE', '');

    ……

    创建数据库

    mysql -uroot -p123456

    mysql>create database wordpress;

    mysql>grant all on wordpress.* to wordpress@'localhost' identified by '123456';

    mysql>flush privileges;

    mysql> quit

    重启nginx使WEB服务生效

    /application/nginx/sbin/nginx -t

    /application/nginx/sbin/nginx -s reload

    测试:

    浏览器输入:http://blog.etiantian.org/wp-admin/install.php

  • 相关阅读:
    Eclipse无法导入一些相关类的方法,出现Multiple markers at this line
    查看共享命令
    eclipse历史版本的下载地址
    MyEclipse的快捷键
    Hibernate的隔离级别
    eclipse插件下载地址
    UML类图几种关系的总结
    Oracle正则表达式函数:regexp_like、regexp_substr、regexp_instr、regexp_replace
    回滚段的学习
    Oracle 字符集的查看和修改
  • 原文地址:https://www.cnblogs.com/tcheng/p/8495576.html
Copyright © 2020-2023  润新知