目錄php
(1) 三者分離於兩臺主機html
(2) 一個虛擬主機提供phpMyAdmin;另外一個虛擬主機提供wordpressmysql
(3) xcachec++
(4) 爲phpMyAdmin提供https虛擬主機sql
yum install http php yum install php-mbstring unzip phpMyAdmin-4.0.10.20-all-languages.zip mv phpMyAdmin-4.0.10.20-all-languages /var/www/html/phpMyAdmin cd /var/www/html/phpMyAdmin/ cp config.sample.inc.php config.inc.php vim config.inc.php $cfg['blowfish_secret'] = 'a8asdasdfgh11946d'; $cfg['Servers'][$i]['host'] = '192.168.1.10'; tar xvf wordpress-4.9.4-zh_CN.tar.gz -C /var/www/html/ cd /var/www/html/wordpress cp wp-config-sample.php wp-config.php vim wp-config.php /** WordPress數據庫的名稱 */ define('DB_NAME', 'wpdb'); /** MySQL數據庫用戶名 */ define('DB_USER', 'http'); /** MySQL數據庫密碼 */ define('DB_PASSWORD', 'centos'); /** MySQL主機 */ define('DB_HOST', '192.168.1.10'); 訪問wordpress頁面安裝 systemctl restart httpd
參考 LAMP PHP 詳解 編譯安裝xcache 文章
yum install mysql mysql_secure_installation grant all on *.* to http@'192.168.1.%' identified by 'centos';
(1) 三者分離於三臺主機數據庫
(2) 一個虛擬主機提供phpMyAdmin;另外一個虛擬主機提供wordpressapache
(3) xcachevim
見獨立筆記
注意:在沒有nfs的狀況下,若是把php和http分離,須要把網頁在php服務器和html服務器,各放一份。!!centos
主機IP | 系統 | 部署服務 |
---|---|---|
192.168.1.14 | Centos6 | apache |
192.168.1.12 | Centos6 | php-fpm |
192.168.1.13 | Centos6 | mysql5.6 |
(1) 三者分離於兩臺或三臺主機api
(2) 一個虛擬主機提供phpMyAdmin;另外一個虛擬主機提供wordpress
(3) xcache
(4) 嘗試mpm爲非prefork機制
#編譯環境 yum groupinstall Development -y yum install pcre-devel openssl-devel expat-devel -y # apache 帳戶 groupadd -r -g 80 apache useradd -r -s /sbin/nologin -g 80 -u 80 apache #解壓包 cd /alidata/ tar xvf httpd-2.4.33.tar.bz2 tar xvf apr-util-1.6.1.tar.gz tar xvf apr-1.6.3.tar.gz mv apr-1.6.3 httpd-2.4.33/srclib/apr mv apr-util-1.6.1 httpd-2.4.33/srclib/apr-util cd httpd-2.4.33 #編譯 ./configure --prefix=/alidata/httpd --with-mpm=prefork --enable-so --enable-rewrite --enable-mods-shared=all --enable-nonportable-atomics=yes --disable-dav --enable-deflate --enable-cache --enable-disk-cache --enable-mem-cache --enable-file-cache --enable-ssl --with-included-apr --enable-modules=all --enable-mods-shared=all --enable-cgi #這條命令能夠查看 CPU數 cat /proc/cpuinfo |grep processor |wc -l make -j 12 make install #添加環境變量和啓動腳本 echo PATH=/alidata/httpd/bin:$PATH > /etc/profile.d/http.sh cp /alidata/httpd/bin/apachectl /etc/init.d/httpd #配置主配置文件 (表示要更改和新增的行) 主要是啓動模塊,修改默認目錄,主頁 vim /alidata/httpd/conf/httpd.conf #去掉下面兩行註釋啓動模塊 LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so #修改主機名和默認目錄 ServerName www.ddz.com:80 #DocumentRoot "/alidata/httpd/htdocs" DirectoryIndex index.php index.html #添加解析 AddType application/x-httpd-php .php Addtype application/x-httpd-php-source .phps #關閉正向代理,轉發到php服務器,這兩行不用,由於後面要配置虛擬主機,因此寫在虛擬主機的配置裏 #ProxyRequests Off #ProxyPassMatch ^/(.*\.php)$fcgi://192.168.1.13:9000/app/httpd24/htdocs/$1 #容許主配置文件使用虛擬主機配置 取消該行註釋 # Virtual hosts Include conf/extra/httpd-vhosts.conf
#先建立目錄 mkdir -pv /alidata/vhosts/{phpmyadmin,wordpress} mkdir -pv /var/log/httpd #配置文件 vim /alidata/httpd/conf/extra/httpd-vhosts.conf <VirtualHost *:80> DocumentRoot "/alidata/vhosts/phpmyadmin" ServerName www.phpmyadmin.com ErrorLog "/var/log/httpd/phpmyadmin-error_log" CustomLog "/var/log/httpd/phpmyadmin-access_log" common ProxyRequests Off ProxyPassMatch ^/(.*\.php)$ fcgi://192.168.1.12:9000/alidata/vhosts/phpmyadmin/$1 <Directory "/alidata/vhosts/phpmyadmin"> Options none AllowOverride none Require all granted </Directory> </VirtualHost> <VirtualHost *:80> DocumentRoot "/alidata/vhosts/wordpress" ServerName www.blog.com ErrorLog "/var/log/httpd/wordpress-error_log" CustomLog "/var/log/httpd/wordpress-access_log" common ProxyRequests Off ProxyPassMatch ^/(.*\.php)$ fcgi://192.168.1.12:9000/alidata/vhosts/wordpress/$1 <Directory "/alidata/vhosts/wordpress"> Options none AllowOverride none Require all granted </Directory> </VirtualHost>
至此,apache服務配置完成,重啓便可
apachectl restart service httpd restart
hostname mysql yum groupinstall Development -y yum -y install bison bison-devel zlib-devel libcurl-devel libarchive-devel boost-devel gcc gcc-c++ cmake ncurses-devel gnutls-devel libxml2-devel openssl-devel libevent-devel libaio-devel (epel 源) #準備數據目錄 mkdir /alidata/mysqldb chown mysql.mysql /alidata/mysqldb/ #準備包 cd /alidata/ wget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.37.tar.gz tar xvf mysql-5.6.37.tar.gz #準備帳戶 groupadd -r mysql -g 80 useradd -r -s /sbin/nologin -g 80 -u 80 mysql #編譯安裝 cmake . -DCMAKE_INSTALL_PREFIX=/alidata/mysql -DMYSQL_DATADIR=/alidata/mysqldb/ -DSYSCONFDIR=/etc -DMYSQL_USER=mysql -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITHOUT_MROONGA_STORAGE_ENGINE=1 -DWITH_DEBUG=0 -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_LIBWRAP=0 -DENABLED_LOCAL_INFILE=1 -DMYSQL_UNIX_ADDR=/alidata/mysqldb/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci make -j 12 make install #添加變量 echo 'PATH=/alidata/mysql/bin:$PATH' > /etc/profile.d/mysql.sh . /etc/profile.d/mysql.sh cd /alidata/mysql #初始化數據庫 scripts/mysql_install_db --datadir=/alidata/mysqldb/ --user=mysql #作啓動服務 cp support-files/mysql.server /etc/init.d/mysqld cd /etc/init.d/ chkconfig --add mysqld #編輯數據庫配置文件 vim /etc/my.cnf [mysqld] datadir=/alidata/mysqldb socket=/alidata/mysqldb/mysql.sock user=mysql # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 log-bin port=3306 skip-name-resolve [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/alidata/mysqldb/mysqld.pid #啓動服務 service mysqld start #安全初始化 mysql_secure_installation #建立管理帳戶 grant all on *.* to http@'192.168.1.%' identified by 'centos';
#編譯環境 yum groupinstall Development -y yum install libxml2-devel bzip2-devel libmcrypt-devel -y yum install pcre-devel openssl-devel expat-devel -y #帳戶準備 groupadd -r -g 80 php useradd -r -s /sbin/nologin -g 80 -u 80 php cd /alidata/ tar xvf php-7.1.18.tar.bz2 cd php-7.1.18 #編譯安裝 ./configure --prefix=/alidata/php --enable-mysqlnd --with-mysqli=mysqlnd --with-openssl --with-pdo-mysql=mysqlnd --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --enable-fpm --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --enable-maintainer-zts --disable-fileinfo make -j 12 make install #環境配置 echo 'PATH=/alidata/php/bin:$PATH' > /etc/profile.d/php.sh . /etc/profile.d/php.sh #建立配置文件 cp php.ini-production /etc/php.ini #建立啓動服務 cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm chmod +x /etc/init.d/php-fpm chkconfig --add php-fpm chkconfig php-fpm on #建立配置文件 cd /alidata/php/etc/ cp php-fpm.conf.default php-fpm.conf cp php-fpm.d/www.conf.default php-fpm.d/www.conf #修改配置文件 vim /alidata/php/etc/php-fpm.d/www.conf #修改應用使用者 user = php group = php #監聽端口和容許訪問者 listen = 192.168.1.12:9000 listen.allowed_clients = 192.168.1.14 #看需求改 pm.max_children = 50 pm.start_servers = 5 pm.min_spare_servers = 2 pm.max_spare_servers = 5 #看需求改 vim /etc/php.ini memory_limit = 1024M
phpmyadmin
#建立存放該服務的目錄 mkdir -pv /alidata/vhosts/{phpmyadmin,wordpress} mkdir -pv /var/log/httpd cd /alidata/ unzip phpMyAdmin-4.8.1-all-languages.zip mv phpMyAdmin-4.8.1-all-languages/* vhosts/phpmyadmin/ #建立配置文件 cd vhosts/phpmyadmin/ mv config.sample.inc.php config.inc.php #生成隨機字符串 openssl rand -base64 18 vim config.inc.php $cfg['Servers'][$i]['host'] = '192.168.1.13'; #因爲沒有nfs 因此複製一份一毛同樣的去apache 服務器 scp -r phpmyadmin/* root@192.168.1.14:/alidata/vhosts/phpmyadmin/
wordpress
cd /alidata/ tar xvf wordpress-4.9.4-zh_CN.tar.gz -C /alidata/vhosts/ cd /alidata/vhosts chown -R root.root wordpress/ #設置配置文件 cd wordpress/ cp wp-config-sample.php wp-config.php vim wp-config.php define('DB_NAME', 'wpdb'); define('DB_USER', 'http'); define('DB_PASSWORD', 'centos'); define('DB_HOST', '192.168.1.13'); scp -r wordpress root@192.168.1.14:/alidata/vhosts/ setfacl -R -m u:php:rwx wordpress/