您好,登錄后才能下訂單哦!
注:本實驗是在關閉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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。