httpd-2.4.25 + mariadb-5.5.54 + php-5.5.33编译安装过程(单机)
-
编译安装apache
-
编译安装apr
[root@localhost ~]# tar -xf apr-1.5.2.tar.gz
[root@localhost ~]# cd apr-1.5.2
[root@localhost apr-1.5.2]# ./configure –prefix=/usr/local/apr
[root@localhost apr-1.5.2]# make && make install
-
编译安装apr-util
[root@localhost ~]# tar xf apr-util-1.5.4.tar.gz
[root@localhost ~]# cd apr-util-1.5.4
[root@localhost ~]# tar xf apr-util-1.5.4.tar.gz
[root@localhost ~]# cd apr-util-1.5.4
[root@localhost apr-util-1.5.4]# ./configure –prefix=/usr/local/apr-util –with-apr=/usr/local/apr
[root@localhost apr-util-1.5.4]# make && make install [root@localhost apr-util-1.5.4]# make && make install
-
安装pcre-devel
[root@localhost ~]# yum -y install pcre-devel
-
安装 openssl-devel
[root@localhost ~]# yum -y install openssl-devel
-
安装apache
[root@localhost ~]# groupadd -r apache
[root@localhost ~]# useradd -r apache -g apache
####[root@localhost apr-util-1.5.4]# ./configure –prefix=/usr/local/apache –sysconf=/etc/httpd24 –enable-so –enable-ssl –enable-cgi –enable-rewrite –with-zlib –with-pcre –with-apr=/usr/local/apr –with-apr-util=/usr/local/apr-util/ –enable-modules=most –enable-mpms-shared=all –with-mpm=prefork
####[root@localhost apr-util-1.5.4]# ./configure –prefix=/usr/local/apache –sysconfdir=/etc/httpd24 –enable-so –enable-ssl –enable-cgi –enable-rewrite –with-zlib –with-pcre –with-apr=/usr/local/apr –with-apr-util=/usr/local/apr-util –enable-modules=most –enable-mpms-shared=all –with-mpm=event
-
[root@localhost httpd-2.4.25]# make && make install
-
启动服务
[root@localhost httpd-2.4.25]# /usr/local/apache/bin/apachectl start
-
httpd环境变量
[root@localhost httpd-2.4.25]# vim /etc/profile.d/httpd.sh
写入:
export PATH=”/usr/local/apache/bin/:${PATH}”
[root@localhost httpd-2.4.25]# . /etc/profile.d/httpd.sh
[root@localhost httpd-2.4.25]# which httpd
/usr/local/apache/bin/httpd
-
修改httpd 启动脚本
修改一下参数:
apachectl=/usr/local/apache/bin/apachectl
httpd=/usr/local/apache/bin/httpd
prog=httpd
pidfile=/usr/local/apache/logs/httpd24.pid
lockfile=${LOCKFILE-/var/lock/subsys/httpd24}
-
安装程序脚本
[root@localhost httpd24]# chkconfig –add httpd
[root@localhost httpd24]# chkconfig –list httpd
httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@localhost httpd24]# chkconfig httpd –level 2345 on
[root@localhost httpd24]# chkconfig –list httpd
httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
-
安装mysql-5.5.33
-
创建mysql用户与组
[root@localhost mysql]# groupadd -r mysql
[root@localhost mysql]# useradd -r mysql -g mysql
-
下载mysql安装包
[root@repo ~]# wget http://mirrors.tuna.tsinghua.edu.cn/mariadb//mariadb-5.5.54/bintar-linux-x86_64/mariadb-5.5.54-linux-x86_64.tar.gz -c
-
创建数据库目录
[root@localhost ~]# mkdir -pv /mydata/data
[root@localhost mysql]# chown mysql:mysql /mydata -R
-
解压mariadb
[root@localhost ~]# tar xf mariadb-5.5.54-linux-x86_64.tar.gz -C /usr/local/
[root@localhost mysql]# chown -R root:mysql /usr/local/mysql/
root@localhost local]# ln -sv mariadb-5.5.54-linux-x86_64 mysql
`mysql’ -> `mariadb-5.5.54-linux-x86_64′
[root@localhost local]# cd mysql
[root@localhost mysql]# ls
-
运行mysql安装脚本
[root@localhost mysql]# scripts/mysql_install_db –datadir=/mydata/data –user=mysql
-
安装系统启动脚本
[root@localhost mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
[root@localhost mysql]# chkconfig –add mysqld
[root@localhost mysql]# chkconfig –list mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@localhost mysql]# chkconfig mysqld –level 2345 on
[root@localhost mysql]# chkconfig –list mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
-
安装mysql配置文件
[root@localhost mysql]# mkdir -pv /etc/mysql
mkdir: created directory `/etc/mysql’
[root@localhost mysql]# cp support-files/my-large.cnf /etc/mysql/my.cnf
[root@localhost mysql]# vim /etc/mysql/my.cnf
在[mysqld]段加入
-
datadir = /mydata/data
innodb_file_per_table = on
skip_name_resolve = on
-
启动mysqld
[root@localhost mysql]# service mysqld start
Starting MySQL.170217 19:07:11 mysqld_safe Logging to ‘/var/log/mysqld.log’.
170217 19:07:11 mysqld_safe Starting mysqld daemon with databases from /mydata/data
.. SUCCESS!
-
安装帮助文档
[root@localhost mysql]# vim /etc/man.config
加入:
MANPATH /usr/local/mysql/man/man
-
输出头文件
[root@localhost mysql]# ln -sv /usr/local/mysql/include /usr/include/mysql
`/usr/include/mysql’ -> `/usr/local/mysql/include’
-
导出mysql环境变量
[root@localhost mysql]# vim /etc/profile.d/mysql.sh
加入:
export PATH=”/usr/local/mysql/bin/:${PATH}”
[root@localhost mysql]# . /etc/profile.d/mysql.sh
-
安全初始化mysql
[root@localhost mysql]# mysql_secure_installation
Set root password? [Y/n] y
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] n 一般不允许root远程登陆
Remove test database and access to it? [Y/n] n
Reload privilege tables now? [Y/n] y
Mysql 安装完成
-
编译安装php-5.5.38
-
bzip2-devel libxml2-devel
[root@localhost ~]# yum -y install bzip2-devel libxml2-devel
[root@localhost ~] wget http://jp2.php.net/distributions/php-5.4.24.tar.bz2
-
安装libmcrypt, libmcrypt-devel, and mcrypt 哎,这三个包都必须安而且必须解决倚赖关系,很多网上编译文档都没有说,最后官方找到答案编译不再报错。!~~~哥哥这个还是弄了半天的,写出来希望能帮助到大家。
[root@localhost ~]#wget https://mirrors.aliyun.com/epel/6/x86_64/libmcrypt-2.5.8-9.el6.x86_64.rpm
[root@localhost ~]#wget https://mirrors.aliyun.com/epel/6/x86_64/libmcrypt-devel-2.5.8-9.el6.x86_64.rpm
[root@localhost ~]#wget
https://mirrors.aliyun.com/epel/6/x86_64/mhash-0.9.9.9-3.el6.x86_64.rpm
[root@localhost ~]#wget https://mirrors.aliyun.com/epel/6/x86_64/mcrypt-2.6.8-10.el6.x86_64.rpm
[root@localhost ~] rpm -ivh libmcrypt-2.5.8-9.el6.x86_64.rpm
[root@localhost ~]# rpm -ivh libmcrypt-devel-2.5.8-9.el6.x86_64.rpm
[root@localhost ~]# rpm –ivh mhash-0.9.9.9-3.el6.x86_64.rpm
[root@localhost ~]# rpm –ivh mcrypt-2.6.8-10.el6.x86_64.rpm
[root@localhost ~]# rpm –ivh mhash-0.9.9.9-3.el6.x86_64.rpm
-
编译安装php
[root@localhost ~]#wget http://jp2.php.net/distributions/php-5.5.38.tar.bz2
[root@localhost ~]# tar -xf php-5.5.38.tar.bz2
-
[root@localhost ~]# cd php-5.5.38
[root@localhost php-5.5.38]# make 建议多开几个进程,好慢哦!!~~~~~
[root@localhost php-5.5.38]#make test
[root@localhost php-5.5.38]#make install
-
为php提供配置文件:
[root@localhost php-5.5.38]# cp php.ini-production /etc/php.ini
-
编辑apache配置文件httpd.conf,以apache支持php
# vim /etc/httpd/httpd.conf
1、添加如下二行
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
2、定位至DirectoryIndex index.html
修改为:
DirectoryIndex index.php index.html
而后重新启动httpd,或让其重新载入配置文件即可测试php是否已经可以正常使用。
-
测试页面index.php示例如下:
<?php
$link = mysql_connect(‘127.0.0.1′,’root’,’mageedu’);
if ($link)
echo “Success…”;
else
echo “Failure…”;
mysql_close();
?>
-
压力测试以及优化xcache测试
-
安装phpmyadmin做ab
Total transferred: 1094900 bytes
HTML transferred: 947800 bytes
Requests per second: 30.79 [#/sec] (mean)
Time per request: 649.614 [ms] (mean)
Time per request: 32.481 [ms] (mean, across all concurrent requests)
Transfer rate: 329.19 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 10 85 89.0 45 346
Processing: 96 492 236.7 486 941
Waiting: 77 458 227.8 467 885
Total: 138 577 250.9 591 1017
-
安装xcache
-
下载xcache 安装
-
[root@localhost ~]#wget http://xcache.lighttpd.net/pub/Releases/3.2.0/xcache-3.2.0.tar.gz
[root@localhost xcache-3.2.0]# /usr/local/php/bin/phpize 生成configure
[root@localhost xcache-3.2.0]# ./configure –enable-xcache –with-php-config=/usr/local/php/bin/php-config
[root@localhost xcache-3.2.0]# make && make install
安装结束时,会出现类似如下行:
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-zts-20121212/
-
编辑php.ini,整合php和xcache:
首先将xcache提供的样例配置导入php.ini
[root@localhost ~]#mkdir /etc/php.d
[root@localhost xcache-3.2.0]# cp xcache.ini /etc/php.d
说明:xcache.ini文件在xcache的源码目录中。
接下来编辑/etc/php.d/xcache.ini,找到zend_extension开头的行,修改为如下行:
zend_extension = /usr/local/php/lib/php/extensions/no-debug-zts-20100525/xcache.so
注意:如果php.ini文件中有多条zend_extension指令行,要确保此新增的行排在第一位。
[xcache-common]
;; non-Windows example:
extension = /usr/local/php/lib/php/extensions/no-debug-zts-20121212/xcache.so
;; Windows example:
; extension = php_xcache.dll
-
启用服务器状态
mod_status模块可以让管理员查看服务器的执行状态,它通过一个HTML页面展示了当前服务器的统计数据。这些数据通常包括但不限于:
-
处于工作状态的worker进程数;
-
空闲状态的worker进程数;
-
每个worker的状态,包括此worker已经响应的请求数,及由此worker发送的内容的字节数;
-
当前服务器总共发送的字节数;
-
服务器自上次启动或重启以来至当前的时长;
-
平均每秒钟响应的请求数、平均每秒钟发送的字节数、平均每个请求所请求内容的字节数;
启用状态页面的方法很简单,只需要在主配置文件中添加如下内容即可:
<Location /server-status>
SetHandler server-status
Require all granted
</Location>
-
安装xcache后的压力测试
电脑配置不行,两台电脑之间带宽也不高,但是看procession还是有优化的效果。
-