新聞中心
簡單羅列基礎(chǔ)命令,只分享我的想法!
霍州ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場景,ssl證書未來市場廣闊!成為創(chuàng)新互聯(lián)公司的ssl證書銷售渠道,可以享受市場價格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18982081108(備注:SSL證書合作)期待與您的合作!
要求:把php編譯成為httpd的模塊,實(shí)現(xiàn)lamp,并且在httpd上面建立兩個虛擬機(jī),一個用于PHPAdmin,另外一個實(shí)現(xiàn)discuz。
環(huán)境:httpd-2.4.10,apr-1.5.0,apr-until-1.4.1,PHP-5.4.40,mariaDB-5.5.43和CentOS 6.6
一、首先編譯httpd
編譯2.4版本以上的httpd需要首先安裝1.4版本以上的apr和apr-until
1)編譯apr-1.5.0,這個軟件類似于一個php的“虛擬機(jī)”,使用同一種php的代碼都可以在上面運(yùn)行。
./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機(jī)制,動態(tài)裝卸載模塊;--with-zlib:網(wǎng)上實(shí)施壓縮的壓縮庫;--enable-cgi:啟動cgi模塊,主要用于httpd與php之間的通信;--enable-modules:啟用哪些模塊;--enable-ssl:支持ssl功能;--enable-mpms-shared:啟用共享mpm模塊;--with-mpm默認(rèn)啟動的MPM模塊;)
httpd的管理命令加入到PATH
vim /etc/profile.d/httpd.sh PATH=/usr/local/apache/bin:$PATH . /etc/profile.d/httpd.sh
對httpd的include進(jìn)行處理
ln -sv /usr/local/apache/include/ /usr/include/httpd
更新man.config
vim /etc/man.config
添加一行
MANPATH /usr/local/apache/man
創(chuàng)建apache用戶
useradd -r apache
編譯/etc/httpd24/httpd.conf主要配置文件
修改以下兩行,把用戶變?yōu)閍pache
user apache group apache
因?yàn)槲以瓉戆惭b過httpd的rpm包,所以,直接復(fù)制啟動腳本之后進(jìn)行修改
cp /etc/init.d/httpd /etc/init.d/httpd24 vim /etc/init.d/httpd24
修改以下三項(xiàng)即可
apachectl=/usr/local/apache/bin/apachectl httpd=${HTTPD-/usr/local/apache/bin/httpd} pidfile=${PIDFILE-/var/run/httpd.pid}
檢驗(yàn)一下/etc/init.d/httpd24start,看80端口是否啟動。
把httpd24添加到服務(wù)啟動項(xiàng)中
chkconfig --add httpd24 chkconfig httpd24 on
httpd服務(wù)啟動,截圖如下。
圖1
二、通用二進(jìn)制格式安裝MariaDB-5.4.43
1)有的是空間,直接分區(qū),然后把數(shù)據(jù)文件放到新的分區(qū)中,如果想要充分利用空間,可以做LVM,新分區(qū)/dev/sda7,命令如下
pvcreate /dev/sda7 vgcreate myvg /dev/sda7 lvcreate -L 10G -n mylv2 myvg2
格式化
mkfs.ext4 /dev/myvg2/mylv2
掛載,然后可以添加到/etc/fstab中,開機(jī)自動啟動
mount /dev/myvg2/mylv2 /mariadb/mydata/mdat
2)解壓縮MariaDB的安裝包,需要創(chuàng)建一個鏈接/user/local/MySQL指向解壓縮后的安裝包(因?yàn)閴嚎s包中的腳本指向的目錄就是/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
對httpd的include進(jìn)行處理
ln -sv /usr/local/mysql/include/ /usr/include/mysqld
更新man.config
vim /etc/man.config
添加一行
MANPATH /usr/local/mysql/man
把函數(shù)庫添加到系統(tǒng)自動搜索的路徑下面
vim /etc/ld.so.conf.d/mysql.conf
添加一行
/usr/local/mysql/lib
編輯完畢,退出,ldconfig,之后可以通過ldconfig-p | grep "/usr/local/mysql"看是否已經(jīng)加載。
更改安裝目錄的屬主和屬組
cd /usr/local/mysql chown -R root:mysql ./*
更改存放數(shù)據(jù)目錄的屬主和屬組
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
初始化數(shù)據(jù)庫到指定的目錄
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
根據(jù)cpu個數(shù)修改以下一行,線程并發(fā)個數(shù)由來:CPU個數(shù)乘以2
thread_concurrency = 4
添加啟動腳本
cd/usr/local/mysql cp ./support-files/mysql.server /etc/init.d/mysqld43
添加到開機(jī)啟動的服務(wù)中
chkconfig --add mysqld43 chkconfig mysqld43 on
檢驗(yàn)是否啟動,截圖如下
/etc/init.d/mysqld43 start
圖2
三、把php-5.4.40編譯安裝成為httpd的模塊,從而實(shí)現(xiàn)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
刷新網(wǎng)頁即可,截圖如下
圖3
圖4
六、httpd中創(chuàng)建虛擬機(jī)
打開虛擬機(jī)配置文件
vim /etc/httpd24/httpd.conf
修改以下一行
Include /etc/httpd24/extra/httpd-vhosts.conf
編輯httpd-vhosts.conf配置文件
vim /etc/httpd24/extra/httpd-vhosts.conf#[email protected] DocumentRoot"/usr/local/apache/vhost1" ServerName www.a.com #ServerAliaswww.dummy-host.example.com ErrorLog"logs/error_log" CustomLog"logs/access_log" combine AllowOverride None Require all granted #ServerAdmin [email protected] DocumentRoot"/usr/local/apache/vhost2" ServerName www.b.com #ServerAliaswww.dummy-host.example.com ErrorLog"logs/error22_log" CustomLog"logs/access22_log" combine AllowOverride None Require all granted
七、phpAdmin配置(省略,上一篇博客有寫到),此次實(shí)驗(yàn)是通過vhost1顯示,只有截圖。
圖5
八、discuz在vhost2中顯示
1)查看README,如下圖:
圖6
2)修改upload目錄中config和data目錄的權(quán)限
chmod –R 777 config/ data/ uc_client/ uc_server/
3)通過瀏覽器訪問http://www.b.com/upload/install/,如下圖
圖7
4)繼續(xù)下一步進(jìn)行配置
圖8
圖9
有志同道合的“戰(zhàn)友”可以加我qq:865765761。
分享名稱:通過編譯php為httpd的模塊實(shí)現(xiàn)lamp
標(biāo)題鏈接:http://fisionsoft.com.cn/article/goiejj.html