您好,登錄后才能下訂單哦!
一、下載源碼包
[root@ceshi ~]# mkdir -p /www/xiazai //新建文件夾
[root@ceshi ~]# cd /www/xiazai //進入放置軟件包目錄
[root@ceshi xiazai]# wget http://mirrors.sohu.com/apache/httpd-2.2.34.tar.gz下載apache
[root@ceshi xiazai]# wget http://mirrors.sohu.com/mysql/MySQL-5.0/mysql-5.0.95-linux-x86_64-glibc23.tar.gz
http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.55-linux2.6-x86_64.tar.gz
[root@ceshi xiazai]# wget http://mirrors.sohu.com/php/php-5.3.27.tar.gz
二、安裝mysql
[root@ceshi xiazai]# tar -zxvf mysql-5.0.95-linux-x86_64-glibc23.tar.gz //解壓
1、把解壓完的數據移動到[root@o20150628102525 xiazai]# mkdir -p /www/server
[root@ceshi xiazai]# mv mysql-5.0.95-linux-x86_64-glibc23 /www/server/mysql //移動到mysql目錄下
[root@ceshi xiazai]# useradd -s /sbin/nologin -M mysql //建立用戶
[root@ceshi xiazai]# cd /www/server/mysql //進入mysql安裝目錄
[root@ceshi mysql]# mkdir -p /www/data/mysqldata //新建數據庫存放地址
[root@ceshi mysql]# chown -R mysql:mysql /www/data/mysqldata //設置mysql數據庫存放目錄權限
[root@ceshi mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/www/data/mysqldata
--user 定義數據庫的所屬主, --datadir 定義數據庫安裝到哪里,建議放到大空間的分區上,這個目錄需要自行創建。這一步驟很關鍵,如果你看到兩個 “OK” 說明執行正確
4、拷貝配置文件
[root@ceshi mysql]# cp support-files/my-large.cnf /etc/my.cnf //拷貝配置文件
5、拷貝啟動腳本文件并修改其屬性
[root@ceshi mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[root@ceshi mysql]# chmod 755 /etc/init.d/mysqld
6、修改啟動腳本
[root@ceshi mysql]# yum install vim*
[root@ceshi mysql]# vim /etc/init.d/mysqld //編輯數據庫主配置文件
需要修改的地方有 “datadir=/data/mysql” (前面初始化數據庫時定義的目錄)
basedir=/www/server/mysql
datadir=/www/data/mysqldata
7、把啟動腳本加入系統服務項,并設定開機啟動,啟動mysql
[root@ceshi mysql]# chkconfig --add mysqld
[root@ceshi mysql]# chkconfig mysqld on
[root@jiahaowu mysql]# service mysqld start
[root@jiahaowu mysql]# netstat -lnp |grep mysql //查看端口是否運行
[root@o20150628102525 mysql]# echo "PATH=$PATH:/www/server/mysql/bin" >> /etc/profile
echo "PATH=$PATH:/www/wdlinux/apache_php-5.6.21/bin" >> /etc/profile
/www/wdlinux/apache_php-5.6.21/bin/
[root@o20150628102525 mysql]# source /etc/profile 設置變量開機加載
#/www/server/mysql/bin/mysqladmin -u root password 75dn289z //設置MySQL密碼
8、測試
[root@o20150628102525 mysql]# shutdown -r now //重啟
[root@o20161209038952 ~]# mysql -uroot -p
三、安裝Apache
首先添加依賴應用
yum install -y gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libpng libpng-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses curl openssl-devel gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel gmp-devel readline-devel libxslt-devel expat-devel xmlrpc-c xmlrpc-c-devel zlib-devel pcre pcre-devel apr apr-devel
yum install gcc zlib-devel openssl-deve
[root@ceshi xiazai]# tar -zxvf httpd-2.2.32.tar.gz //解壓縮包
2、進入目錄
[root@ceshi xiazai]# cd httpd-2.2.32
[root@ceshi httpd-2.2.32]# mkdir -p /www/server新建安裝目錄
3、編譯
[root@o20161209038952 httpd-2.2.31]# ./configure --prefix=/www/server/httpd --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --with-pcre
--prefix 指定安裝到哪里, --enable-so 表示啟用DSO [1] --enable-deflate=shared 表示共享的方式編譯deflate,后面的參數同理。
如果這一步你出現了這樣的錯誤 error: mod_deflate has been requested but can not be built due to prerequisite failures
解決辦法 yum install -y zlib-devel
為了避免在make的時候出現錯誤,所以最好是提前先安裝好一些庫文件
[root@o20161209038952 httpd-2.2.31]## yum install -y pcre pcre-devel apr apr-devel
[root@ceshi httpd-2.2.32]# echo $?
0
[root@ceshi httpd-2.2.32]# make install
[root@o20161209038952 httpd-2.2.31]## echo $?
[root@o20161209038952 httpd-2.2.31]# vi /etc/init.d/httpd新建啟動腳本
[root@iZbp18ekm5cjum3elk9bgaZ httpd-2.2.31]# chmod 775 /etc/init.d/httpd //設置權限
[root@iZbp18ekm5cjum3elk9bgaZ httpd-2.2.31]# chkconfig --add httpd
[root@iZbp18ekm5cjum3elk9bgaZ httpd-2.2.31]# chkconfig httpd on
http://note.youdao.com/noteshare?id=e4485bc811f68e4a70bb8f8be7b1f16b httpd啟動腳本
四、安裝PHP
[root@o20161209038952 httpd-2.2.31]# cd /www/xiazai/
下面我們來 添加 jpeg 格式文件的支持
wget http://y.w-jiahao.cn/by/la/jpegsrc.v8b.tar.gz
tar -zxvf jpegsrc.v8b.tar.gz
cd jpeg-8b
./configure --prefix=/www/server/jpeg --enable-shared --enable-static
make && make install
使用php mcrypt 前必須先安裝Libmcrypt
libmcrypt源碼安裝方法:
cd /www/xiazai
wget http://y.w-jiahao.cn/by/la/libmcrypt-2.5.8.tar.gz
tar -zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure --prefix=/www/server/libmcrypt
make
make install
1、解壓
[root@jiahaowu src]# tar -zxvf php-5.3.27.tar.gz
2、配置參數
[root@o20161209038952 xiazai]# cd php-5.3.27
[root@o20161209038952 php-5.3.27]# ./configure --prefix=/www/server/php --with-apxs2=/www/server/httpd/bin/apxs --with-config-file-path=/www/server/php/etc --with-mysql=/www/server/mysql --with-libxml-dir --with-gd --with-jpeg-dir=/www/server/jpeg--with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt=/www/server/libmcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif --disable-ipv6
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/httpd/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-libxml-dir --with-gd --with-jpeg-dir=/usr/local/jpeg--with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt=/usr/local/libmcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif --disable-ipv6
遇到如下錯誤
configure: error: xml2-config not found. Please check your libxml2 installation.
解決辦法 yum install -y libxml2-devel
configure: error: Cannot find OpenSSL's <evp.h>
解決辦法yum install -y openssl openssl-devel
checking for BZip2 in default path... not found
configure: error: Please reinstall the BZip2 distribution
解決辦法yum install -y bzip2 bzip2-devel
configure: error: png.h not found
解決辦法 yum install -y libpng libpng-devel
configure: error: freetype.h not found.
解決辦法yum install -y freetype freetype-devel
configure: error: mcrypt.h not found. Please reinstall libmcrypt
[root@jiahaowu php-5.3.27]# echo $?
[root@jiahaowu php-5.3.27]# make
報錯:make: *** [ext/fileinfo/libmagic/apprentice.lo] Error 1
解決辦法
這是由于內存小于1G所導致.
在./configure加上選項:
--disable-fileinfo
有時候我們編譯php的時候會出現以下錯誤:
make ***[libphp5.la] Error 1
處理方法:
安裝兩個rpm包#yum -y install libtool.x86_64 libtool-ltdl.x86_64 libtool-ltdl-devel.x86_64
然后make clean;make
[root@jiahaowu php-5.3.27]# echo $?
[root@jiahaowu php-5.3.27]# make install
[root@jiahaowu php-5.3.27]# echo $? ///待續
3、拷貝配置文件
[root@o20161209038952 php-5.3.27]# cp php.ini-production /www/server/php/etc/php.ini 四、apache結合php
Apache主配置文件為:/www/server/httpd/conf/httpd.conf
[root@o20161209038952 php-5.3.27]# vi /www/server/httpd/conf/httpd.conf
找到
<IfModule dir_module>
x
DirectoryIndex index.html
</IfModule>
改為
<IfModule dir_module>
DirectoryIndex index.html index.htm index.php
</IfModule>
找到AddType application/x-gzip .gz .tgz 在下面添加AddType application/x-httpd-php .php 314
找到#ServerName www.example.com:80改為ServerName localhost:80 102
#AllowOverride None改為 AllowOverride All
#Include conf/extra/httpd-vhosts.conf改為Include conf/extra/httpd-vhosts.conf
wq保存
六、測試PHP
[root@jiahaowu conf]# curl localhost 查看是否正常顯示It works!
測試php
[root@iZ30rtw8o80Z conf]#echo "<?php phpinfo();?>" >/www/server/httpd/htdocs/index.php 添加php文檔
http://note.youdao.com/noteshare?id=731fc872a408734d6b1b803a1a3ec193 httpd啟動腳本
初次使用瀏覽器訪問web服務的時候,可能無法訪問,這是因為防火墻的緣故。請運行下面的命令
[root@jiahaowu ~]# iptables -F 關閉防火墻
截圖范:
==============================
curl組件安裝
進入安裝目錄/usr/local/src/php-5.3.27/ext/curl
執行/www/server/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-curl=/usr/local/php/lib/php/extensions
make && make install
在php.ini添加路徑
extension="/usr/local/php/lib/php/extensions/curl.so"
==============================================
Zend安裝
換成:vim /www/server/php/etc/php.ini
[Zend]
zend_extension = /www/server/zujian/ZendGuardLoader.so
zend_loader.enable = 1
配置ionCube:
修改php.ini 在文件尾部添加以下代碼:
[ionCube Loader]
zend_extension="/usr/local/ioncube/ioncube_loader_lin_php5.4.so"
#################################
php添加開啟pdo_mysql擴展模塊
/www/server/php/bin/phpize
./configure --with-php-config=/www/server/php/bin/php-config --with-pdo-mysql=/www/server/mysql
make
make install
手動開啟PDO,在php-ini文件上開啟,連接數據庫用。mysql開啟PDO, 在php.ini加上extension=pdo_mysql.so,extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613", 再重啟php即可
mysqli安裝
/www/server/php/bin/phpize
./configure --with-php-config=/www/server/php/bin/php-config --with-mysqli=/www/server/mysql/bin/mysql_config
make
make install
############################
Redis擴展安裝
wget http://pecl.php.net/get/redis-3.0.0.tgz
mv redis-3.0.0.tgz redis-3.0.0.tar.gz
tar -zxvf redis-3.0.0.tar.gz
cd redis-3.0.0
/www/server/php/bin/phpize
./configure --with-php-config=/www/server/php/bin/php-config
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。