码迷,mamicode.com
首页 > Web开发 > 详细

编译安装实现php-admin和WordPress

时间:2019-02-09 00:55:22      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:doc   errno   数据   fish   服务   http   percent   null   9.4   

1.编译安装http

1.准备好文件apr-1.6.5.tar.bz2 httpd-2.4.38.tar.bz2 apr-util-1.6.1.tar.bz2并安装如下包

[root@centos7 install]#yum groupinstall "development tools"
[root@centos7 install]#yum install openssl-devel pcre-devel expat-devel 

2.解压文件到当前文件夹

 [root@centos7 install]tar xvf apr-1.6.5.tar.bz2  
 [root@centos7 install] tar xvf   apr-util-1.6.1.tar.bz2 
  [root@centos7 install]tar xvf  httpd-2.4.38.tar.bz2

3.移动文件夹,把apr 和apr-util 拷贝进去httpd文件夹中一起编译

    [root@centos7 install]#cp -r apr-1.6.5 httpd-2.4.38/srclib/apr
[root@centos7 install]#cp -r apr-util-1.6.1 httpd-2.4.38/srclib/apr-util

4.编译安装httpd

 [root@centos7 httpd-2.4.38]#  ./configure --prefix=/data/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-included-apr --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork
 [root@centos7 httpd-2.4.38]#make -j 4 && make install

5.设置httpd环境变量

[root@centos7 httpd-2.4.38]#echo PATH=/data/httpd24/bin:${PATH} > /etc/profile.d/lamp.sh  
[root@centos7 httpd-2.4.38]#. /etc/profile.d/lamp.sh  
[root@centos7 httpd-2.4.38]#echo $PATH
/data/httpd24/bin:/app/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

6.添加apache用户

[root@centos7 httpd-2.4.38]#useradd -r  –m –d /data/httpd24/ -s /sbin/nologin
[root@centos7 httpd-2.4.38]#chown  -R apache:apache /data/httpd24/

7.修改/data/httpd24/conf/httpd.conf 配置文件让apache账号运行

User apache
 Group apache

8.设置apache开机启动

[root@centos7 httpd-2.4.38]#ln -s /data/httpd24/bin/apachectl /etc/init.d/httpd 
[root@centos7 httpd-2.4.38]#vim /data/httpd24/bin/apachectl 

9.在apachectl脚本加入

#chkconfig: 2345 10 90
#description: Activates/Deactivates Apache Web Server
[root@centos7 httpd-2.4.38]#chkconfig --add httpd
[root@centos7 httpd-2.4.38]#chkconfig --list

Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.

      If you want to list systemd services use ‘systemctl list-unit-files‘.
      To see services enabled on particular target use
      ‘systemctl list-dependencies [target]‘.

httpd           0:off   1:off   2:on    3:on    4:on    5:on    6:off
netconsole      0:off   1:off   2:off   3:off   4:off   5:off   6:off
network         0:off   1:off   2:on    3:on    4:on    5:on    6:off

10.启动服务测试

[root@centos7 httpd-2.4.38]#apachectl start
[root@localhost ~]# curl 192.168.0.109
<html><body><h1>It works!</h1></body></html>
[root@localhost ~]# curl -I 192.168.0.109
HTTP/1.1 200 OK
Date: Thu, 07 Feb 2019 10:59:57 GMT
Server: Apache/2.4.38 (Unix)
Last-Modified: Mon, 11 Jun 2007 18:53:14 GMT
ETag: "2d-432a5e4a73a80"
Accept-Ranges: bytes
Content-Length: 45
Content-Type: text/html

2.编译安装php-fpm

php-7.1.26.tar.xz
1.安装额外包


[root@centos7 httpd-2.4.38]#yum install libxml2-devel  bzip2-devel libmcrypt-devel

2.解压文件


[root@centos7 install]#tar xvf php-7.1.26.tar.xz 

3.编译安装php

[root@centos7 php-7.1.26]#./configure --prefix=/data/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-mcrypt --with-config-file-path=/etc  --with-config-file-scan-dir=/etc/php.d  --enable-maintainer-zts  --disable-fileinfo  
[root@centos7 php-7.1.26]#make -j 4 && make install

4.拷贝php配置文件


[root@centos7 php-7.1.26]#cp -a php.ini-production  /etc/php.ini

5.拷贝php启动脚本


[root@centos7 php-7.1.26]#cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

6.设置php开机启动

[root@centos7 php-7.1.26]#chkconfig --add php-fpm
[root@centos7 php-7.1.26]#chkconfig --list php-fpm

Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.

      If you want to list systemd services use ‘systemctl list-unit-files‘.
      To see services enabled on particular target use
      ‘systemctl list-dependencies [target]‘.

php-fpm         0:off   1:off   2:on    3:on    4:on    5:on    6:off

7.拷贝php-fpm配置文件

[root@centos7 php-7.1.26]#cd /data/php/etc/
[root@centos7 etc]#ls
pear.conf  php-fpm.conf.default  php-fpm.d
[root@centos7 etc]#cp php-fpm.conf.default php-fpm.conf
[root@centos7 etc]#cp php-fpm.d/www.conf.default php-fpm.d/www.conf

8.配置httpd支持php
取消下面两行的注释

LoadModule proxy_module modules/mod_proxy.so   #支持代理 
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so  #支持fcgi

修改下面行 加主页

<IfModule dir_module>     
DirectoryIndex index.php index.html 
</IfModule>

加下面四行

AddType application/x-httpd-php .php 
AddType application/x-httpd-php-source .phps 
ProxyRequests Off 
ProxyPassMatch  ^/(.*\.php)$ fcgi://127.0.0.1:9000/data/httpd24/htdocs/$1  #所有php处理给本机9000端口(也就是php-fpm)处理

9.启动服务

[root@centos7 etc]#chmod +x /etc/init.d/php-fpm
[root@centos7 etc]#service php-fpm start       
Starting php-fpm  done

10.重启http的服务


[root@centos7 etc]#apachectl restart

11.设置测试文件


[root@centos7 etc]#vim /data/httpd24/htdocs/index.php
   <?php  
   echo date("Y/m/d  H:i:s");  
   phpinfo();   
   ?>

技术图片

3.在192.168.0.112安装mariadb

准备好二进制文件mariadb-10.1.38-linux-systemd-x86_64.tar.gz
1.准备好MySQL用户

[root@localhost ~]# groupadd -r -g 306 mysql                                               
[root@localhost ~]# useradd -r -g 306 -u 306 -m -d /data/mysql -s /sbin/nologin
mysql

2.把文件解压到/usr/local中


[root@localhost ~]# tar xf mariadb-10.1.38-linux-systemd-x86_64.tar.gz -C /usr/local

3.创建文件夹软链接

[root@localhost ~]# cd /usr/local/
[root@localhost local]# ln -s mariadb-10.1.38-linux-systemd-x86_64/ mysql

4.修改文件夹权限


[root@localhost local]#chown -R root:mysql /usr/local/mysql/ 

5.把二进制执行文件加入PATH变量中

[root@localhost local]# echo PATH=/usr/local/mysql/bin:$PATH > /etc/profile.d/mysql.sh
[root@localhost local]# . /etc/profile.d/mysql.sh
[root@localhost local]# echo $PATH
/usr/local/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

6.创建数据库文件

[root@localhost local]# cd /usr/local/mysql
[root@localhost mysql]# ./scripts/mysql_install_db --datadir=/data/mysql -user=mysql
[root@localhost mysql]# ls /data/mysql
aria_log.00000001  aria_log_control  ibdata1  ib_logfile0  ib_logfile1  mysql  performance_schema  test
[root@localhost mysql]# chown -R mysql.mysql /data/mysql

7.准备配置文件


[root@localhost mysql]# cp support-files/my-large.cnf /etc/my.cnf

8.修改配置文件

datadir = /data/mysql
skip_name_resolve = on    禁止主机名解析,建议使用

9.设置启动文件

[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[root@localhost mysql]# chkconfig --list

Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.

      If you want to list systemd services use ‘systemctl list-unit-files‘.
      To see services enabled on particular target use
      ‘systemctl list-dependencies [target]‘.

mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off
netconsole      0:off   1:off   2:off   3:off   4:off   5:off   6:off
network         0:off   1:off   2:on    3:on    4:on    5:on    6:off

10.启动服务

[root@localhost mysql]# service mysqld start                 
Starting mysqld (via systemctl):                           [  OK  ]

11.安全初始化


[root@localhost mysql]# mysql_secure_installation

12.创建测试用户

MariaDB [(none)]> grant all on *.* to test@‘192.168.0.%‘ identified by ‘123456‘; 
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;

13.在192.168.0.109安装php-mysql


[root@centos7 etc]#yum install php-mysql

14.设置测试页面

 root@centos7 ~]#vim /data/httpd24/htdocs/test.php 
<?php 
$mysqli=new mysqli("192.168.0.112","test","123456");                                                            
if(mysqli_connect_errno()){    
echo "Failure";    
$mysqli=null;    
exit; 
}
echo "OK"; 
$mysqli->close(); 
?>

15.测试
技术图片

4.安装phpmyadmin

phpMyAdmin-4.8.5-all-languages.tar.xz
1.解压phpmyadmin,并放在httpd网页文件夹上

[root@centos7 install]#tar -xvf phpMyAdmin-4.8.5-all-languages.tar.xz
[root@centos7 install]#cp -a phpMyAdmin-4.8.5-all-languages/ /data/httpd24/htdocs/phpmyadmin/

2.改名默认配置文件,并修改配置

[root@centos7 phpmyadmin]#cp config.sample.inc.php config.inc.php
$cfg[‘blowfish_secret‘] = ‘sda1254z‘; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */   #修改该随机数
$cfg[‘Servers‘][$i][‘host‘] = ‘192.168.0.112‘; #定义远程访问数据库地址

3.安装模块并重启服务

[root@centos7 phpmyadmin]#yum -y install php-mbstring 
[root@centos7 phpmyadmin]#apachectl restart

4.测试登录http://192.168.0.109/phpmyadmin/
技术图片
技术图片

5.利用phpmyadmin创建wordpress数据库和账号
技术图片技术图片

5.安装WordPress

准备好wordpress-4.9.4-zh_CN.tar.gz
1.解压文件,拷贝到httpd网页文件夹下,并且给定apache权限

[root@centos7 install]#tar xvf wordpress-4.9.4-zh_CN.tar.gz 
[root@centos7 install]#cp -a wordpress/ /data/httpd24/htdocs/
[root@centos7 htdocs]#setfacl -R -m u:apache:rwx wordpress/ #安装完可以回收权限

2.访问网页,安装WordPress
技术图片
3.设置数据库信息
技术图片
4.设置管理信息
技术图片
技术图片
5.查看页面
技术图片
6.查看数据库
技术图片

6.利用xcache加速php

1.先用ab测试测试一下

[root@localhost ~]# ab -c 10 -n 100 http://192.168.0.109/wordpress/
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.0.109 (be patient).....done

Server Software:        Apache/2.4.38
Server Hostname:        192.168.0.109
Server Port:            80

Document Path:          /wordpress/
Document Length:        53063 bytes

Concurrency Level:      10
Time taken for tests:   6.964 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      5332300 bytes
HTML transferred:       5306300 bytes
Requests per second:    14.36 [#/sec] (mean)
Time per request:       696.430 [ms] (mean)
Time per request:       69.643 [ms] (mean, across all concurrent requests)
Transfer rate:          747.72 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   0.6      1       3
Processing:   280  648 109.5    633     855
Waiting:      265  631 109.2    615     840
Total:        283  648 109.3    634     856

Percentage of the requests served within a certain time (ms)
  50%    634
  66%    668
  75%    684
  80%    711
  90%    815
  95%    827
  98%    852
  99%    856
 100%    856 (longest request)

结果Requests per second: 14.36
准备好xcache-3.2.0.tar.bz2
2.解压并安装模块

 [root@centos7 install]#tar xvf xcache-3.2.0.tar.bz2
    [root@centos7 xcache-3.2.0]#yum install php-devel

3.在xcache目录下执行命令生成configure文件

[root@centos7 xcache-3.2.0]#phpize 
Configuring for:
PHP Api Version:         20100412
Zend Module Api No:      20100525
Zend Extension Api No:   220100525

4.编译安装xcache

[root@centos7 xcache-3.2.0]#./configure --enable-xcache --with-php-config=/usr/bin/php-config
[root@centos7 xcache-3.2.0]#make -j 4 && make install

生成模块路径Installing shared extensions: /usr/lib64/php/modules/
5.拷贝xcache配置文件到php配置的文件夹下,并重启php-fpm和httpd服务

[root@centos7 xcache-3.2.0]#cp xcache.ini /etc/php.d/
[root@centos7 php]#apachectl restart
[root@centos7 php]#service php-fpm restart

6.重新测试

[root@localhost ~]# ab -c 10 -n 100 http://192.168.0.109/wordpress/
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.0.109 (be patient).....done

Server Software:        Apache/2.4.38
Server Hostname:        192.168.0.109
Server Port:            80

Document Path:          /wordpress/
Document Length:        53063 bytes

Concurrency Level:      10
Time taken for tests:   5.320 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      5332300 bytes
HTML transferred:       5306300 bytes
Requests per second:    18.80 [#/sec] (mean)
Time per request:       531.999 [ms] (mean)
Time per request:       53.200 [ms] (mean, across all concurrent requests)
Transfer rate:          978.82 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   1.1      1      10
Processing:   179  497  75.3    506     643
Waiting:      169  484  74.0    495     633
Total:        180  498  75.4    507     644

Percentage of the requests served within a certain time (ms)
  50%    507
  66%    529
  75%    540
  80%    550
  90%    556
  95%    590
  98%    607
  99%    644
 100%    644 (longest request)

结果Requests per second: 18.80
访问效率提高了

编译安装实现php-admin和WordPress

标签:doc   errno   数据   fish   服务   http   percent   null   9.4   

原文地址:http://blog.51cto.com/6289984/2348971

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!