本文作者:不许人间见白头

Lamp(apache2.2mysql5.1php5.3)centos6版本

不许人间见白头 2个月前 ( 12-15 ) 79

本教程使用操作系统Centos6.10

一、下载源码包(如需其他版本请到对应的官网去下载)

# mkdir -p /www/xiazai  //新建下载目录
# cd /www/xiazai     //进入下载目录二、下载编译包
# wget http://mirrors.ahaoyw.com/autoconf/lin/httpd/httpd-2.2.34.tar.gz
# wget  http://mirrors.ahaoyw.com/autoconf/lin/Mysql/mysql-5.1.72-linux-x86_64-glibc23.tar.gz
# wget http://mirrors.ahaoyw.com/autoconf/lin/PHP/php-5.3.29.tar.gz

二、开始编译安装

1、安装mysql

# tar -zxvf mysql-5.1.72-linux-x86_64-glibc23.tar.gz  //解压
# mkdir -p /www/server/   //新建安装目录
# mv mysql-5.1.72-linux-x86_64-glibc23 /www/server/mysql  移动mysql到/www/server/目录下
# useradd -s /sbin/nologin -M mysql  //建立用户
# cd /www/server/mysql  //进入mysql安装目录
# mkdir -p /data/mysqldata  //新建数据库存放地址
# chown -R mysql:mysql /data/mysqldata  //设置mysql数据库存放目录权限
# ./scripts/mysql_install_db --datadir=/data/mysqldata --basedir=/www/server/mysql --user=mysql

--user 定义数据库的所属主, --datadir 定义数据库安装到哪里,建议放到大空间的分区上,这个目录需要自行创建。这一步骤很关键,如果你看到两个 “OK” 说明执行正确

image.png

# cp support-files/my-large.cnf /etc/my.cnf  //拷贝配置文件
# cp support-files/mysql.server  /etc/init.d/mysqld  //拷贝启动文件
# chmod 755 /etc/init.d/mysqld //设置权限
# vim /etc/init.d/mysqld   //编辑数据库主配置文件

如果vim没有安装的话就yum install vim* -y

basedir=/www/server/mysql
datadir=/data/mysqldata

需要修改的地方有 “datadir=/data/mysql” (前面初始化数据库时定义的目录)

把启动脚本加入系统服务项,并设定开机启动,启动mysql

# chkconfig --add mysqld
# chkconfig mysqld on
# service mysqld start

加入系统变量

echo "PATH=$PATH:/www/server/mysql/bin" >> /etc/profile    //加入系统变量
# source /etc/profile   刷新变量开机加载

设置MySQL密码

#/www/server/mysql/bin/mysqladmin -u root password 你要的密码

2、安装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

2.1、开始安装apache

# cd /www/xiazai 进入下载目录
# tar -zxvf httpd-2.2.34.tar.gz   解压httpd包
# cd httpd-2.2.34 进入解压的包

编译configure 

./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,后面的参数同理。

报错解决办法configure failed for srclib/apr

yum -y install gcc make

初始化完成后接下来进行安装

make && make install

配置apache

# vi /etc/init.d/httpd新建启动脚本

脚本内容参考https://www.ahaoyw.com/article/89.html

设置权限

# chmod 775 /etc/init.d/httpd

加入开机启动

#chkconfig --add httpd 

# chkconfig httpd on

3、安装php

# cd /www/xiazai  /添加 jpeg 格式文件的支持  
# wget  http://mirrors.ahaoyw.com/autoconf/lin/other/jpegsrc.v8b.tar.gz
# tar -zxvf jpegsrc.v8b.tar.gz
# cd jpeg-8b
# ./configure --prefix=/usr/local/jpeg --enable-shared --enable-static  
# make && make install 使用php mcrypt 前必须先安装Libmcrypt 
libmcrypt源码安装方法:
# cd /www/xiazai
# wget http://mirrors.ahaoyw.com/autoconf/lin/other/libmcrypt-2.5.8.tar.gz 
# tar -zxvf libmcrypt-2.5.8.tar.gz
# cd libmcrypt-2.5.8
# ./configure --prefix=/usr/local/libmcrypt
# make && make install
安装freetype
# yum install freetype -y  
安装libpng
# yum install libpng -y

解压php

# cd /www/xiazai/

# tar -zxvf php-5.3.29.tar.gz

# cd php-5.3.29

编译

./configure --prefix=/www/server/php \
--with-config-file-path=/www/server/php/etc \
--with-apxs2=/www/server/httpd/bin/apxs \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--enable-static \
--enable-maintainer-zts \
--enable-zend-multibyte \
--enable-inline-optimization \
--enable-sockets \
--enable-wddx \
--enable-zip \
--enable-calendar \
--enable-bcmath \
--enable-soap \
--with-zlib \
--with-iconv \
--with-gd \
--with-xmlrpc \
--enable-mbstring \
--without-sqlite \
--with-curl  \
--enable-ftp \
--with-mcrypt=/usr/local/libmcrypt \
--with-freetype-dir \
--with-jpeg-dir=/usr/local/jpeg \
--with-png-dir \
--disable-ipv6 \
--disable-debug \
--with-openssl \
--disable-maintainer-zts \
--disable-safe-mode \
--disable-fileinfo
# make  && make install

拷贝配置文件

# cp php.ini-production /www/server/php/etc/php.ini

apache结合php

vi /www/server/httpd/conf/httpd.conf
Apache主配置文件为:/www/server/httpd/conf/httpd.conf
 vi /www/server/httpd/conf/httpd.conf 
 找到
 <IfModule dir_module>
   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
 找到
 #ServerName www.example.com:80改为ServerName localhost:80
 #AllowOverride None改为 AllowOverride All
 #Include conf/extra/httpd-vhosts.conf改为Include conf/extra/httpd-vhosts.conf
 在conf/extra/httpd-vhosts.conf中
 加上
 NameVirtualHost *:80
 Include /www/server/httpd/conf/vhosts/*.conf //删除其他的
 在配置文件目录里面新建站点/www/server/httpd/conf/vhosts
 # mkdir -p /www/log
 # cd /www/server/httpd/conf/vhost 
 # mkdir -p /www/data/web/default 
 # vi localhost.conf新建一个站点存放目录
<DirectoryMatch "/www/web/default/(attachment|html|data)">    
   <Files ~ ".php">   
     Order allow,deny
     Deny from all 
   </Files>
</DirectoryMatch>
<VirtualHost *:80>        
   DocumentRoot "/www/data/web/default"        
   ServerName localhost        
   <Directory /www/data/web/default>          
     Options FollowSymLinks          
     AllowOverride None          
     Order deny,allow         
     Allow from all        
    </Directory>        
ErrorLog "/www/log/default-error.log"
CustomLog "/www/log/default.log" common     
</VirtualHost>
# echo "<?php phpinfo();?>" >/www/data/web/default/phpinfo.php

最后测试下php是否安装成功

# /etc/init.d/httpd start

image.png

Zend安装

# cd /www/xiazai
# wget http://mirrors.ahaoyw.com/autoconf/lin/PHP/zend/ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz
# tar -zxvf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz 
# cp ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/ZendGuardLoader.so /www/server/php/etc/
打开php.ini配置文件:vi /www/server/php/etc/php.ini
在底部添加如下
[Zend]
zend_extension = /www/server/php/etc/ZendGuardLoader.so 
zend_loader.enable = 1
最后重启httpd服务
# /etc/init.d/httpd restart

测试下Zend是否有加载成功

image.png

文章版权及转载声明

作者:不许人间见白头本文地址:https://www.ahaoyw.com/article/174.html发布于 2个月前 ( 12-15 )
文章转载或复制请以超链接形式并注明出处阿豪运维笔记

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏