In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to build the discuz forum under the LNAMP environment and realize the mysql master-slave deployment. The content of the article is carefully selected and edited by the author. It has a certain pertinence and is of great significance to everyone's reference. The following is to understand with the author how to build the discuz forum under the LNAMP environment and realize the mysql master-slave deployment.
Experimental environment:
1 、 VMware Workstation 10
2. Real IP:192.168.0.113
2. Device Apurs nginxapparatus apacheals phpads discuzables mysqlMagical IP address: 192.168.145.133 recording hostlmaster1
3. Equipment B:
Mysql,IP address 192.168.145.134
4. Linux distribution: Centos 6.5x86x64
5 、 nginx:nginx-1.8.0.tar.gz
6 、 apache:httpd-2.2.27.tar.bz2
7 、 php:php-5.6.12.tar.bz2
8. Mysql:mysql-5.6.32-linux-glibc2.5-x86_64.tar.gz (B device master)
Mysql-5.1.73-linux-x86_64-glibc23.tar.gz (A device slave)
9 、 discuz:Discuz_X3.2_SC_UTF8.zip
The steps of the experiment:
1. Install mysql database on B device
Tar zxvf / usr/local/src/mysql-5.6.32-linux-glibc2.5-x86_64.tar.gz mv mysql-5.6.32-linux-glibc2.5-x86_64 / 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 # Database initialization cp support-files/my-large.cnf / etc/my.cnf # copy database configuration file cp support-files/mysql.server / etc/init.d/mysqld # copy database startup script chmod 755 / etc/init.d/mysqld vim / etc/init.d/mysqld # modify datadir=/usr/local/mysql chkconfig-add mysqld chkconfig mysqld on Service mysqld start mysql-h227.0.0.1-uroot # login database > create database discuz # create discuz library > grant all on discuz.* to 'xaioyuan'@'192.168.145.133' identified by' 123456database; # this statement authorizes xiaoyuan users with an ip of 192.168.145.133 to access the discuz library with an access password of 123456 > quit # to exit the database
2. Install apache on device A.
Tar jxvf / usr/local/src/httpd-2.2.27.tar.bz2cd / usr/loca/src/httpd-2.2.27./configure\-- prefix=/usr/local/apache2\-- with-included-apr\-- enable-so\-- enable-deflate=shared\-- enable-expires=shared\-- enable-rewrite=sharedmake & make installcp / usr/local/apache2/bin/apachectl / etc/init.d/httpd # copy apache's startup script vim / etc/init.d/httpd Add two lines of text under the first line #! / bin/sh # chkconfig: 35 70 3 saved description: Apache save exit chkconfig-- level 35 httpd on
3. Install php on device A.
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 # if you encounter repeated errors when compiling php You should observe whether the compilation options appear spaces when there should not be spaces, such as: "\-- with-mysql=mysqlnd\-- with-mysqli=mysqlnd" is written as "\-- with-mysql=mysqlnd\-- with-mysqli=mysqlnd". Make & & make installcp / usr/local/src/php-5.6.12/php.ini-production / usr/local/php/etc/php.ini
4. Configure apache to associate with php
Vim / usr/local/apache2/conf/httpd.conf find: AddType application/x-gzip .gz .tgz add: AddType application/x-httpd-php .php find: DirectoryIndex index.html/IfModule > change it to: DirectoryIndex index.html index.htm index.php find: # ServerName www.example.com:80 modify to: ServerName localhost:88 find: listen:80 change to: listen:88 find: Options FollowSymLinks AllowOverride None Order deny Change allow Deny from all to: Options FollowSymLinks AllowOverride None Order deny Allow Allow from all found: # Include conf/extra/httpd-vhosts.conf remove the first # to see if there is a modules/libphp5.sovim / usr/local/apache2/conf/extra/httpd-vhosts.conf # Open the apache virtual host configuration file and add at the end: DocumentRoot "/ date/discuz/" ServerName bbs.xiaoyua.com ErrorLog "logs/bbs.xiaoyuan.com-error_log" CustomLog "logs / bbs.xiaoyuan.com-access_log "commonservice httpd-t (check for errors) service httpd graceful (load configuration) to view the operation of httpd netstat-lnp | grep httpd
5. Install nginx on device A.
Tar zxvf / usr/local/src/nginx-1.8.0.tar.gz cd nginx-1.8.0./configure-- prefix=/usr/local/nginx-- with-pcre make & make instalvim / etc/init.d/nginx # write the startup script: #! / bin/bash# chkconfig:-302 hours description: http service.# Source Function Library. / etc/init.d/functions# Nginx SettingsNGINX_SBIN= "/ usr/local/nginx/sbin/nginx" NGINX_CONF= "/ usr/local/nginx/conf/nginx.conf" NGINX_PID= "/ usr/local/nginx/logs/nginx.pid" RETVAL=0prog= "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 "$1" in start) start;; stop) stop;; reload) reload;; restart) restart;; configtest) configtest *) echo $"Usage: $0 {start | stop | reload | restart | configtest}" RETVAL=1esacexit $RETVAL starts the nginx service: chmod aplyx / etc/init.d/nginxchkconfig-- add nginxchkconfig nginx on/usr/local/nginx/conf/nginx.conf # write the nginx configuration file: user nobody nobody;worker_processes 2 transmissionlog / usr/local/nginx/logs/nginx_error.log crit;pid / usr/local/nginx/logs/nginx.pid;worker_rlimit_nofile 51200 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 / usr/local/nginx/conf/vhosts/*.conf Mkdir-p / usr/local/nginx/conf/vhosts # create nginx virtual host vim / usr/local/nginx/conf/vhosts/bbs.conf # # configure nginx virtual host (discuz) server {listen 80; server_name bbs.chinaops.com; index index.html index.htm index.php; root / date/bbs # restrict 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.113; # # only real machines are allowed to access admin.php deny all; proxy_pass http://127.0.0.1:88; Proxy_set_header Host $host;} # Agent apache 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 } # set static cache location ~. *\. (js | css)? ${expires 24h; access_log off;} # set hotlink protection location ~ * ^. +\. (gif | jpg | png | swf | flv | rar | doc | pdf | gz | 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;}
5. Install discuz on device A.
Mkdir / data/discuzcd / data/discuzwget unzip Discuz_X3.2_SC_UTF8.zip mv upload/*. Enter: bbs.xiaoyuan.com/installcd / data/bbschown-R daemon.daemon config/ data/ uc_client/data/ uc_server/data/ in the browser to install according to the installation steps prompted.
6. Set up mysql master and slave
# mysql on machine B configure master for mysql on master,A machine and configure slave for slave: vim / usr/local/mysql/my.cnf # modify or add two optional parameters: server-id=1 log-bin=mysql-bin (2 optional 1): binlog-do-db=discuz # libraries that need to be synchronized binlog-ignore-db=db1,db2 # after ignoring out-of-sync libraries to modify configuration files Restart mysql mysql-h227.0.0.1-uroot # log in to mysql database > grant replication slave on *. * to 'repl'@'192.168.145.133' identified by' 123123' # authorized slave can access master > flush tables with read lock; > show master status # will use the contents of the first two columns to install (same as master steps) and configure slave: vim / etc/my.cnf # modify or add server-id = 2 # this value cannot be the same as the main two optional parameters (2 optional 1): replicate-do-db=discuz # library replicate-ignore-db=db1 that needs synchronization Db2 # ignores the asynchronous library mysql-h227.0.0.1-uroot # Log in to mysql database slave stop Change master to master_host='192.168.145.134', master_port=3306, master_user='repl', master_password='123123', master_log_file='mysql-bin.000006', master_log_pos=474952; slave start Master: mysql-uroot-S / tmp/mysql2.sock-p123456-e "unlock tables" check the status of the slave from above: show slave status\ G when you see Slave_IO_Running: Yes Slave_SQL_Running: Yes Replicate_Do_DB: discuz, it means that the mysql master / slave has been successfully built. A further verification method is to create a table in master's discuz library, and then go to slave to see if the table appears in slave's discuz library.
After reading the above about how to build discuz forums and achieve mysql master-slave deployment in LNAMP environment, many readers must have some understanding. If you need to get more industry knowledge and information, you can continue to follow our industry information column.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.