apache+mysql+php for linux安装配置

1.安装环境
操作系统:Red Hat Linux
数据库:MySQL 5.1.41
Web服务器:Apache 2.2.15
脚本语言:PHP 5.3.2

2.安装MySQL 5.1.41
-------------下载软件包mysql-5.1.41.tar.gz,地址http://www.mysql.com或http://mysql.isu.edu.tw/Downloads/MySQL-5.1/-------------

# tar zvxf mysql-5.1.41.tar.gz //解压缩

# cd mysql-5.1.41 //进入解压缩后的文件目录

#./configure --prefix=/usr/local/mysql --enable-thread-safe-client --localstatedir=/opt/mysqldata

# make //编译

# make install //安装

# /usr/local/mysql/bin/mysql_install_db //初始化授权

# chown –R root:root /usr/local/mysql //文件属性改为root用户

# cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf //复制配置文件

----------------------------------启动MySQL服务----------------------------------
# /usr/local/mysql/bin/mysqld_safe --user=root & //启动MySQL

----------------------------------修改MySQL密码----------------------------------
# /usr/local/mysql/bin/mysqladmin -uroot password smilingsdb //修改密码


----------------------------------关闭MySQL服务----------------------------------
# /usr/local/mysql/bin/mysqladmin -uroot -pmysqlsecret shutdown //关闭MySQL

-----------------检查是否安装成功---------------
启动后用ps -aux │ grep mysql 可以看到,证明安装成功

---------------------------------创建Mysql用户-----------------------------------------------
[root@ud2C002 bin]# ./mysql -u root -p
mysql> GRANT ALL ON *.* TO 'smilingsdb'@'localhost' IDENTIFIED BY 'smilingsdb'



3.安装Apache 2.2.15
-------------下载软件包httpd-2.2.15.tar.gz,地址http://www.apache.org-------------

# tar zvxf httpd-2.2.15.tar.gz

# cd httpd-2.2.15

#./configure --prefix=/usr/local/apache --enable-module=most --enable-shared=max

# make

# make install

# chown -R root:root /usr/local/apache/

----------------------------------启动Apache服务----------------------------------
# /usr/local/apache/bin/apachectl start

----------------------------------关闭Apache服务----------------------------------
# /usr/local/apache/bin/apachectl stop

----------------------------------重启Apache服务----------------------------------
# /usr/local/apache/bin/apachectl restart

---------------------------------测试apache是否安装成功---------------------------
通过浏览器访问:
http://234.90.166.134/index.html


4.安装PHP 5.3.2
-------------------下载软件包php-5.3.2.tar.gz,地址www.php.net--------------------

# tar zvxf php-5.3.2.tar.gz

# cd php-5.3.2

# ./configure --prefix=/usr/local/php --with-mysqld=/usr/local/mysql --with-apxs2=/usr/local/apache/bin/apxs


# make

# make install

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

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

5.PHP与Apache整合
----------------------------修改httpd.conf配置-------------------------------------------------
#vi /usr/local/apache/conf/httpd.conf

*在DirectoryIndex处添加 index.php

*在AddType application处添加

AddType application/x-httpd-php .php .phtml

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

修改文件存放路径
DocumentRoot "/opt/smilings"
<Directory "/opt/smilings">

----------------------------整合后信息查看-------------------------------------------------
http://234.90.166.134/phpinfo.php

你可能感兴趣的:(apache,linux,mysql,PHP,application,web服务)