设为首页 收藏本站
查看: 722|回复: 0

[经验分享] CentOS 7, lamp (module)

[复制链接]

尚未签到

发表于 2019-2-17 07:18:21 | 显示全部楼层 |阅读模式
  CentOS 7, lamp (module);
  要求:(1) 三者分离于两台主机;
           (2) 一个虚拟主机用于提供phpMyAdmin;另一个虚拟主机用于提供wordpress;
           (3) xcache
           (4) 为phpMyAdmin提供https虚拟主机;
  主机1:192.168.2.110
  apache+php
  主机2:192.168.2.111
  mariadb
  一、在主机1上安装httpd、php、php-mysql
[root@localhost ~]# yum install -y httpd php php-mysql  二、创建网站路径目录
[root@localhost ~]# mkdir -pv /www/htdocs/web{1,2}  三、在httpd上配置虚拟主机
[root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf

        ServerName pma.mylinuxops.com
        DocumentRoot /www/htdocs/web1
        
                Options none
                AllowOverRide none
                Require all granted
        


        ServerName wp.mylinuxops.com
        DocumentRoot /www/htdocs/web2
        
                Options none
                AllowOverRide none
                Require all granted
        
  四、检查配置文件是否有语法错误,启动httpd
[root@localhost ~]# httpd -t
[root@localhost ~]# systemctl start httpd  五、在主机2上安装mariadb,启动mariadb,创建用于pma及wp的用户账号
[root@localhost ~]# yum install -y mariadb-server
[root@localhost ~]# systemctl start mariadb
[root@localhost ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.56-MariaDB MariaDB Server
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> CREATE USER 'pmauser'@'192.168.2.110' IDENTIFIED BY 'magedu';
Query OK, 0 rows affected (0.01 sec)
MariaDB [(none)]> CREATE USER 'wpuser'@'192.168.2.110' IDENTIFIED BY 'magedu';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> exit
Bye  六、测试LAMP链接
[root@localhost ~]# vim /www/htdocs/web1/index.php
  七、安装phpMyAdmin
  (1)解压phpMyAdmin,并将解压出的文件复制到网站根目录下
[root@localhost ~]# unzip phpMyAdmin-4.0.10.20-all-languages.zip
[root@localhost ~]# cp -a phpMyAdmin-4.0.10.20-all-languages /www/htdocs/web1
[root@localhost web1]# ln -sv /www/htdocs/web1/phpMyAdmin-4.0.10.20-all-languages /www/htdocs/web1/pma
"/www/htdocs/web1/pma" -> "/www/htdocs/web1/phpMyAdmin-4.0.10.20-all-languages"  (2)修改配置文件
[root@localhost web1]# cd pma
[root@localhost pma]# cp config.sample.inc.php config.inc.php  
[root@localhost pma]# vim config.inc.php
cfg['Servers'][$i]['host'] = '192.168.2.111'; 将主机指向mysql服务器  (3)安装php-mbstring
[root@localhost web1]# yum install -y php-mbstring
    (4)重启httpd服务

[root@localhost web1]# systemctl restart httpd
    (5)测试


八、安装wordpress

    (1)解压wordpress,并复制到网站目录下

[root@localhost ~]# tar -xf wordpress-4.9.4-zh_CN.tar.gz
[root@localhost ~]# cp -a wordpress /www/htdocs/web2/
    (2)修改配置文件

[root@localhost wordpress]# cp wp-config-sample.php wp-config.php
[root@localhost wordpress]# vim wp-config.php
/** WordPress数据库的名称 */
define('DB_NAME', 'wpdb');
/** MySQL数据库用户名 */
define('DB_USER', 'wpuser');
/** MySQL数据库密码 */
define('DB_PASSWORD','magedu');
/** MySQL主机 */
define('DB_HOST', '192.168.2.111');
    (3)在mysql服务器上创建数据库并授权

[root@localhost ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 14
Server version: 5.5.56-MariaDB MariaDB Server
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create database wpdb;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> USE wpdb
Database changed
MariaDB [wpdb]> GRANT ALL ON wpdb TO 'wpuser'@'192.168.2.110';
Query OK, 0 rows affected (0.01 sec)
MariaDB [wpdb]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
MariaDB [wpdb]> exit
Bye
    (5)测试




九、安装xcache

    (1)未安装xcache时进行测试

[root@localhost wordpress]# ab -c 200 -n 10000 pma.mylinuxops.com/pma
This is ApacheBench, Version 2.3
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking pma.mylinuxops.com (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests
Server Software:        Apache/2.4.6
Server Hostname:        pma.mylinuxops.com
Server Port:            80
Document Path:          /pma
Document Length:        238 bytes
Concurrency Level:      200
Time taken for tests:   7.286 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Non-2xx responses:      10000
Total transferred:      4780000 bytes
HTML transferred:       2380000 bytes
Requests per second:    1372.57 [#/sec] (mean)
Time per request:       145.712 [ms] (mean)
Time per request:       0.729 [ms] (mean, across all concurrent requests)
Transfer rate:          640.71 [Kbytes/sec] received
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   11  86.2      5    3018
Processing:    14   80 285.2     60    7231
Waiting:        1   78 285.2     58    7231
Total:         31   91 298.6     65    7247
Percentage of the requests served within a certain time (ms)
  50%     65
  66%     69
  75%     71
  80%     72
  90%     80
  95%     89
  98%    269
  99%    470
100%   7247 (longest request)  (2)安装xcache并测试
[root@localhost wordpress]# yum install -y php-xcache
[root@localhost wordpress]# systemctl restart httpd
[root@localhost wordpress]# ab -c 200 -n 10000 pma.mylinuxops.com/pma
This is ApacheBench, Version 2.3
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking pma.mylinuxops.com (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests
Server Software:        Apache/2.4.6
Server Hostname:        pma.mylinuxops.com
Server Port:            80
Document Path:          /pma
Document Length:        238 bytes
Concurrency Level:      200
Time taken for tests:   4.907 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Non-2xx responses:      10000
Total transferred:      4780000 bytes
HTML transferred:       2380000 bytes
Requests per second:    2037.87 [#/sec] (mean)
Time per request:       98.142 [ms] (mean)
Time per request:       0.491 [ms] (mean, across all concurrent requests)
Transfer rate:          951.27 [Kbytes/sec] received
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   23   7.4     22      53
Processing:    26   74  14.3     71     290
Waiting:        1   64  14.7     62     280
Total:         41   97  14.4     94     325
Percentage of the requests served within a certain time (ms)
  50%     94
  66%     99
  75%    105
  80%    107
  90%    113
  95%    117
  98%    121
  99%    127
100%    325 (longest request)  十、为pma提供https
  (1) 为服务器申请数字证书;

  (a) 创建私有CA
[root@localhost wordpress]# cd /etc/pki/CA
[root@localhost CA]# (umask 077; openssl genrsa -out private/cakey.pem 2048)
Generating RSA private key, 2048 bit long modulus
...................................................................+++
...............................................................................................................+++
e is 65537 (0x10001)
[root@localhost CA]# openssl req -new -x509 -key private/cakey.pem -out cacert.pem -days 3650
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:CN
State or Province Name (full name) []:Shanghai
Locality Name (eg, city) [Default City]:Shanghai
Organization Name (eg, company) [Default Company Ltd]:mylinuxops
Organizational Unit Name (eg, section) []:ops
Common Name (eg, your name or your server's hostname) []:ca.mylinuxops.com
Email Address []:caadmin.mylinuxops.com
[root@localhost CA]# touch serial index.txt
[root@localhost CA]# echo 01 > serial  (b) 在服务器创建证书签署请求
[root@localhost CA]# cd /etc/httpd/
[root@localhost httpd]# mkdir ssl
[root@localhost httpd]# cd ssl
[root@localhost ssl]# (umask 077; openssl genrsa -out httpd.key 1024)
Generating RSA private key, 1024 bit long modulus
......................++++++
.................++++++
e is 65537 (0x10001)
[root@localhost ssl]# openssl req -new -key httpd.key -out httpd.csr
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:CN
State or Province Name (full name) []:Shanghai
Locality Name (eg, city) [Default City]:Shanghai
Organization Name (eg, company) [Default Company Ltd]:mylinuxops
Organizational Unit Name (eg, section) []:ops
Common Name (eg, your name or your server's hostname) []:pma.mylinuxops.com
Email Address []:pmadmin@mylinuxops.com
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:  (c) CA签证
[root@localhost ssl]# cd /etc/pki/CA/
[root@localhost CA]# openssl ca -in /etc/httpd/ssl/httpd.csr -out certs/httpd.crt
Using configuration from /etc/pki/tls/openssl.cnf
Check that the request matches the signature
Signature ok
Certificate Details:
        Serial Number: 1 (0x1)
        Validity
            Not Before: Apr 14 05:42:48 2018 GMT
            Not After : Apr 14 05:42:48 2019 GMT
        Subject:
            countryName               = CN
            stateOrProvinceName       = Shanghai
            organizationName          = mylinuxops
            organizationalUnitName    = ops
            commonName                = pma.mylinuxops.com
            emailAddress              = pmadmin@mylinuxops.com
        X509v3 extensions:
            X509v3 Basic Constraints:
                CA:FALSE
            Netscape Comment:
                OpenSSL Generated Certificate
            X509v3 Subject Key Identifier:
                84:1A:5D:C1:73:2A:B2:17:F9:5E:18:5F:2C:85:C3:6A:A6:83:9D:B5
            X509v3 Authority Key Identifier:
                keyid:E4:00:05:49:AF:4D:2A:44:92:9C:B7:FD:63:E2:D5:7A:6F:54:84:6E
Certificate is to be certified until Apr 14 05:42:48 2019 GMT (365 days)
Sign the certificate? [y/n]:y
1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated  (2) 配置httpd支持使用ssl,及使用的证书;

[root@localhost ssl]# yum -y install mod_ssl  配置文件:/etc/httpd/conf.d/ssl.conf

DocumentRoot "/www/htdocs/web1/"
ServerName pma.mylinuxops.com:443
        
                options followsymlinks
                allowOverRide none
                require all granted
        
SSLCertificateFile /etc/httpd/ssl/httpd.crt
SSLCertificateKeyFile /etc/httpd/ssl/httpd.key



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-673330-1-1.html 上篇帖子: CentOS 架设DHCP服务 下篇帖子: CentOS5、6的启动流程
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表