Centos 7.0 編譯安裝LAMP(Linxu+apache+mysql+php)之源碼安裝php (三)
PHP簡介:
PHP(外文名:PHP: Hypertext Preprocessor,中文名:“超文本預處理器”)是一種通用開源腳本語言。語法吸收了C語言、Java和Perl的特點,利於學習,使用廣泛,主要適用於Web開發領域。PHP 獨特的語法混合了C、Java、Perl以及PHP自創的語法。它可以比CGI或者Perl更快速地執行動態網頁。用PHP做出的動態頁面與其他的編程語言相比,PHP是將程序嵌入到HTML(標準通用標記語言下的一個應用)文檔中去執行,執行效率比完全生成HTML標記的CGI要高許多;PHP還可以執行編譯後代碼,編譯可以達到加密和優化代碼運行,使代碼運行更快。。
安裝環境:
系統: centos 7.0 最小化安裝
軟件:php
依賴包:libXpm-devel、fontconfig-devel、libvpx-devel、libgpeg-devel、libxml2-devel 、t1lib-devel、libpng-devel
安裝PHP
yum 安裝依賴包
[[email protected] src]yum install -y libXpm-devel fontconfig-devel libvpx-devel libgpeg-devel libxml2-devel t1lib-devel
添加用戶、組,並分配權限
groupadd www
useradd www –g www -s /bin/false #創建用戶www並加入到組,不允許www用戶直接登錄系統
安裝依賴包yasm
[[email protected] src]tar zxvf yasm-1.2.0.tar.gz #解壓文件
[[email protected] src]# cd yasm-1.2.0
[[email protected] yasm-1.2.0]# ./configure #編譯
[[email protected] src]make && make install
安裝Libcrypt
[[email protected] src] tar -zxf libmcrypt-2.5.8.tar.gz #解壓文件
[[email protected] src]# cd libmcrypt-2.5.8
[[email protected] libmcrypt-2.5.8]# ./configure #編譯
[[email protected] libmcrypt-2.5.8]make && make install #安裝
安裝tiff
[[email protected] src]tar -zxf tiff-4.0.3.tar.gz #解壓文件
[[email protected] src]# cd tiff-4.0.3
[[email protected] tiff-4.0.3]# ./configure #編譯
[[email protected] tiff-4.0.3]make && make install #安裝
安裝libpng
[[email protected] src]tar -zxf libpng-1.6.28.tar.gz #解壓文件
[[email protected] src]# cd libpng-1.6.28
[[email protected] libpng-1.6.28]# ./configure #編譯
[[email protected] libpng-1.6.28]make && make install #安裝
安裝freetype
[[email protected] src]tar -zxf freetype-2.5.3.tar.gz #解壓文件
[[email protected] src]# cd freetype-2.5.3
[[email protected] freetype-2.5.3]# ./configure #編譯
[[email protected] freetype-2.5.3]make && make install #安裝
./configure--prefix=/usr/local/tiff --enable-shared
make
make install
5、安裝libpng
cd /usr/local/src
tar zxvflibpng-1.6.12.tar.gz
cd libpng-1.6.12
./configure--prefix=/usr/local/libpng --enable-shared
make
make install
6、安裝freetype
cd /usr/local/src
tar zxvffreetype-2.5.3.tar.gz
cd freetype-2.5.3
./configure--prefix=/usr/local/freetype --enable-shared
make #編譯
makeinstall #安裝
7、安裝jpeg
cd /usr/local/src
tar zxvfjpegsrc.v9a.tar.gz
cd jpeg-9a
./configure--prefix=/usr/local/jpeg --enable-shared
make #編譯
makeinstall #安裝
8、安裝libgd
cd /usr/local/src
tarzxvf libgd-2.1.0.tar.gz #解壓
cdlibgd-2.1.0 #進入目錄
./configure --prefix=/usr/local/libgd --enable-shared--with-jpeg=/usr/local/jpeg --with-png=/usr/local/libpng--with-freetype=/usr/local/freetype --with-fontconfig=/usr/shared/ --with-xpm=/usr/ --with-tiff=/usr/local/tiff--with-vpx=/usr/ #配置
make #編譯
makeinstall #安裝
初始化數據庫
[[email protected] mysql-5.6.19]cd /usr/local/mysql
[[email protected] mysql]./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql--datadir=/data/mysql #生成mysql系統數據庫
scripts/mysql_install_db 錯誤:提示/usr/bin/perl: 壞的解釋器: 沒有那個文件或目錄
解決:yum install -y perl-Module-Install.noarch
復制啟動腳本,讓其可以使用service起停
[[email protected] mysql-5.6.19] cp ./support-files/mysql.server /rc.d/init.d/httpd #復制啟動本到啟動目錄下
[[email protected] mysql-5.6.19] chmod 755 -R /etc/rc.d/init.d/mysqld
[[email protected] mysql-5.6.19]vi /etc/rc.d/init.d/mysqld #編輯啟動mysqld文
basedir=/usr/local/mysql #MySQL程序安裝路徑
datadir=/data/mysql #MySQl數據庫存放目錄
:wq! #保存退出
[[email protected] mysql-5.6.19]service mysqld start #啟動
[[email protected] mysql-5.6.19]chkconfig mysqld on #加入開機啟動列表
[[email protected] mysql-5.6.19]echo ‘export PATH=$PATH:/usr/local/mysql/bin‘ >>/etc/profile #把mysql服務加入系統環境變量:在最後添加下面這一行export PATH=$PATH:/usr/local/mysql/bin
source /etc/profile #使配置立刻生效
調整文件權限
chmod -R 755 /usr/local/mysql/
chown -R mysql:mysql /usr/local/mysql/ #分配讀寫權限及所屬組權限
添加相關鏈接
ln -s /usr/local/mysql/my.cnf /etc/my.cnf #添加到/etc目錄的軟連
ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock #添加軟鏈接
mysql_secure_installation #設置Mysql密碼,根據提示輸入2次密碼
驗證mysql安裝:
[[email protected] mysql]# mysql -u root -p #登陸確認
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 5.6.19 Source distribution
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
mysql>
[[email protected] mysql]# chkconfig --list
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[[email protected] mysql]# service mysqld status # 服務啟動狀態
SUCCESS! MySQL running (3583)
至此 ,該Apache 服務安裝完成 ,後續將繼續為LAMP服務器安裝mysql服務 ,請看下文 Centos 7.0 編譯安裝LAMP(Linxu+apache+mysql+php)之源碼安裝php (三)
本文出自 “ITCol_XiaoYu” 博客,請務必保留此出處http://itcolxiaoyu.blog.51cto.com/11439802/1942612
Centos 7.0 編譯安裝LAMP(Linxu+apache+mysql+php)之源碼安裝php (三)