一、編譯安裝amp:
(1)系統環境:centos6,7
httpd依賴于apr和apr-util
appache protable runtime
(2)開發環境:
Development Tools,Server Platform Development
(3)各程序的版本:
httpd:2.2,2.4
php:5.x
mysql:5.1,5.5,5.6,5.7,5.8
mariadb:5.x,10.x
(4)httpd+php
modules:–with-apxs=
prefork:libphp5.so
worker,event:libphp5-zts.so
fpm:
5.3.3-,手動打上fpm patch;
5..3.3+,自帶了fpm,編譯時只需要使用–fpm選項;
過程:
先安裝am,再安裝p
安裝MySQL:
預制的二進制程序包:
os vendor:mariadb-devel或mysql-devel;
項目官方提供的
二進制格式的程序包:展包即用;
源代碼:編譯安裝
第一種安裝:
(1)yum install mariadb-devel
(2)yum install mariadb-server
假如部署mysql時,將http和mysql安裝在不同機器上,那么本臺安裝http的服務器只需安裝好開發環境即可,無需安裝mariadb-server.只在另一臺上安裝mariadb-server即可。
以模塊化安裝,割裂為兩臺主機。以fpm安裝可以分割為三臺主機。
第二種(二進制格式程序安裝):
移除mariadb-server 和mariadb-devel
(1)獲取tar包,創建mysql用戶和組
(2) tar xf mariadb-5.5.46-linux-x86_64.tar.gz -C /usr/local
(3)ln -sv mariadb-5.5.46-linux-x86_64 mysql
數據庫默認存在于data目錄下
(4)改權限:chown -R root:mysql ./*
(5)創建存放數據的文件目錄mkdir -pv /mydata/data
chown mysql:mysql /mydata/data
(6)scripts/mysql_install_db –help
(7)[root@centos7 mysql]# scripts/mysql_install_db –datadir=/mydata/data –user=mysql
(8)ls /mydata/data/
(9) 配置文件的修改cp support-files/my-large.cnf /etc/my.cnf
修改thread_concurrency = 2
datadir=/mydata/data
skip_name_resolve=ON
innodb_file_per_table=ON
其中2指的是CPU的核心數乘以2.
(10)提供mysql運行的腳本cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod +x /etc/rc.d/init.d/mysqld
(11)chkconfig –add mysqld
chkconfig –list
(12)開啟服務service mysqld start
(13)vim /etc/profile.d/mysql.sh
(14) . /etc/profile.d/mysql.sh
二、安裝httpd-2.4
(1) yum groupinstall "Development Tools" "Server Platform Development"
(2)yum install pcre-devel openssl-devel libevent-devel apr-devel apr-util-devel
(3)./configure –prefix=/usr/local/apache2 –sysconfdir=/etc/httpd –enable-so –enable-cgi –enable-modules=most –enable-mpms-shared=all –with-mpm=prefork –with-zlib –with-apr=/usr –with-apr-util=/usr
(4)make
(5)make install
(6)vim /etc/profile.d/apache.sh
(7) . /etc/profile.d/apache.sh
(8) apachectl start
出現如下報錯,原來是/etc/hosts文件中沒有寫主機信息
網友解決方案:http://www.cnblogs.com/Anker/p/3355039.html
三、安裝php5
(1)yum install gd-devel freetype-devel libmcrypt-devel libxml2-devel
(2)./configure –prefix=/usr/local/php –with-mysql –with-openssl –with-mysql=/usr/bin/mysql_config –enable-mbstring –enable-xml –enable-sockets –with-freetype-dir –with-gd –with-libxml-dir=/usr –with-zlib –with-jpeg-dir –with-png-dir –with-mcrypt –with-apx2=/usr/local/apache2/bin/apxs –with-config-file-path=/etc/php.ini –with-config-file-scan-dir=/etc/php.d/
(3)make -J #
(4)make install
(6)cp php.ini-production /etc/php.ini
(7)makedir /etc/php.d/
注意:如果httpd使用線程模型MPM,需要額外的–enable-maintainer-zts選項;
注意:如果要以fpm方式允許php,需要編譯時移除–with-apxs選項。
注意:如果獨立安裝的mysql-server,假設安裝在/usr/local/mysql目錄下,則需要使用類似如下的.configure命令。
./configure –prefix=/usr/local/php –with-mysql=/usr/local/mysql –with-openssl –with-mysql=/usr/local/bin/mysql/mysql_config –enable-mbstring –enable-xml –enable-sockets –with-freetype-dir -with-gd –with-libxml-dir=/usr –with-png-dir –with-apxs2=/usr/local/apache2/bin/apxs –with-config-file-path=/etc/php.ini –with-config-file-scan-dir=/etc/php.d/
整合php
httpd.conf配置文件中:
AddType application/x-httpd-php.php
DirectoryIndex index.php index.html
原創文章,作者:178babyhanggege,如若轉載,請注明出處:http://www.www58058.com/51141