Uploaded on

About LAMP, how to setup.

About LAMP, how to setup.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
117
On Slideshare
0
From Embeds
0
Number of Embeds
4

Actions

Shares
Downloads
0
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. LAMP
  • 2. 概述• LAMP是一种目前很流行的建站方式, LAMP 指的是Linux+Apache+MySQL+PHP, 这里依次解 释后面三个: Apache 最流行的web服务器, 什么是web server 参考这里, Apache官方网站. MySQL 开源数据库服务器, 特点是小巧高效 PHP 网页脚本引擎, 输出HTML脚本• 这里会讲述如何使用搭建LAMP环境并建立一 个内容管理(CMS)站点, 前提是需要对WEB有一 定的概念.
  • 3. LAMP - 安装 & apache• 准备源代码包 httpd-2.2.22.tar.bz2 MySQL-5.5.17-1.rhel5.src.rpm php-5.3.14.tar.bz2• apache安装及配置 1, 安装 tar jxvf httpd-2.2.22.tar.bz2 # 解压缩 # 切换到解压缩后的目录, 运行configure ./configure --prefix=/usr/local/apache2 --enable-mods- shared=most --enable-so --enable-rewrite # 编译安装 make && make install
  • 4. LAMP - 安装 & apache 2, apache配置 通常将httpd配置为系统服务, 如下: # 拷贝系统服务脚本cp /usr/local/apache2/bin/httpd /etc/init.d # 添加系统服务 chkconfig --add httpd chkconfig httpd --level 35 on 3, web根目录设置, 添加PHP支持 在apache安装目录下找到httpd.conf文件, 参考如下配置: DocumentRoot "/apps" <Directory "/apps"> DirectoryIndex index.html index.phpAddType application/x-httpd-php .phpAddType application/x-httpd-php-source .phps
  • 5. LAMP - 安装 & mysql• mysql安装及配置 1, 安装 # 解压缩 rpm2cpio MySQL-5.5.17-1.rhel5.src.rpm | cpio –id tar zxvf mysql-5.5.17.tar.gz # 在安装mysql需要确保cmake, bison, ncurses-devel已安装 tar zxvf cmake-2.8.8.tar.gz cd cmake-2.8.8 ./configure && make && make install yum install bison.i386 yum install ncurses-devel # 编译安装mysql, cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/data make && make install
  • 6. LAMP - 安装 & mysql2, mysql基础配置# mysql配置文件mkdir /var/mysqlcp /usr/local/mysql/support-files/my-huge.cnf /var/mysql/my.cnf# 创建mysql用户和组, 创建数据文件目录并更改权限groupadd mysqluseradd -g mysql mysqlchown -R mysql:mysql /var/mysqlchown -R mysql:mysql /data# 初始化mysql字典数据库/usr/local/mysql/scripts/mysql_install_db --defaults-file=/var/mysql/my.cnf --basedir=/usr/local/mysql --datadir=/data --user=mysql# 配置系统服务cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqldchmod +x /etc/init.d/mysqldchkconfig --add mysqldchkconfig --level 35 mysqld on
  • 7. LAMP - 安装 & mysql# 修改my.cnf, 类似如下修改:[mysqld]datadir=/datasocket=/tmp/mysql.sockuser=mysql[mysqld_safe]log-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pid[client]socket=/tmp/mysql.sock# 启用mysql日志修改my.cnf文件在mysqld段添加: log=”/data/mysql.log”# 允许root远程连接grant all on *.* to root@% identified by abc123;flush privileges;
  • 8. LAMP - 安装 & PHP• PHP安装 根据需要安装libxml2-devel: yum install libxml2-devel.i386 解压后使用如下如下命令安装php: ./configure --prefix=/usr/local/php --with- apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-config-file- path=/usr/local/php --with-zlib=/usr make && make install
  • 9. LAMP - 测试• 在web根目录下分别创建如下两个php脚本文件: 1, test1.php 测试php安装是否成功 <?php phpinfo(); ?> 2, test2.php 测试是否能够连接mysql <? $link = mysql_connect(localhost,root,root); if(!$link) echo "Failure!"; else echo "Success!"; mysql_close(); ?>