多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
## 1(50分)部署dedecms(www网站),discuz(bbs网站),wordpress(blog网站),并把用户上传的目录挂载到nfs01的/data/www /data/bbs /data/blog上 ### 以下是web01(10.0.0.8),web02(10.0.0.7)上的部署, #### 一, 安装nginx ##### 01,下载,解压nginx源码 ~~~ mkdir /root/tools -p cd /root/tools yum install openssl openssl-devel -y yum install pcre pcre-devel -y useradd www -u 888 -s /sbin/nologin -M wget -q http://nginx.org/download/nginx-1.14.0.tar.gz tar xf nginx-1.14.0.tar.gz ~~~ ##### 02,配置nginx ~~~ cd /root/tools/nginx-1.14.0 ./configure --user=www --group=www --with-http_ssl_module --with-http_stub_status_module --prefix=/apps/nginx-1.14.0/ ~~~ ##### 03,编译安装nginx ~~~ make make install ~~~ ##### 04,给nginx目录创建软连接 ~~~ ln -s /apps/nginx-1.14.0/ /apps/nginx ~~~ ##### 05,修改nginx配置文件 ~~~ # nginx.conf cat >nginx.conf<<EOF worker_processes 1; error_log logs/error.log; error_log logs/error.log notice; error_log logs/error.log info; pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; 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 logs/access.log main; sendfile on; keepalive_timeout 65; include extra/www.conf; include extra/bbs.conf; include extra/blog.conf; } EOF # extra/www.conf cat >extra/www.conf <<EOF server { listen 80; server_name www.etiantian.org; location / { root html/www; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html/www; } location ~ \.php$ { root html/www; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; } } EOF # extra/bbs.conf cat >extra/bbs.conf <<EOF server { listen 80; server_name bbs.etiantian.org; location / { root html/bbs; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html/bbs; } location ~ \.php$ { root html/bbs; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; } } EOF # extra/blog.conf cat >extra/blog.conf <<EOF server { listen 80; server_name blog.etiantian.org; location / { root html/blog; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html/blog; } location ~ \.php$ { root html/blog; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; } } EOF ~~~ ##### 06,nginx开机自启动 ~~~ ln -s /apps/nginx/sbin/nginx /usr/bin/nginx echo '/usr/bin/nginx' >> /etc/rc.local ~~~ #### 二,安装php ##### 01,安装依赖库 ```Bash yum install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel curl-devel -y yum install freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel -y rpm -qa zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel curl-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel ``` ##### 02, 安装其它相关程序---libmcrypt ```Bash #wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo yum -y install libmcrypt-devel mhash mcrypt rpm -qa libmcrypt-devel mhash mcrypt #php下载地址 http://php.net/releases/ ``` ##### 03, 下载并解压 ```Bash #下载安装包并解压 cd /root/tools/ wget http://cn2.php.net/distributions/php-5.6.36.tar.gz tar xf php-5.6.36.tar.gz cd php-5.6.36 #----正式编译前也可以把这个软件安装上(libxslt*) ``` ##### 04, 配置 ``` ./configure --prefix=/apps/php-5.6.36 \ --with-mysql=mysqlnd \ --with-pdo-mysql=mysqlnd \ --with-freetype-dir \ --with-jpeg-dir \ --with-png-dir \ --with-zlib \ --with-libxml-dir=/usr \ --enable-xml \ --disable-rpath \ --enable-bcmath \ --enable-shmop \ --enable-sysvsem \ --enable-inline-optimization \ --with-curl \ --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-soap \ --enable-short-tags \ --enable-static \ --with-xsl \ --with-fpm-user=www \ --with-fpm-group=www \ --enable-ftp \ --enable-opcache=no ``` ##### 05, 编译--安装--安装目录创建软连接 ```bash touch ext/phar/phar.phar #这个文件一定要创建 make && make install ln -s /apps/php-5.6.36/ /apps/php ``` ##### 06,复制php配置文件 ~~~ cp /root/tools/php-5.6.36/php.ini-production /apps/php-5.6.36/lib/php.ini cp /apps/php-5.6.36/etc/php-fpm.conf.default /apps/php-5.6.36/etc/php-fpm.conf ~~~ ##### 07,检查并启动php ~~~ /apps/php-5.6.36/sbin/php-fpm -t /apps/php-5.6.36/sbin/php-fpm ss -lntup |grep 9000 ~~~ ##### 08,php-fpm开机自启动 ~~~ ln -s /apps/php/sbin/php-fpm /usr/bin/php-fpm echo '/usr/bin/php-fpm' >> /etc/rc.local ~~~ ### 在数据库服务器上安装mysql,ip为10.0.0.51 #### 数据库安装 ##### 0.准备工作-下载mysql ``` # 下载地址 # https://downloads.mysql.com/archives/community/ mkdir /root/tools -p cd /root/tools wget https://downloads.mysql.com/archives/get/file/mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz ``` ##### 1.添加用户 ``` useradd -s /sbin/nologin -M mysql ``` ##### 2.解压 mysql 二进制包 ``` cd /root/tools tar xf mysql-5.6.40-*-x86_64.tar.gz ``` ##### 3.把MySQL 移动到 /apps/ ``` mkdir -p /apps/ mv /root/tools/mysql-5.6.40-*-x86_64 /apps/mysql-5.6.40 ``` ##### 4.创建软连接 ``` ln -s /apps/mysql-5.6.40/ /apps/mysql ``` ##### 5.让MySQL用户管理 /apps/mysql ``` chown -R mysql.mysql /apps/mysql/data ``` ##### 6.安装这个软件 初始化数据库 ``` /apps/mysql/scripts/mysql_install_db --basedir=/apps/mysql --datadir=/apps/mysql/data --user=mysql ``` ##### 7.复制启动脚本 授权 ``` cp /apps/mysql/support-files/mysql.server /etc/init.d/mysqld chmod +x /etc/init.d/mysqld ``` ##### 8.修改启动脚本 和 mysql命令 中的路径 ``` sed -i 's#/usr/local/mysql#/apps/mysql#g' /apps/mysql/bin/mysqld_safe /etc/init.d/mysqld ``` ##### 9.复制 默认的配置文件 ``` \cp /apps/mysql/support-files/my-default.cnf /etc/my.cnf /etc/init.d/mysqld start ``` ##### 10.PATH路径 ``` echo 'export PATH=/apps/mysql/bin:$PATH' >>/etc/profile source /etc/profile which mysql ``` ##### 11.加入开机自启动 ``` chkconfig --add mysqld chkconfig mysqld on chkconfig | grep mysql ``` ##### 12.给MySQL root用户设置密码 ``` /apps/mysql/bin/mysqladmin -u root password 'oldboy123' ``` ##### 13.重新登录MySQL数据库,创建所需数据库 ``` mysql -uroot -poldboy123 create database discuz; grant all on discuz.* to 'discuz'@'172.16.1.0/255.255.255.0' identified by '123456'; create database dedecms; grant all on dedecms.* to 'dedecms'@'172.16.1.0/255.255.255.0' identified by '123456'; create database wordpress; grant all on wordpress.* to 'wordpress'@'172.16.1.0/255.255.255.0' identified by '123456'; flush privileges; # mysql -uwordpress -p123456 -h 172.16.1.8 ``` ### 三,部署网站,把 ~~~ cd /root/tools wget https://cn.wordpress.org/wordpress-4.9.4-zh_CN.tar.gz tar xf wordpress-4.9.4-zh_CN.tar.gz cd wordpress/ \cp * /apps/nginx/html/blog/ -a cd /root/tools wget http://updatenew.dedecms.com/base-v57/package/DedeCMS-V5.7-UTF8-SP2-Full.tar.gz tar xf DedeCMS-V5.7-UTF8-SP2-Full.tar.gz cd DedeCMS-V5.7-UTF8-SP2-Full/uploads/ \cp * /apps/nginx/html/www/ -a cd /root/tools wget http://download.comsenz.com/DiscuzX/3.3/Discuz_X3.3_SC_UTF8.zip unzip Discuz_X3.3_SC_UTF8.zip cd upload/ \cp * /apps/nginx/html/bbs/ -a cd /apps/nginx chown -R www.www html ~~~ ### 安装dedecms,discuz,wordpress截图,见附件 `安装dedecms,discuz,worpress截图.pdf` ~~~ web01安装完成以后,把html/下的内容全部复制到web02上面 scp -r root@10.0.0.8:/apps/nginx/html/* /apps/nginx/html/ chown -R www.www /apps/nginx/html/ ~~~ ### 配置nfs01,存储服务 ~~~ #1,安装nfs和rpcbind yum install nfs-utils rpcbind -y #2,启动rpcbind和nfs服务 #先启动rpcbind /etc/init.d/rpcbind start #再启动nfs /etc/init.d/nfs start #3,开机自启动 chkconfig nfs on chkconfig rpcbind on #4,创建/data目录,更改所属用户和用户组 useradd www -u 888 -s /sbin/nologin -M mkdir /data/{www,bbs,blog} -p chown -R www.www /data/ #5,配置NFS服务,分享/data目录 vim /etc/exports #share /data 172.16.1.0/24 /data/www 172.16.1.0/24(rw,sync,all_squash,anonuid=888,anongid=888) /data/bbs 172.16.1.0/24(rw,sync,all_squash,anonuid=888,anongid=888) /data/blog 172.16.1.0/24(rw,sync,all_squash,anonuid=888,anongid=888) #6,重启nfs服务 /etc/init.d/nfs reload #7,在web01,web02上挂载 yum install nfs-utils rpcbind -y /etc/init.d/rpcbind start chkconfig rpcbind on chkconfig nfs off mount -t nfs 172.16.1.31:/data/www /apps/nginx/html/www/upload mount -t nfs 172.16.1.31:/data/bbs /apps/nginx/html/bbs/data/attachment/forum mount -t nfs 172.16.1.31:/data/blog /apps/nginx/html/blog/wp-content/uploads ~~~