LAMP架构搭建
系统环境:centos6.7 32位一、mysql安装
1、下载mysql到/usr/local/src/
cd /usr/local/src/
wget http://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.73-linux-i686-glibc23.tar.gz
2、初始化
tar zxvf /usr/local/src/mysql-5.1.73-linux-i686-glibc23.tar.gz //解压
mv mysql-5.1.73-linux-i686-glibc23/usr/local/mysql //挪动位置并且重命名为mysql
useradd -s /sbin/nologin mysql //建立mysql用户
cd /usr/local/mysql
mkdir -p /data/mysql//创建datadir,用来存放数据库文件
chown -R mysql:mysql /data/mysql//更改目录权限
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql//初始化
// --user 定义数据库的所属主,--datadir 定义数据库安装到哪个目录下。
3、配置mysql
cp support-files/my-large.cnf /etc/my.cnf //拷贝配置文件到/etc/下,且命名为my.cnf
cp support-files/mysql.server /etc/init.d/mysqld //拷贝启动脚本到/etc/init.d/下,切命名为mysqld
chmod 755 /etc/init.d/mysqld //修改启动脚本的权限
//拷贝启动脚本,修改其属性
vim /etc/init.d/mysqld
//修改启动脚本,datadir=/data/mysql(之前初始化数据库时定义的目录)
chkconfig --add mysqld
chkconfig mysqld on
service mysqld start
//把启动脚本加入系统服务项,设定开机启动,并启动mysql
二、安装apache
1、下载apachel到/usr/local/src/
cd /usr/local/src/ //进入/usr/local/src/目录下
wget http://www.lishiming.net/data/attachment/forum/httpd-2.2.24.tar.bz2
//下载源码包
2、解压编译安装
tar jvxf httpd-2.2.24.tar.bz2//解压
cd httpd-2.2.24 //进入httpd-2.2.24目录下
./configure --prefix=/usr/local/apache2 --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --with-pcre //配置编译参数
make //编译
make install //安装
三、安装PHP
1、下载PHP到/usr/local/src下
cd /usr/local/src
wget http://cn2.php.net/distributions/php-5.4.44.tar.gz
2、解压编译安装
tar zxvf php-5.4.44.tar.gz//解压
cd php-5.4.44//进入php-5.4.44目录
./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//安装
cp php.ini-production /usr/local/php/etc/php.ini//拷贝配置文件
apache结合php
vim /usr/local/apache2/conf/httpd.conf//编辑apache主配置文件
找到:
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all </Directory>
改成:
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
</Directory>
//不修改,访问网站会显示403
找到:
AddType application/x-gzip .gz .tgz
在该行下面添加一行:
AddType application/x-httpd-php .php
//加上对应类型以支持php脚本解析
找到:
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
改成:
<IfModule dir_module>
DirectoryIndex index.html index.htm index.php
</IfModule>
//增加针对php的索引
找到:
#ServerName www.example.com:80
改成:
ServerName localhost:80
保存配置文件
/usr/local/apache2/bin/apachectl -t //检查配置文件是否有错
/usr/local/apache2/bin/apachectl start//启动apache
页:
[1]