首頁 >php教程 >php手册 >centos 下安装apache2.4.2+mysql5.5.7+php5.4

centos 下安装apache2.4.2+mysql5.5.7+php5.4

WBOY
WBOY原創
2016-06-06 20:07:411264瀏覽

apache2.4.2+mysql5.5.7+php5.4 Apache安装 wget http://mirror.bjtu.edu.cn/apache//apr/apr-1.4.6.tar.gzwget http://mirror.bjtu.edu.cn/apache//apr/apr-util-1.4.1.tar.gzwget http://apache.etoak.com//httpd/httpd-2.4.2.tar.gztar zxvf apr-1.4.6.ta

apache2.4.2+mysql5.5.7+php5.4
Apache安装

wget http://mirror.bjtu.edu.cn/apache//apr/apr-1.4.6.tar.gz
wget http://mirror.bjtu.edu.cn/apache//apr/apr-util-1.4.1.tar.gz
wget http://apache.etoak.com//httpd/httpd-2.4.2.tar.gz
tar zxvf apr-1.4.6.tar.gz
cd apr-1.4.6
./configure –prefix=/usr/local/apr
make
make install
tar zxvf apr-util-1.4.1.tar.gz
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/make
make install
tar zxvf httpd-2.4.2.tar.gz
cd httpd-2.2
./configure --prefix=/usr/local/apache2 --enable-so --enable-mods-shared=all --enable-vhost-alias --enable-expires --enable-rewrite --enable-authn-dbm=shared --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/
make
make install
cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd
chmod 755 /etc/rc.d/init.d/httpd
/etc/rc.d/init.d/httpd start

测试
lynx localhost
远程上不行,通过关闭防火墙
service iptables stop
远程就可以访问了
如果不想关闭防火墙,放开80端口即可。

iptables -I INPUT -p tcp --dport 80 -j ACCEPT
service iptables save
#vi /etc/sysconfig/iptables
增加一行
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
#service iptables restart //重启防火墙

Mysql安装
使用rpm方式安装mysql
wget http://cdn.mysql.com/Downloads/MySQL-5.5/MySQL-server-5.5.27-1.linux2.6.i386.rpm
wget http://cdn.mysql.com/Downloads/MySQL-5.5/MySQL-client-5.5.27-1.linux2.6.i386.rpm
安装mysql
rpm –ivh MySQL-server-5.5.27-1.linux2.6.i386.rpm
rpm –ivh MySQL-client-5.5.27-1.linux2.6.i386.rpm
启动mysql
/usr/bin/mysqld_safe &
将mysql服务加入自动启动
查看mysql的运行状态
service mysql status
查看mysql是否在自动启动的列表中
chkconfig –list
如果不再加入
chkconfig –add mysql

php安装
安装一些常用的库

yum install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
wget http://cn2.php.net/distributions/php-5.4.5.tar.gz
tar zxvf php-5.4.5.tar.gz
cd php-5.4.5
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-mysqli --prefix=/usr/local/php5 --disable-cgi --with-zlib --with-gettext --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap
make
make install
cp -p .libs/libphp5.so /usr/local/apache/modules

修改apache配置
# Make sure there’s only **1** line for each of these 2 directives:
# Use for PHP 4.x:
#LoadModule php4_module modules/libphp4.so
#AddHandler php-script .php

# Use for PHP 5.x:
LoadModule php5_module modules/libphp5.so
AddHandler php5-script .php

# Add index.php to your DirectoryIndex line:
DirectoryIndex index.html index.php

AddType text/html .php

# PHP Syntax Coloring
# (optional but useful for reading PHP source for debugging):
AddType application/x-httpd-php-source phps

httpd.conf中加入php的配置文件
PHPINIDir /etc/php.ini

开起gd库php.ini中加入
extension=curl.so
session.auto_start=1

自动启动apache
vi /etc/rc.d/rc.local
加入
/usr/local/apache2/bin/httpd -f /usr/local/apache2/conf/httpd.conf

声明: 本文 ” centos 下安装apache2.4.2+mysql5.5.7+php5.4” 采用 BY-NC-SA 协议进行授权.

转载请注明本文链接地址: http://blog.ueder.info/934.html

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn