httpd

1.安裝好開發包租

  yum groepinstall -y “Development Tools””Server Platform Development ”

  2.再依次安裝mariadb數據庫, httpd服務,php-xcache服務

    yum install mariadb-service

    vim /etc/my.conf

  [mysql]

  innodb_file_per_table = ON

  skip_name_resolve = ON

重啓服務後,檢查進程和端口運行

    systemctl reatart mariadb.service

    ps aux 

    ss -ntl

檢查數據庫是否可以使用

$mysql

 

安裝httpd服務以及依賴包

yum install http php php-gd php-mysql php-mbstring php-xml

默認配置就可以達到我們所需要求

重啓服務

sysctemctl restart httpd.service

查看服務是否運行,端口是否打開

 Ps aux

ss -ntl

檢測httpd服務是否能被解析

vim /var/www/html/index.php

<?php

Phpinfo();

?>

檢測mysql數據庫是否能被解析

$vim /var/www/html/index.php

<?php

$conn = mysql_connect(‘127.0.0.1’,’root’,’’);

if($conn)

echo "ok";

else

echo "failure";

mysql_close();

?>

 

安裝php-xccahe

yum install php-xcache

編輯配置文件

vim /etc/httpd/xcache.ini

重新加載服務

systemctl httpd reload

檢測是否能解析

vim /var/www/hmtl/index.php

<?php

 phpinfo();

?>

 

完成amp安裝後,在創建基於ip地址的虛擬機

ip addr add 172.16.54.2/16 dev eno16777736

ip a l

 

其中172.16.54.1提供WordPress

編輯虛擬主機172.16.54.1的配置文件

vim /etc/httpd/conf.d/vhost1.conf

 

下載WordPress.zip安裝包,並解壓

將解壓後的安裝包移動到/data/vhosts/www1/目錄下

wp-config-sample.php 改名爲wp-config.php

在創建wpdb數據庫

#mysql>GRANT ALL ON wpdb.*  TO  'wpuser'@'172.16.%.$'  IDENTIFIED BY 'wppass';

#mysql>CREATE DATABASE wpdb;

#mysql>exit;

在編輯WordPress的配置文件

vim wp-config.php

將數據庫文件信息填在對應的位置

NAME      wpdb

USER      wpuser      

PASSWORD      wppass

HOST      172.16.54.2

 

vim /data/vhosts/www1/index.php

<?php

 phpinfo();

?>

在重啓服務,瀏覽器172.16.54.1

172.16.54.2上面提供phpMyAdmin服務

vim /etc/httpd/conf.d/vhost2.conf

安裝phpMyAdmin

yum install phpMyAdmin

編輯其配置文件

vim /etc/httpd/conf.d/phpMyAdmin

Apache [2.4]下的

<Require>都指向172.16

Require ip 172.16

(b)

yum install mod_ssl

172.16.54.6 CA

cd /etc/pki/CA

(umask 077;openssl genrsa -out private/cakey.pem 2048 )

openssl req -new -x509 -key private/cakesy.pem -out cacert.pem

 [CN  Beijing  Beijing magedu ops magedu.com  @admin.com]

 

/etc/httpd/ssl

(umask 077;openssl genrsa -out private/httpd.key 1024)

openssl req -new -key httpd.key -out httpd.csr

scp httpd.csr 172.16.54.6:/tmp 

 

[CA]

openssl ca -in /tmp/httpd.csr -out /etc/pki/certs/httpd.crt

scp certs/httpd.crt  172.16.54.1:/etc/httpd/ssl

vim /etc/httpd/conf.d/ssl.conf

 

ServerName www2.magedu.com:443

DocumentRoot "/data/vhosts/www2"

ServerName www2.mageducom/phpmyadmin/:443

SSLCertifcateFile /etc/httpd/ssl/httpd.crt

SSLCertifcateKeyFile /etc/httpd/ssl/httpd.key

 

systemctl httpd reload 

ss -ntl

 

172.16.54.1  http

172.16.54.2 php-fpm

172.16.54.3  mariadb

 

yum -y instal httpd

vim /etc/httpd/conf.d/vhost1.conf

<VirtualHost 172.16.54.1:80>

ServerName www1.magedu.com

DocumentRoot "/data/vhost/www1"

ProxyRequests on

DirectoryIndex index.php

ProxyPassMatch ^/(.*\.php)$ fcgi://172.16.54.2:9000/data/vhost/www1/$1        

 <Directory "/data/vhost/www1">

       Options None

   AllowOverride None

   Require all granted

  </Directory>

</VirtualHost>

 

vim /etc/httpd/conf.d/vhost2.conf 

<VirtualHost 172.16.54.1:80>

ServerName www2.magedu.com

DocumentRoot "/data/vhost/www2"

ProxyRequests on

DirectoryIndex index.php

ProxyPassMatch ^/(.*\.php)$ fcgi://172.16.54.2:9000/data/vhost/www2/$1    

<Directory "/data/vhost/www2">

   Options None

  AllowOverride None

  Require all granted

   </Directory>

</VirtualHost>

 

vim /etc/resolv.conf 

DNS=172.16.54.1

nameserver 172.16.0.1

           

 

vim /etc/hosts

172.16.54.1 www1.magedu.com www2.magedu.com

       

 

mkdir -pv /data/vhost/www{1,2}

 

vim /data/vhost/www1/index.html

http111111

 

vim /data/vhost/www2/index.html

http222222

       

 

 

           

########172.16.54.2#########

yum install php-fpm

 

vim /etc/php-fpm.d/www.conf

listen = 172.16.54.2:9000        

 listen.allowed_clients = 172.16.54.2    

mkdir -pv /data/vhost/www{1,2}


vim /data/vhost/www1/index.php

<h1>php</h1>

<?php

$conn = mysql_connect('172.16.54.3','wpuser','wppass');

      if($conn)

          echo "OK";

      else

          echo "Failure";

      phpinfo();

?>

       

 

   

unzip wordpress-4.3.1-zh_CN.zip 

mv wordpress /data/vhost/www1

cd /data/vhost/www1/wordpress/

mv wp-config-sample.php wp-config.php 

vim wp-config.php

define('DB_NAME', 'wpdb');

define('DB_USER', 'wpuser');

define('DB_PASSWORD', 'wppass');

define('DB_HOST', '172.16.54.3');          

       

unzip phpMyAdmin-4.4.14.1-all-languages.zip 

mv phpMyAdmin-4.4.14.1-all-languages /data/vhost/www2/

cd /data/vhost/www2/  

ln -s phpMyAdmin-4.4.14.1languages myadmin      

cd myadmin/        

ln -s config.sample.inc.php config.inc.php    

openssl rand -base64 10

vim config.inc.php

$cfg['blowfish_secret'] = '4pnJU4R8p4WaQxD'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

                                                         

/*

 * Servers configuration

 */

$i = 0;

/*

 * First server

 */

$i++;

/* Authentication type */

$cfg['Servers'][$i]['auth_type'] = 'cookie';

/* Server parameters */

$cfg['Servers'][$i]['host'] = '172.16.54. 3';                

$cfg['Servers'][$i]['connect_type'] = 'tcp';

$cfg['Servers'][$i]['compress'] = false;

$cfg['Servers'][$i]['AllowNoPassword'] = false;

 

 

 

 

######172.16.54.3###########

yum install mariadb-server

systemctl start mariadb.service

mysql> GRANT ALL ON wpdb.* TO 'wpuser'@'172.16.%.%' IDENTIFIED BY 'wppass';

mysql>  CREATE DATABASE wpdb;

 

 

 

 

 

           

172.16.54.2

 cd /etc/pki/CA/

(umask 077; openssl genrsa-out private/cakey.pem 2048)

openssl req -new -x509 -key private/cakey.pem -out cacert.pem 

CN

beijing

beijing

magedu

ops

ca.magedu.com

mageedu@admin.com

 

touch index.txt

echo 01 > serial

 

172.16.54.1

yum install mod_ssl

mkdir ssl

cd ssl

 (umask 077; openssl genrsa -out httpd.key 1024)

openssl req -new -key httpd.key -out httpd.csr 

 

CN

beijing

beijing

magedu

ops

www2.magedu.com    

magedu@admin.com    

 

scp httpd.csr 172.16.54.2:/tmp

openssl ca -in /tmp/httpd.csr -out /etc/pki/CA/certs/httpd.crt

 

scp certs/httpd.crt 172.16.54.1:/etc/httpd/ssl/

 

vim /etc/httpd/conf.d/ssl.conf 

DocumentRoot "/data/vhost/www2/myadmin"       

ServerName www2.magedu.com:443            

SSLCertificateFile /etc/httpd/ssl/httpd.crt      

SSLCertificateKeyFile /etc/httpd/ssl/httpd.key  

 

 

 

<VirtualHost _default_:443>

ProxyPassMatch ^/(.*\.php)$ fcgi://172.16.54.2:9000/data/vhost/www2/$1

 

openssl s_client -connect 172.16.54.1:443 -CAfile /etc/pki/CA/cacert.pem

           

 

ab -c 100 -n 1000 http://www1.magedu.com/data/vhost/www1/index.html        靜態數據

Time per request:       22.433 [ms] (mean)      Time per request:       0.231 [ms] (mean, across all concurrent requests)

Transfer rate:          1855.00 [Kbytes/sec] received

 


 


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章