centos6.6 搭建 LAMP
1.安装mysql# cd /usr/src/
# wget http://syslab.comsenz.com/downloads/linux/mysql-5.1.40-linux-i686-icc-glibc23.tar.gz 下载mysql
# 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 移动到此并改名
# cd /usr/local/mysql/
# mkdir -p /data/mysql/ 创建mysql数据库存放位置
# chown -R mysql:mysql /data/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 出现这个为安装成功
# ls
# cp support-files/mysql.server /etc/init.d/mysqld [复制到此,并改名为mysqld,能用service 启动]
# cp support-files/my-huge.cnf /etc/my.cnf [把配置文件复制此,这个文件可以修改相关配置如:端口 sock]
chmod 755 /etc/init.d/mysqld
vim /etc/init.d/mysqld #修改datadir[数据库文件路径],basedir 错误日志什么的都在/data/mysql 下,以主机名.err命名
chkconfig --add mysqld
chkconfig mysqld on [开机启动]
2. 安装apache
# wget http://syslab.comsenz.com/downloads/linux/httpd-2.2.16.tar.gz
# tar zxvf httpd-2.2.16.tar.gz
# cd httpd-2.2.16
# ./configureprefix=/usr/local/apache2 --with-prce--enable-mods-shared=most
如有报错安装 gcc开发包
# 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端口 ServerAdmin you@example.com管理员邮箱 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 默认是prefork2.4 默认是event ./configure 时 可以加 --with-mpm-prefork/event/worker】
3.安装php
# wget http://cn2.php.net/distributions/php-5.3.28.tar.gz
# tar zxvf php-5.3.28.tar.gz
# cd 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
# 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解析正常";
?>
保存后,继续测试:
页:
[1]