通过编译php为httpd的模块实现lamp

发布时间:2020-07-21 09:15:05 作者:DaMiHua
来源:网络 阅读:655

简单罗列基础命令,只分享我的想法!

要求:把php编译成为httpd的模块,实现lamp,并且在httpd上面建立两个虚拟机,一个用于PHPAdmin,另外一个实现discuz

环境:httpd-2.4.10apr-1.5.0apr-until-1.4.1PHP-5.4.40mariaDB-5.5.43CentOS 6.6

一、首先编译httpd

编译2.4版本以上的httpd需要首先安装1.4版本以上的aprapr-until

1)编译apr-1.5.0,这个软件类似于一个php的“虚拟机”,使用同一种php的代码都可以在上面运行。

./configure --prefix=/usr/local/apr
make && make install

2)编译apr-until-1.4.1

./configure --prefix=/usr/local/apr-util –with-apr=/usr/local/apr
make && make install

3)编译httpd

如果启用pcre功能,需要安装pcre-devel包。

yum install pcre-devel
./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=prefork

(--enable-so:支持DSO机制,动态装卸载模块;--with-zlib:网上实施压缩的压缩库;--enable-cgi:启动cgi模块,主要用于httpdphp之间的通信;--enable-modules:启用哪些模块;--enable-ssl:支持ssl功能;--enable-mpms-shared:启用共享mpm模块;--with-mpm默认启动的MPM模块;)

httpd的管理命令加入到PATH

vim /etc/profile.d/httpd.sh
PATH=/usr/local/apache/bin:$PATH
. /etc/profile.d/httpd.sh

httpdinclude进行处理

ln -sv /usr/local/apache/include/ /usr/include/httpd

更新man.config

vim /etc/man.config

添加一行

MANPATH /usr/local/apache/man

创建apache用户

useradd -r apache

编译/etc/httpd24/httpd.conf主要配置文件

修改以下两行,把用户变为apache

user apache
group apache

因为我原来安装过httpdrpm包,所以,直接复制启动脚本之后进行修改

cp /etc/init.d/httpd /etc/init.d/httpd24
vim /etc/init.d/httpd24

修改以下三项即可

apachectl=/usr/local/apache/bin/apachectl
httpd=${HTTPD-/usr/local/apache/bin/httpd}
pidfile=${PIDFILE-/var/run/httpd.pid}

检验一下/etc/init.d/httpd24start,看80端口是否启动。

httpd24添加到服务启动项中

chkconfig --add httpd24
chkconfig httpd24 on

httpd服务启动,截图如下。

通过编译php为httpd的模块实现lamp

1

二、通用二进制格式安装MariaDB-5.4.43

1)有的是空间,直接分区,然后把数据文件放到新的分区中,如果想要充分利用空间,可以做LVM,新分区/dev/sda7,命令如下

pvcreate /dev/sda7
vgcreate myvg /dev/sda7
lvcreate -L 10G -n mylv2 myvg2

格式化

mkfs.ext4 /dev/myvg2/mylv2

挂载,然后可以添加到/etc/fstab中,开机自动启动

mount /dev/myvg2/mylv2 /mariadb/mydata/mdat

2)解压缩MariaDB的安装包,需要创建一个链接/user/local/mysql指向解压缩后的安装包(因为压缩包中的脚本指向的目录就是/usr/local/mysql)。

ln -sv /root/mariadb-5.5.43-linux-x86_64 /usr/local/mysql

mysql的管理命令加入到PATH

vim /etc/profile.d/mysqld.sh
PATH=/usr/local/mysql/bin:$PATH
. /etc/profile.d/mysqld.sh

httpdinclude进行处理

ln -sv /usr/local/mysql/include/ /usr/include/mysqld

更新man.config

vim /etc/man.config

添加一行

MANPATH /usr/local/mysql/man

把函数库添加到系统自动搜索的路径下面

vim /etc/ld.so.conf.d/mysql.conf

添加一行

/usr/local/mysql/lib

编辑完毕,退出,ldconfig,之后可以通过ldconfig-p | grep "/usr/local/mysql"看是否已经加载。

更改安装目录的属主和属组

cd /usr/local/mysql
chown -R root:mysql ./*

更改存放数据目录的属主和属组

chown -R mysql:mysql /mariadb/mydata/

安装mysql的配置文件,mysql搜索的配置文件依次是/etc/my.cnf->/etc/mysql/my.cnf->~/.my.cnf

mkdir /etc/mysql
cp support-files/my-large.cnf /etc/mysql/my.cnf

初始化数据库到指定的目录

cd /user/local/mysql
./scripts/mysql_install_db --user=mysql --datadir=/mariadb/mydata/

编辑/etc/mysql/my.cnf

vim /etc/mysql/my.cnf

添加以下两行

datadir = /mariadb/mydata
innodb_file_per_table = on

根据cpu个数修改以下一行,线程并发个数由来:CPU个数乘以2

thread_concurrency = 4

添加启动脚本

cd/usr/local/mysql
cp ./support-files/mysql.server /etc/init.d/mysqld43

添加到开机启动的服务中

chkconfig --add mysqld43
chkconfig mysqld43 on

检验是否启动,截图如下

/etc/init.d/mysqld43 start

通过编译php为httpd的模块实现lamp

2

三、把php-5.4.40编译安装成为httpd的模块,从而实现lamp的组合。

1)安装依赖包(devel子包主要是包含一些include文件)

yum install libxml2-devel libmcrypt-devel bzip2-devel –y

2)编译

./configure --prefix=/user/local/php --with-mysql=/usr/local/mysql--with-mysqli=/usr/local/mysql/bin/mysql_config--with-apxs2=/usr/local/apache/bin/apxs --enable-mbstring --with-freetype-dir--with-jpeg-dir --with-zlib --with-libxml-dir=/usr --enable-xml--enable-sockets --with-mcrypt --with-bz2--with-config-file-path=/etc/php/php.ini --with-config-file-scan-dir=/etc/php.d/
make && make install

3)安装主配置文件

mkdir /etc/php
cp php.ini-production /etc/php/php.ini

四、编辑/etc/httpd24/httpd.conf,支持php

vim /etc/httpd24/httpd.conf

添加以下三行

DirectoryIndex index.php index.html
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

五、测试php

1)编辑index.php

vim /usr/local/apache/htdocs/index.php
<?
         phpinfo();
?>

重新启动httpd24

刷新网页即可,截图如下

通过编译php为httpd的模块实现lamp

3

通过编译php为httpd的模块实现lamp

4

六、httpd中创建虚拟机

打开虚拟机配置文件

vim /etc/httpd24/httpd.conf

修改以下一行

Include /etc/httpd24/extra/httpd-vhosts.conf

编辑httpd-vhosts.conf配置文件

vim /etc/httpd24/extra/httpd-vhosts.conf
<VirtualHost 172.16.49.1:80>
    #ServerAdminwebmaster@dummy-host.example.com
    DocumentRoot"/usr/local/apache/vhost1"
    ServerName www.a.com
    #ServerAliaswww.dummy-host.example.com
    ErrorLog"logs/error_log"
    CustomLog"logs/access_log" combine
    <Directory"/usr/local/apache/vhost1">
             AllowOverride None
         Require all granted
    </Directory>
</VirtualHost>
<VirtualHost 172.16.49.1:80>
    #ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot"/usr/local/apache/vhost2"
    ServerName www.b.com
    #ServerAliaswww.dummy-host.example.com
    ErrorLog"logs/error22_log"
    CustomLog"logs/access22_log" combine
    <Directory"/usr/local/apache/vhost2">
             AllowOverride None
         Require all granted
    </Directory>
</VirtualHost>

七、phpAdmin配置(省略,上一篇博客有写到),此次实验是通过vhost1显示,只有截图。

通过编译php为httpd的模块实现lamp

5

八、discuzvhost2中显示

1)查看README,如下图:

通过编译php为httpd的模块实现lamp

6

2)修改upload目录中configdata目录的权限

chmod –R 777 config/ data/ uc_client/ uc_server/

3)通过浏览器访问http://www.b.com/upload/install/,如下图

通过编译php为httpd的模块实现lamp

7

4)继续下一步进行配置

通过编译php为httpd的模块实现lamp

8

通过编译php为httpd的模块实现lamp

9

有志同道合的“战友”可以加我qq865765761


推荐阅读:
  1. 部署httpd+php实现lamp的负载均衡
  2. 编译安装lamp-4(安装xcache,为php加速)

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

php lamp 编译httpd

上一篇:OEL6.8_X86平台部署oracle10gR2检测失败问

下一篇:PHP有哪些关于高并发的面试题

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》