1. 安装mysql
cd /usr/local/src/
wget http://syslab.comsenz.com/downloads/linux/mysql-5.1.40-linux-i686-icc-glibc23.tar.gz
注意:上面的地址是32位机器用的,如果你的机器是64位,下载这个包(http://syslab.comsenz.com/downloads/linux/mysql-5.1.40-linux-x86_64-icc-glibc23.tar.gz)安装方法是一样的。
tar zxvf /usr/local/src/mysql-5.1.40-linux-i686-icc-glibc23.tar.gz
mv mysql-5.1.40-linux-i686-icc-glibc23 /usr/local/mysql
useradd -s /sbin/nologin mysql
cd /usr/local/mysql
mkdir -p /data/mysql
chown -R mysql:mysql /data/mysql
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
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 #修改datadir
chkconfig --add mysqld
chkconfig mysqld on
service mysqld start
2. 安装apache
wget http://archive.apache.org/dist/httpd/httpd-2.2.27.tar.bz2
tar jvxf httpd-2.2.27.tar.bz2
cd httpd-2.2.27
./configure --prefix=/usr/local/apache2 --enable-mods-shared=most --enable-so
make && make install
3. 安装php
wget http://cn2.php.net/distributions/php-5.3.28.tar.gz
tar zxf php-5.3.28.tar.gz
cd php-5.3.28
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif --disable-ipv6
make && make install
4. 配置apache结合php
vim /usr/local/apache2/conf/httpd.conf找到:
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
改为:
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
</Directory>
找到:
AddType application/x-gzip .gz .tgz
在该行下面添加:
AddType application/x-httpd-php .php
找到:
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
将该行改为:
<IfModule dir_module>
DirectoryIndex index.html index.htm index.php
</IfModule>
找到:
#ServerName www.example.com:80
修改为:
ServerName localhost:80
5. 测试解析php
vim /usr/local/apache2/htdocs/1.php
写入:
<?php
echo "php解析正常";
?>
保存后,继续测试:
curl localhost/1.php
在centos6.x 上编译安装php时,如果指定编译参数 --wity-mcrypt 会需要安装 libmcrypt-devel这个包才可以。但是当使用yum install libmcrypt-devel 的时候,会提示无这个包。这是因为centos6.x 默认的yum源不在包含这个资源。需要第三方资源。解决办法为:
rpm -ivh "http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-7.noarch.rpm"
如果上面的地址失效,请使用下面的地址
http://www.lishiming.net/data/attachment/forum/month_1211/epel-release-6-7.noarch.rpm
然后再
yum install -y libmcrypt-devel
Centos6.5编译php时报错:configure: error: mcrypt.h not found. Please reinstall libmcrypt.
百度上找了很多解决办法,都不能使用。
解决办法:
[[email protected] php-5.3.27]# yum install libmcrypt-devel -y 安装libmcryp
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.skyshe.cn
* extras: mirrors.skyshe.cn
* updates: mirrors.pubyun.com
Setting up Install Process
No package mcryptlib-devel available.
Error: Nothing to do
以上是常规解决办法。我到这里还不能安装mcrypt。因为yum源里没有这个的包,只能更换yum源。
解决办法:
全部改成阿里云
[[email protected] ~]# rm -rf /etc/yum.repos.d/*
执行此操作的时候记得事先装好wget,不然你就得挂载光盘用rpm装wget了。(说到这个我真的是要哭出声音)
[[email protected] ~]# wget -P /etc/yum.repos.d/ [img]file:///C:/Users/xc/AppData/Local/Temp/[5UQ[BL(6~BS2JV6W%7DN6[%S.png[/img]
http://mirrors.aliyun.com/repo/epel-6.repo
[img]file:///C:/Users/xc/AppData/Local/Temp/[5UQ[BL(6~BS2JV6W%7DN6[%S.png[/img]http://mirrors.aliyun.com/repo/Centos-6.repo 这条命令的意思是把centos6的repo文件和epel文件同时下载到/etc/yum.repos.d这个目录下
这个时候,执行 yum repolist的结果如下
[[email protected] ~]# yum repolist
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Setting up Install Process
如果有依赖实在解决不了,只能下载个源码包了。下载地址:
http://www.aminglinux.com/bbs/data/attachment/forum/libmcrypt.tar.bz2
编译之前需要安装 gcc 和 gcc-c++ yum install -y gcc gcc-c++