LAMP的編譯安裝

一、編譯安裝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/

LAMP的編譯安裝1.jpg

(9) 配置文件的修改cp support-files/my-large.cnf /etc/my.cnf

LAMP的編譯安裝2.jpg

修改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

LAMP的編譯安裝3.jpg

(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

LAMP的編譯安裝4.jpg

(7) . /etc/profile.d/apache.sh

(8) apachectl start

LAMP的編譯安裝5.jpg

出現如下報錯,原來是/etc/hosts文件中沒有寫主機信息

網友解決方案:http://www.cnblogs.com/Anker/p/3355039.html

LAMP的編譯安裝6.jpg

三、安裝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

(0)
178babyhanggege178babyhanggege
上一篇 2016-10-17 08:34
下一篇 2016-10-17 08:34

相關推薦

  • 馬哥教育網絡班20期+第七周博客作業

    1、創建一個10G分區,并格式為ext4文件系統     (1) 要求其block大小為2048,預留空間百分比為2,卷標為MYDATA,默認掛載屬性包含acl fdisk /dev/sdbnp1110Gw[root@llww3317 ~]# mke2fs -t ext…

    Linux干貨 2016-08-02
  • N22-第四周作業

    1、復制/etc/skel目錄為/home/tuser1,要求/home/tuser1及其內部文件的屬組和其它用戶均沒有任何訪問權限。 ~]# cp -r /etc/skel /home/tuser1 ~]# chmod -R go= /home/tuser1/ 2、編輯/etc…

    Linux干貨 2016-09-06
  • 初識varnish

      實驗拓撲 varnish主機    地址192.168.150.137 后端web主機     web1靜態服務192.168.150.138     web2動態服務192.168.150.140 varnish的安裝及開啟 varnish主機: ~]# yum info varni…

    Linux干貨 2017-01-05
  • 圖解 lvs 工作原理

    一.lvs 基本工作流程介紹  如圖1,ipvsadm定義lvs服務監聽的ip和port,并發送給ipvs,而ipvs是工作在netfilter的input鉤子上的程序,當input鏈中有目標ip屬于lvs服務的請求報文時,ipvs就會修改該報文的鏈路,使其不進入用戶空間而直接轉到postrouting鏈上,并轉發給其中一臺real server,…

    Linux干貨 2016-10-30
  • linux計劃任務

    任務計劃的分類: 一次性的任務計劃:只執行一次 周期性的任務計劃:每隔一定的周期去做相同的事情 設置任務計劃功能的工具:at和crontab at:專門處理一次性的計劃任務 crontab:根據定義的周期信息,循環做一些事情 batch:系統自行選擇空閑時間去執行此處指定的任務 At命令: 查看atd狀態和啟動atd服務及其配置文件路徑: centos6:s…

    2017-09-09
  • shell腳本語言的for循環使用方法和案例

    在shell語言中bash是用的最多的,其語法簡單。以指令為核心快速解決常用的問題。所有語言中邏輯控制是必不可少的,它可以幫助我們減少不必要的重復性工作。今天我們就來說說所有語言都會使用的神奇的for循環,學了它以后不僅知道如果規避重復的工作,還能理解程序的運行原理。         for循環是什么?&nb…

    Linux干貨 2017-04-16
欧美性久久久久