Apache+PHP+MySQL Configuration

来源:互联网 发布:ad线路板画图软件 编辑:程序博客网 时间:2024/05/22 16:58

准备工作

系统

centos 7

安装

apache

下载源码

在http://www.apache.org/dist/httpd下载apache源码;

解决ARP出错

#./configure --prefix……检查编辑环境时出现:

checking for APR... no
configure: error: APR not found .  Please read the documentation

解决办法:

1.下载所需软件包:

wget http://archive.apache.org/dist/apr/apr-1.4.5.tar.gz

wget http://archive.apache.org/dist/apr/apr-util-1.3.12.tar.gz

wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.10/pcre-8.10.zip

2.编译安装软件包:

yum remove apr-util-devel apr apr-util-mysql apr-docs apr-devel apr-util apr-util-docs

具体步骤如下:

  • 解决apr not found问题:

[root@xt test]# tar -zxf apr-1.4.5.tar.gz

[root@xt test]# cd apr-1.4.5

[root@xt apr-1.4.5]# ./configure --prefix=/usr/local/apr

[root@xt apr-1.4.5]# make && make install

  • 解决APR-util not found问题

[root@xt test]# tar -zxf apr-util-1.3.12.tar.gz

[root@xt test]# cd apr-util-1.3.12

[root@xt apr-util-1.3.12]# ./configure --prefix=/usr/local/apr-util--with-apr=/usr/local/apr/bin/apr-1-config

[root@xt apr-util-1.3.12]# make && make install

  •   解决pcre问题

[root@xt test]#unzip -o pcre-8.10.zip

[root@xt test]#cd pcre-8.10

[root@xt pcre-8.10]#./configure --prefix=/usr/local/pcre

[root@xt pcre-8.10]#make && make install

3.编译安装Apache

./configure --prefix=/usr/local/apache2 --enable-module=so --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre

make

make install

配置

cd /usr/local/apache/conf 

vi httpd.conf 

针对php要对以下内容进行修改: 

AddType application/x-httpd-php .php .php3 .htm .phtml .php4

AddType application/x-httpd-php-source .phps 

添加以上两行 

DirectoryIndex index.htm index.html index.php3 index.php default.php 

启动

/usr/local/apache/bin/apachectl start 

MySQL

CentOS 7的yum源中貌似没有正常安装mysql时的mysql-sever文件,需要去官网上下载

# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

# rpm -ivh mysql-community-release-el7-5.noarch.rpm

# yum install mysql-community-server

成功安装之后重启mysql服务

# service mysqld restart

初次安装mysql是root账户是没有密码的

设置密码的方法

# mysql -uroot

mysql> set password for ‘root’@‘localhost’ = password('mypasswd');

mysql> exit

PHP

下载源码

在http://www.php.net/downloads.php下载php的for Linux 的源码包

yum install libxml2-devel

./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/lib --enable-track-vars --with-xml --with-MySQL

make

make install

配置

cp php.ini-dist /usr/local/lib/php.ini 

vi /usr/local/lib/php.ini 

#register-golbals = On


测试

rm /usr/local/apache2/htdocs/index.html

vim /usr/local/apache2/htdocs/index.php

<?php  
            echo "hello world!";  
?>
在浏览器输入本机ip回车

就会有hello world出现。bingo!


  





0 0