重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
注:本实验是在关闭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
修改完如下:
DirectoryIndex index.html index.php
AddType application/x-httpd-php .php
添加虚拟目录测试lamp
[root@server ~]# vim /usr/local/apache/conf/httpd.conf
添加以下内容
Alias /test "/usr/local/apache/test"
AuthType Basic
Options None
AllowOverride None
Order allow,deny
Allow from all
创建Php测试页面
[root@server ~]# mkdir /usr/local/apache/test
[root@server ~]# vim /usr/local/apache/test/index.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