1.安装mysql
[iyunv@zhaijunming src]# cd /usr/src/
[iyunv@zhaijunming src]# wget http://syslab.comsenz.com/downlo ... -icc-glibc23.tar.gz 下载mysql
[iyunv@zhaijunming src]# tar zxvf /usr/src/mysql-5.1.40-linux-i686-icc-glibc23.tar.gz
root@zhaijunming src]# mv mysql-5.1.40-linux-x86_64-icc-glibc23 /usr/local/mysql 移动到此并改名
[iyunv@zhaijunming src]# cd /usr/local/mysql/
[iyunv@zhaijunming mysql]# mkdir -p /data/mysql/ 创建mysql数据库存放位置
[iyunv@zhaijunming mysql]# chown -R mysql:mysql /data/mysql/ 修改属主属组
[iyunv@zhaijunming mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql/ 初始化
出现这个错误 需要vim/etc/hosts 中添加 127.0.0.1 + 主机名
出现这个错误 需要安装compat-linstdc++ (附件里有)
Installing MySQL system tables...
OK
Filling help tables...
OK 出现这个为安装成功
[iyunv@zhaijunming support-files]# ls [support-files 中的 mysql.server是启动文件]
[iyunv@zhaijunming mysql]# cp support-files/mysql.server /etc/init.d/mysqld [复制到此,并改名为mysqld,能用service 启动]
[iyunv@zhaijunming mysql]# cp support-files/my-huge.cnf /etc/my.cnf [把配置文件复制此,这个文件可以修改相关配置如:端口 sock]
chmod 755 /etc/init.d/mysqld
vim /etc/init.d/mysqld #修改datadir[数据库文件路径],basedir[mysql安装路径] 错误日志什么的都在/data/mysql 下,以主机名.err命名
chkconfig --add mysqld
chkconfig mysqld on [开机启动]
2. 安装apache
[iyunv@zhaijunming src]# wget http://syslab.comsenz.com/downloads/linux/httpd-2.2.16.tar.gz
[iyunv@zhaijunming src]# tar zxvf httpd-2.2.16.tar.gz
[iyunv@zhaijunming src]# cd httpd-2.2.16
[iyunv@zhaijunming httpd-2.2.16]# ./configure prefix=/usr/local/apache2 --with-prce --enable-mods-shared=most [pcre识别正则表达式,shared动态共享模块]
如有报错安装 gcc开发包
[iyunv@zhaijunming httpd-2.2.16]# make && make install
root Ss (父进程) daemon S (是子进程) apache相关路径 配置文件 :/usr/local/apache2/conf/httpd.conf php文件放在:/usr/local/apache2/htdocs 启动文件 :/usr/local/apache2/bin/apachetl2 检测配置文件是否有错误:/usr/local/apache2/bin/apachectl -t
httpd.conf中 : Listen 80 80端口 ServerName localhost:80 主机名 DocumentRoot "/usr/local/apache2/htdocs" index.php 文件放的位置 ErrorLog "logs/error_log" 定义错误日志 LogLevel warn 定义日志级别 warn的错误才记录 AddType application/x-httpd-php .php 支持php DirectoryIndex index.html index.php 自动寻找主页文件 【prefork 稳定 (由子进程提供服务)(占用内存多) worker 支持高并发(由进程跟线程混合的方式提供服务)(占用内存少) 进程是相互独立的,每两个或多个进程之间不受影响不存在共享内存,共享cpu 线程是由进程派生的,意味着线程之间相互共享进程的资源, 进程下是线程 2.0 2.2 默认是prefork 2.4 默认是event ./configure 时 可以加 --with-mpm-prefork/event/worker】
3. 安装php
[iyunv@zhaijunming src]# wget http://cn2.php.net/distributions/php-5.3.28.tar.gz
[iyunv@zhaijunming src]# tar zxvf php-5.3.28.tar.gz
[iyunv@zhaijunming src]# cd php-5.3.28
[iyunv@zhaijunming 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
[iyunv@zhaijunming src]# vim /usr/local/apache2/conf/httpd.conf
找到:
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解析正常";
?>
保存后,继续测试:
|