Lamp+nginx Acting +discuz+wordpress+phpmyadmin

Source: Internet
Author: User
Lamp+nginx Agent +discuz+wordpress+phpmyadmin

Experimental project: Build lamp, install Nginx, as an agent, the MySQL installed in a separate machine, Apache responsible for dynamic, Nginx responsible for static

Lab Environment:

1. VMware Workstation 11

2, Equipment A:mysql,ip address: 192.168.0.102,host:mysql

3, the device B:NGINX+APACHE+PHP,IP address: 192.168.0.107,HOST:LANP Real machine: 192.168.0.104

4, Linux distribution: Centos 6.6 x86;

5, nginx:http://nginx.org/download/nginx-1.6.2.tar.gz

6, Apache:get http://mirrors.sohu.com/apache/httpd-2.4.16.tar.gz

7, php:http://cn2.php.net/get/php-5.6.12.tar.gz

8, mysql:http://mirrors.sohu.com/mysql/mysql-5.5/mysql-5.5.42-linux2.6-i686.tar.gz

9, Discuz:http://download.comsenz.com/discuzx/3.2/discuz_x3.2_sc_utf8.zip

10, wordpress:https://cn.wordpress.org/wordpress-4.2.2-zh_cn.tar.gz

11, Phpmyadmin:https://files.phpmyadmin.net/phpmyadmin/4.4.13.1/phpmyadmin-4.4.13.1-all-languages.zip

12, Pcre http://sourceforge.net/projects/pcre/files/pcre2/10.20/pcre2-10.20.tar.gz

13. Apr http://mirror.bit.edu.cn/apache//apr/apr-1.5.2.tar.gz

14, Apr-util http://mirror.bit.edu.cn/apache//apr/apr-util-1.5.4.tar.gz

15, Epel-release http://mirrors.ustc.edu.cn/epel/6Server/x86_64/epel-release-6-8.noarch.rpm

16, Libmcrypt

Experiment Preparation:

1. Replace 163 download Source

Mv/etc/yum.repos.d/centos-base.repo/etc/yum.repos.d/centos-base.repo.old

cd/etc/yum.repos.d/

wget Http://mirrors.163.com/.help/CentOS6-Base-163.repo

MV Centos6-base-163.repo Centos-base.repo

Yum Clean All

Yum Makecache (Note replace Centos-base.repo $Realease: 1, $s/$Realease/6.6/g)

Yum-y Update

2, respectively in the equipment A and b download each software;

3, update the system time;

CRONTAB-E */30 * * * * ntpdate 210.72.145.44 >/dev/null 2>&1

4. Clear iptables, turn off SELinux, or add access to databases and websites.

-A input-p tcp-m state--state new-m TCP--dport 80-j ACCEPT

-A input-m state--state new-m tcp-p TCP--dport 88-j ACCEPT # #

-A input-m state--state new-m tcp-p TCP--dport 3306-j ACCEPT

5. Installing dependent Packages

Yum-y install NTP make OpenSSL openssl-devel pcre pcre-devel libpng libpng-devel libtiff-devel libjpeg-6b libjpeg-devel-6 b freetype freetype-devel gd gd-devel fontconfig-devel zlib zlib-devel libevent-devel gcc gcc-c++ Flex Bison bzip2 bzip2-d Evel libxpm libxpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2 libxml2-devel imake autoconf automake SCR Een sysstat compat-libstdc++-33 Curl curl-devel

Experimental steps:

Equipment A:mysql

Tar zxvf/usr/local/src/mysql-5.5.42-linux2.6-i686.tar.gz
MV Mysql-5.5.42-linux2.6-i686/usr/local/mysql
Useradd-s/sbin/nologin MySQL
Cd/usr/local/mysql
Mkdir-p/data/mysql
Chown-r Mysql:mysql/data/mysql
./scripts/mysql_install_db--user=mysql--datadir=/data/mysql
CP SUPPORT-FILES/MY-LARGE.CNF/ETC/MY.CNF
CP Support-files/mysql.server/etc/init.d/mysqld
chmod 755/etc/init.d/mysqld
Vim/etc/init.d/mysqld #修改datadir =/usr/local/mysql
Chkconfig--add mysqld
Chkconfig mysqld on
Service mysqld Start

Mysql-uroot-p <输入你的mysql登录密码>

Create Database Discuz;

Create DATABASE WordPress;

Grant all on discuz.* to ' youruser ' @ ' lyourhostip ' identified by ' YourPassword ';
Grant all on WordPress. * to ' youruser ' @ ' lyourhostip ' identified by ' YourPassword ';

Quit

Equipment B:LANP

First, install Apache

Tar zxvf/usr/local/src/httpd-2.4.16.tar.gz

Tar zxvf/usr/local/src/apr-1.5.2.tar.gz

Tar zxvf/usr/local/src/apr-util-1.5.4.tar.gz

Mv/usr/loca/src/apr-1.5.2/usr/loca/src/httpd-2.4.16/srclib/apr

Mv/usr/local/src/apr-util-1.5.4/usr/loca/src/httpd-2.4.16/srclib/apr-util

cd/usr/loca/src/httpd-2.4.16

./configure \--prefix=/usr/local/apache2 \--with-included-apr \--enable-so \--enable-deflate=shared \-- Enable-expires=shared \--enable-rewrite=shared

Make && make install

Cp/usr/local/apache2/bin/apachectl/etc/init.d/httpd

Vim/etc/init.d/httpd
Add two lines of text to the first line #!/bin/sh
# chkconfig:35 70 30
# Description:apache
Save exit
Chkconfig--level httpd on

Second, install PHP

Tar zxf/usr/local/src/php-5.6.12.tar.gz
CD php-5.6.12
./configure \--prefix=/usr/local/php \--with-apxs2=/usr/local/apache2/bin/apxs \--with-config-file-path=/usr/ LOCAL/PHP/ETC \--with-mysql=mysqlnd \--with-mysqli=mysqlnd \--with-pdo-mysql=mysqlnd \--with-libxml-dir \--with-gd \ --with-jpeg-dir \--with-png-dir \--with-freetype-dir \--with-iconv-dir \--with-zlib-dir \--with-bz2 \--with-openssl \ --with-mcrypt \--enable-soap \--enable-gd-native-ttf \--enable-mbstring \--enable-sockets \--enable-exif \-- Disable-ipv6

# #使用了php自带的对mysql的驱动程序mysqlnd

Make && make install

Cp/usr/local/src/php-5.6.12/php.ini-production/usr/local/php/etc/php.ini

Third, configure PHP and Apache combination

Vim/usr/local/apache2/conf/httpd.conf found: AddType application/x-gzip. gz. tgz
Add below the line: AddType application/x-httpd-php. php
Found it:

DirectoryIndex index.html

Change the line to read:

DirectoryIndex index.html index.htm index.php

Found: #ServerName www.example.com:80 modified to: ServerName localhost:88

Found: listen:80 modified to: listen:88

Add granted allow from all

allowoverride None

Require all granted

Allow from all

See if modules/libphp5.so exists

Modify Vim/usr/local/apache2/conf/extra/httpd-vhosts.conf

DocumentRoot "/date/discuz/"

ServerName bbs.chinaops.com

Errorlog "Logs/bbs.chinaops.com-error_log"

Customlog "Logs/bbs.chinaops.com-access_log" common

DocumentRoot "/date/blog/"

ServerName blog.chinaops.com

Errorlog "Logs/blog.chinaops.com-error_log"

Customlog "Logs/blog.chinaops.com-access_log" common

DocumentRoot "/date/pma/"

ServerName pma.chinaops.com

Errorlog "Logs/pma.chinaops.com-error_log"

Customlog "Logs/pma.chinaops.com-access_log" common

Service httpd-t (check for errors)

Service httpd Graceful (load configuration)

See how the HTTPD works

NETSTAT-LNP | grep httpd

Iv. installation of Nginx

Tar zxvf/usr/local/src/nginx-1.6.2.tar.gz

CD nginx-1.6.2

Yum Install-y pcre-devel
./configure--prefix=/usr/local/nginx--with-pcre
Make
Make instal

Writing Nginx Startup scripts
Vim/etc/init.d/nginx//Add the following:
#!/bin/bash
# Chkconfig:-30 21
# Description:http Service.
# Source Function Library
. /etc/init.d/functions
# Nginx Settings
Nginx_sbin= "/usr/local/nginx/sbin/nginx"
nginx_conf= "/usr/local/nginx/conf/nginx.conf"
Nginx_pid= "/usr/local/nginx/logs/nginx.pid"
Retval=0
Prog= "Nginx"
Start () {
Echo-n $ "Starting $prog:"
Mkdir-p/dev/shm/nginx_temp
Daemon $NGINX _sbin-c $NGINX _conf
Retval=$?
Echo
Return $RETVAL
}
Stop () {
Echo-n $ "Stopping $prog:"
Killproc-p $NGINX _pid $NGINX _sbin-term
Rm-rf/dev/shm/nginx_temp
Retval=$?
Echo
Return $RETVAL
}
Reload () {
Echo-n $ "Reloading $prog:"
Killproc-p $NGINX _pid $NGINX _sbin-hup
Retval=$?
Echo
Return $RETVAL
}
Restart () {
Stop
Start
}
Configtest () {
$NGINX _sbin-c $NGINX _conf-t
return 0
}
Case "$" in
Start
Start
;;
Stop
Stop
;;
Reload
Reload
;;
Restart
Restart
;;
Configtest)
Configtest
;;
*)
echo $ "Usage: $ {start|stop|reload|restart|configtest}"
Retval=1
Esac
Exit $RETVAL

Start the Nginx service

chmod A+x/etc/init.d/nginx
Chkconfig--add Nginx
Chkconfig Nginx on

Configure Nginx

>/usr/local/nginx/conf/nginx.conf
Vim/usr/local/nginx/conf/nginx.conf
User nobody nobody;worker_processes 2;error_log/usr/local/nginx/logs/nginx_error.log crit;pid/usr/local/nginx/logs /nginx.pid;worker_rlimit_nofile 51200;events{     Use epoll;     worker_ Connections 6000;} http{     include mime.types;     Default_type application/octet-stream;      server_names_hash_bucket_size 3526;     server_names_hash_max_size 4096;     log_format combined_realip ' $remote _addr $http _x_forwarded_for [$time _local] '       ' $host ' $request _uri "$status '      '" $http _referer "" $http _user_agent ";      sendfile on;     Tcp_nopush on;     keepalive_ Timeout 30;     client_header_timeout 3m;     client_body_timeout 3m;      send_timeout 3m;     connection_pool_size 256;     client_header_buffer_size 1k;     large_client_header_buffers 8 4k ;     request_pool_size 4k;     output_buffers 4 32k;      Postpone_output 1460;     client_max_body_size 10m;     client_body_ Buffer_size 256k;     client_body_temp_path/usr/local/nginx/client_body_temp;      proxy_temp_path/usr/local/nginx/proxy_temp;     fastcgi_temp_path/usr/local/ nginx/fastcgi_temp;     fastcgi_intercept_errors on;     tcp_nodelay on;      gzip on;     gzip_min_length 1k;     gzip_buffers 4 8k;     gzip_comp_level 5;     gzip_http_version 1.1;      Gzip_types text/plain application/x-javascript text/css text/htm application/xml;     include vhosts/*.conf; 

Configure Nginx Virtual Host

Mkdir-p/usr/local/nginx/conf/vhosts

Create three files under vhosts bbs.conf blog.conf pma.conf

Configure bbs.conf

Server

{

Listen 80;

server_name bbs.chinaops.com;

Index index.html index.htm index.php;

Root/date/bbs;

#根据user_agent控制

if ($http _user_agent ~ ' bingbot/2.0| mj12bot/v1.4.2| spider/3.0| Youdaobot| tomato| gecko/20100315 ') {

return 403;

}

Location ~ admin.php {

Allow 192.168.0.104; # #真机

Deny all;

Proxy_pass http://127.0.0.1:88;

Proxy_set_header Host $host;

}

Location ~ \.php$ {

Proxy_pass http://127.0.0.1:88;

Proxy_set_header Host $host;

Proxy_set_header X-real-ip $remote _addr;

Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;

}

Location ~. *\. (JS|CSS)? $

{

Expires 24h;

Access_log off;

}

Location ~* ^.+\. (Gif|jpg|png|swf|flv|rar|zip|doc|pdf|gz|bz2|jpeg|bmp|xls) $ {

Expires 7d;

Valid_referers None blocked Server_names *.baidu.com\

*.google.com *.google.cn *.soso.com;

if ($invalid _referer) {

return 403;

#rewrite ^/http://www.example.com/nophoto.gif;

}

Access_log off;

}

rewrite ^ ([^\.] *)/topic-(. +) \.html$ $1/portal.php?mod=topic&topic=$2 last;

rewrite ^ ([^\.] *)/forum-(\w+)-([0-9]+) \.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;

rewrite ^ ([^\.] *)/thread-([0-9]+)-([0-9]+)-([0-9]+] \.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3d$4&page =$3 last;

rewrite ^ ([^\.] *)/group-([0-9]+)-([0-9]+) \.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;

rewrite ^ ([^\.] *)/space-(USERNAME|UID)-(. +) \.html$ $1/home.php?mod=space&$2=$3 last;

rewrite ^ ([^\.] *)/(Fid|tid)-([0-9]+) \.html$ $1/index.php?action=$2&value=$3 last;

Access_log/home/logs/discuz.log Combined_realip;

}

configuration blog.conf (reference http://www.upupw.net/nginxhelp/n33.html)

Server

{

Listen 80;

server_name blog.chinaops.com;

Index index.html index.htm index.php;

Root/date/blog;

location/wp-admin/{

Allow 192.168.0.104;

Deny all;

Location ~ \.php$ {

Proxy_pass http://127.0.0.1:88;

Proxy_set_header Host $host;

}

}

Location/{

Proxy_pass http://127.0.0.1:88/;

Proxy_set_header Host $host;

Proxy_set_header X-real-ip $remote _addr;

Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;

}

}

Configure pma.conf

Server

{

Listen 80;

server_name pma.chinaops.com;

Index index.html index.htm index.php;

ROOT/DATE/PMA;

Location/{

Auth_basic "Auth";

AUTH_BASIC_USER_FILE/USR/LOCAL/NGINX/CONF/HTPASSWD;

Location ~ \.php$ {

Proxy_pass http://127.0.0.1:88;

Proxy_set_header Host $host;

Proxy_set_header X-real-ip $remote _addr;

Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;

}

}

}

Service Nginx Configtest

Service Nginx Rsstart

Five, Discuz, WordPress, phpMyAdmin Configuration

Mkdir-p/DATE/{DIXCUZ,BLOG,PMA}

Configure Discuz

Useradd-s/sbin/nologin Daemon

Unzip Discuz_x3.2_sc_utf8.zip

Move the files inside the upload to the site monitoring directory/date/discuz/

cd/data/discuz/

Chown-r Daemon.daemon config/data/uc_client/data/uc_server/data/

192.168.0.104 Modify Vhost on a real machine

192.168.0.104 bbs.chinaops.com blog.chinaops.com pma.chinaops.com

Access bbs.chinaops.com fill in the database IP address, database user name password and create admin password

Configure WordPress

Cd/date

Tar zxvf wordpress-4.2.2-zh_cn.tar.gz

MV WORDPRESS-4.2.2-ZH_CN Blog

Access blog.chinaops.com/wp-admin/fill in the database IP, the database user name password

Configure phpMyAdmin

Cd/date

Unzip Phpmyadmin-4.4.13.1-all-languages.zip

MV Phpmyadmin-4.4.13.1-all-languages PMA

CD PMA

CP libraries/config.default.php config.inc.php

Change

$cfg [' Servers '] [$i] [' user '] = ' root ';

$cfg [' Servers '] [$i] [' password '] = ' yourrootpassword ';

$cfg [' Servers '] [$i] [' host '] = ' yourdbip ';

$cfg [' Servers '] [$i] [' auth_type '] = ' config '; # #认证模式

Visit pma.chinaops.com to

Blog reproduced in: http://linuxlearn.blog.51cto.com/1437234/1684733

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.