天天看点

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

$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

 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

在重启服务,浏览器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 

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 

servername www2.magedu.com

documentroot "/data/vhost/www2"

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

<directory "/data/vhost/www2">

   options none

  allowoverride none

  require all granted

   </directory>

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>

$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

magedu

ops

ca.magedu.com

[email protected]

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 

www2.magedu.com    

[email protected]    

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

下一篇: httpd