您好,登录后才能下订单哦!
注:本实验是在关闭iptables 和selinux 的情况下进行的。
安装环境
[root@server ~]# yum -y install perl gd gd-devel libpng libpng-devel libjpeg libjpeg-devel zlib zlib-devel pcre-devel gcc gcc-c++ make cmake autoconf openssl openssl-devel ncurses-devel patch libxml2 libxml2-devel curl-devel openldap openldap-devel libevent libevent-devel bison icu libicu-devel libtool readline-devel net-snmp-devel bzip2-devel freetype-devel vim
一、搭建LAMP环境
(1) 安装apache
安装http
[root@server lamp]# tar zxvf httpd-2.2.22.tar.gz
[root@server lamp]# cd httpd-2.2.22
[root@server httpd-2.2.22]#./configure --prefix=/usr/local/apache --enable-so --enable-sl --enable-cgi --enable-rewrite --with-zlib \
--with-pcre
[root@server httpd-2.2.22]# make && make install
启动测试apache
[root@server ~]# /usr/local/apache/bin/apachectl start
(2) 安装mysql
[root@server ~]# useradd -s /sbin/nologin -M mysql
[root@server lamp]# tar zxvf mysql-5.5.29.tar.gz
[root@server lamp]# cd mysql-5.5.29
[root@server mysql-5.5.29]# cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DINSTALL_DATADIR=/data/mysql \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=complex \
-DMYSQL_USER=mysql
[root@server mysql]# chown -R root .
[root@server mysql]# cp support-files/my-medium.cnf /etc/my.cnf
[root@server php]# vim /etc/my.cnf
添加以下内容:
[mysqld]
port = 3306
socket = /tmp/mysql.sock
basedir = /usr/local/mysql
datadir = /data/mysql
user = mysql
character_set_server = utf8
配置mysql 启动
[root@server mysql]# cp support-files/mysql.server /etc/init.d/mysql
[root@server mysql]# vim /etc/init.d/mysql
添加以下两行
basedir=/usr/local/mysql
datadir=/data/mysql
[root@server mysql]# service mysql start
Starting MySQL... SUCCESS!
查看mysql是否已经启动
[root@server mysql]# netstat -nultp |grep mysql
0.0.0.0:3306 0.0.0.0:* LISTEN 64819/mysqld
(3) 安装php
[root@server php-5.4.11]# useradd -s /sbin/nologin -M fpmuser
[root@server lamp]# tar zxvf php-5.4.11.tar.gz
[root@server php-5. 4.11]#
./configure --prefix=/usr/local/php \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-config-file-path=/etc \
--with-freetype-dir --with-jpeg-dir \
--with-png-dir --enable-zip \
--with-zlib --enable-xml \
--with-gd --with-mhash \
--with-libxml-dir=/usr --enable-mbstring \
--enable-fpm --with-fpm-user=fpmuser \
--with-fpm-group=fpmuser --disable-ipv6 \
--enable-sockets --with-openssl \
--with-bz2 --with-curl --enable-dba=shared \
--with-pcre-dir --with-gd --with-jpeg-dir --with-png-dir \
--with-zlib-dir --enable-mbstring \
--with-mysql=/usr/local/mysql/ \
--with-mysql-sock=/tmp/mysql.sock \
--with-mysqli=/usr/local/mysql/bin/mysql_config
[root@server php-5. 4.11]# make
[root@server php-5. 4.11]# make install
[root@server php-5.4.11]# cp php.ini-production /usr/local/php/lib/php.ini
[root@server php-5.4.11]# cd /usr/local/php/etc/
[root@server etc]# cp -a php-fpm.conf.default php-fpm.conf
[root@server etc]# cd ..
启动php
[root@server php]# sbin/php-fpm
(4) 配置apache
[root@server html]# vim /usr/local/apache/conf/httpd.conf
找到DirectoryIndex index.html index.html.var
修改为DirectoryIndex index.html index.php
接着增加如下内容:
AddType application/x-httpd-php .php
修改完如下:
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
AddType application/x-httpd-php .php
添加虚拟目录测试lamp
[root@server ~]# vim /usr/local/apache/conf/httpd.conf
添加以下内容
Alias /test "/usr/local/apache/test"
<Directory "/usr/local/apache/test">
AuthType Basic
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>
创建Php测试页面
[root@server ~]# mkdir /usr/local/apache/test
[root@server ~]# vim /usr/local/apache/test/index.php
添加以下内容:
<?php
phpinfo();
?>
配置完成后重启apache
[root@server html]# /usr/local/apache/bin/apachectl restart
测试PHP 页面
打开浏览器访问:
http://ip/test/index.php
至此LAMP环境配置完成
相关软件包下载:http://down.51cto.com/data/699395
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。