企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# Linux环境下LAMP环境编译安装 [TOC] ## 0. 本地系统环境 操作系统:CentOS 6.7 2.6.32-573.el6.x86_64 ## 安装前的准备 ~~~ mkdir -p /application/tools ~~~ ## 1. 安装 apache ~~~ yum install httpd httpd-devel ~~~ ### 根据情况修改配置文件 ~~~ vim /etc/httpd/conf/httpd.conf ~~~ 修改如下内容,详情参考[这里](http://www.kancloud.cn/curder/apache/91277): ~~~ ServerName 192.168.2.200:80 ... ... KeepAlive Off ...... <IfModule prefork.c> StartServers 2 MinSpareServers 6 MaxSpareServers 12 MaxClients 80 MaxRequestsPerChild 3000 </IfModule> ~~~ ### 设置、绑定站点目录文件 #### 新建虚拟站点配置文件 ~~~ vim /etc/httpd/conf.d/localhost.conf ~~~ #### 写入如下内容 ~~~ NameVirtualHost *:80 <VirtualHost *:80> ServerName 192.168.2.200 ServerAlias localhost DocumentRoot /data/site/html ErrorLog /data/site/logs/192.168.2.200.error.log CustomLog /data/site/logs/192.168.2.200.access.log combined </VirtualHost> ~~~ #### 创建站点目录和文件 ~~~ mkdir -p /data/site/html && mkdir /data/site/logs echo 'this is a default web site 192.168.2.200' > /data/site/html/index.html ~~~ ### 启动httpd以及设置开机启动 ~~~ chkconfig --levels 235 httpd on apachectl start ~~~ #### 访问地址栏出现如下信息标识安装apache完成 ![](https://box.kancloud.cn/2016-02-26_56cfe370cc804.png) >[danger] 如果出现404等无法访问的情况请[查看这里](http://www.kancloud.cn/curder/apache/91274) ## 2. 安装MYSQL数据库略[参见](http://www.kancloud.cn/curder/mysql/61095) ## 3. 安装PHP环境 ### 安装依赖 ~~~ yum install openssl openssl-devel curl curl-devel libjpeg-turbo libjpeg-turbo-devel openjpeg-libs libpng libpng-devel freetype freetype-devel -y ~~~ **安装libmcrypt** ~~~ tar zxvf libmcrypt-2.5.8.tar.gz cd libmcrypt-2.5.8 ./configure --prefix=/application/tools/libmcrypt-2.5.8 make && make install ln -s /application/tools/libmcrypt-2.5.8 /usr/local/libmcrypt ~~~ ## 编译PHP并安装 ~~~ ./configure --prefix=/application/tools/php-5.3.28/ --with-config-file-path=/application/tools/php-5.3.28/etc --with-apxs2=/usr/sbin/apxs --with-mysql=/usr/local/mysql --with-mcrypt=/usr/local/libmcrypt --with-gd --with-openssl --with-zlib --enable-xml --with-xmlrpc --enable-session --with-iconv --enable-magic-quotes --with-curl --with-curlwrappers --enable-ctype --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-gd-native-ttf --with-gettext --enable-mbstring --enable-pcntl --enable-soap --enable-sockets --enable-zip --enable-ftp make && make install ln -s /application/tools/php-5.3.28 /usr/local/php ~~~ ### 设置配置文件路径 ~~~ cp /usr/local/src/php-5.3.28/php.ini-development /application/tools/php-5.3.28/etc/php.ini ~~~ ### 修改php.ini 把;date.timezone 前面的分号去掉,改成date.timezone ="PRC"。 ## apache与php的整合 > 编译php我们使用configure命令安装配置时,使用`--with-apxs2=/usr/sbin/apxs`选项以使Apache 2将PHP作为功能模块使用。 > 但我们还要修改Apahce配置文件,添加PHP的支持,告 诉Apache将哪些后缀作为PHP解析。 打开Apache的配置文件`vim /etc/httpd/conf/httpd.conf`,找到`AddType application/x-gzip .gz .tgz`指令选项,并在其下方添加一条指令**`AddType application/x-httpd-php .php .phtml`** 重启Apache后即可测试。 ![](https://box.kancloud.cn/2016-02-26_56cfe370db60c.png)