LAMP 架构在企业里用得非常广泛,目前很多电商公司、游戏公司、移动互联网公司大多都采用这种架构。LAMP指的是Linux、Apache、MySQL、PHP。下面记录了 LAMP 架构系统服务的搭建过程。
一、MySQL数据库安装
1. 系统环境
CentOS 6.4 x86_64 Mini 版本安装
2. 基础软件包安装
[root@vip ~]# yum install gcc vim make wget -y
3. 下载
# 进入源码存放目录[root@vip ~]# cd /usr/local/src# 下载MySQL安装包[root@vip src]# wget downloads.mysql.com/archives/get/file/mysql-5.5.40-linux2.6-x86_64.tar.gz
4. 解压安装
# 拷贝启动脚本[root@vip mysql]# /bin/cp support-files/mysql.server /etc/init.d/mysqld# 赋予可执行权限[root@vip mysql]# chmod 755 /etc/init.d/mysqld
10. 修改启动脚本
[root@vip mysql]# vim /etc/init.d/# 修改设置内容如下basedir=/usr/local/mysql datadir=/var/lib/mysql
11. 把MySQL添加到服务
# 设置PATH环境变量[root@vip mysql]# echo 'export PATH=$PATH:/usr/local/mysql/bin' > /etc/profile.d/mysql.sh[root@vip mysql]# source /etc/profile.d/mysql.sh
15. 登录MySQL测试
3. 安装必要的库和工具[root@vip src]# install -y pcre pcre-devel apr apr-devel zlib-devel gcc make4. 配置编译参数[root@vip httpd-31]# cd httpd-31[root@vip httpd-31]# ./configure \--prefix=/usr/local/apache2 \--with-included-apr \--enable-so \--enable-deflate=shared \--enable-expires=shared \--enable-rewrite=shared \--with-pcre [root@vip httpd-31]# echo $?5. 编译安装# 添加到系统服务 并设置开机启动[root@vip httpd-31]# chkconfig --add httpd [root@vip httpd-31]# chkconfig httpd on9. 验证服务是否正常<span style='font-family: courier new,1)>31]# service httpd starthttpd: apr_sockaddr_info_get() failed for vip # 出现警告信息httpd: Could not reliably determine the server's fully qualified domain name,using 127.0.0.1 for ServerName解决警告信息的方法:去掉 ServerName www.example.com:80 行的注释#。三、PHP系统安装1. 下载解压安装包[root@vip ~]# cd /usr/local/wget http:cn2.php.net/get/php-5.5.38.tar.gz/from/this/mirror -O php-5.5.38.tar.gz[root@vip src]# tar zxf php-38.install -y libxml2-devel openssl openssl-devel bzip2 bzip2-devel \ libjpeg-devel libpng libpng-devel freetype freetype-devel libmcrypt-devel3. 编译配置安装选项[root@vip php-38]# cd php-38[root@vip php-38]# ./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- \--with-png- \--with-freetype- \--with-iconv- \--with-zlib-bz2 \--with-openssl \--with-mcrypt \--enable-soap \--enable-gd-native-ttf \--enable-mbstring \--enable-sockets \--enable-exif \--disable-ipv64. 编译安装5. 拷贝php配置文件IfModule dir_module>DirectoryIndex index.html index.htm index.php # 添加php索引IfModule<span style=color: rgba(0,courier'>4. 测试配置语法和重启apache服务[root@vip ~]# apachectl -t Syntax OK [root@vip ~]# service httpd restart5. 测试php解析编写测试文件:/usr/local/apache2/htdocs/index.php<?phpecho hello php! ?>命令行curl测试:[root@vip htdocs]# curl localhost/index.phphello php![root@vip htdocs]#解析 php 成功!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。