标签:ubuntu apache lamp php mysql
一、lamp环境
1、安装apr
wget http://labs.renren.com/apache-mirror/apr/apr-1.4.6.tar.bz2
tar -jxvf apr-1.4.6.tar.bz2
cd apr-1.4.6
./configure --prefix=/usr/local/apr
make && make install
2、安装apr-util
wget http://labs.renren.com/apache-mirror/apr/apr-util-1.4.1.tar.bz2
tar -jxvf apr-util-1.4.1.tar.bz2
cd apr-util-1.4.1
./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config
make && make install
3、安装pcre
wget http://downloads.sourceforge.net/project/pcre/pcre/8.30/pcre-8.30.zip
unzip pcre-8.30.zip
cd pcre-8.30
./configure --prefix=/usr/local/pcre
make && make install
4、安装apache
wget http://labs.renren.com/apache-mirror/httpd/httpd-2.4.2.tar.bz2
tar -jxvf httpd-2.4.2.tar.bz2
cd httpd-2.4.2
./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre --enable-so --enable-rewrite --enable-deflate --with-module=metadata:expires
make && make install
启动apache
/usr/local/apache/bin/apachectl -k start
在浏览器输入localhost或者127.0.0.1
就可以看到
it works!
5、安装mysql
不需要使用编译直接用命令安装就可以
a、sudo apt-get install mysql-server
b、apt-get isntall mysql-client
c、sudo apt-get install libmysqlclient-dev
安装过程时会出现设置密码;
检查是否开启
sudo netstat -tap | grep mysql
登录mysql
mysql -uroot -p
输入密码就可以了
6、安装php
sudo apt-get install -y curl libxml2 libxml2-dev libssl-dev sendmail libcurl4-openssl-dev libjpeg-dev libpng-dev libmcrypt-dev
wget -O php-5.4.4.tar.bz2 http://cn.php.net/get/php-5.4.4.tar.bz2/from/this/mirror
tar -jxvf php-5.4.4.tar.bz2
cd php-5.4.4
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-curl --with-mcrypt --enable-mbstring --enable-pdo --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-openssl --with-imap-ssl --with-gd --with-jpeg-dir=/usr/lib/ --with-png-dir=/usr/lib/ --enable-exif --enable-zip
make && make install
sudo cp php.ini-development /usr/local/php/lib/php.ini
sudo rm /usr/bin/php
sudo ln -s /usr/local/php/bin/php /usr/bin/php
进行重启apache
/usr/local/apache/bin/apachectl -k restart
7、操作
修改apache配置文件
# vi conf/httpd.conf
搜索LoadModule,在下面加上
LoadMOdule rewrite_module modules/mod_rewrite.so
LoadModule alias_module modules/mod_alias.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule deflate_module modules/mod_deflate.so
LoadModule dir_module modules/mod_dir.so
LoadModule userdir_module modules/mod_userdir.so
LoadModule env_module modules/mod_env.so
LoadModule expires_module modules/mod_expires.so
LoadModule mime_module modules/mod_mime.so
LoadModule vhost_alias_module modules/mod_vhost_alias.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule log_config_module modules/mod_log_config.so
将
<Directory />
</Directory>
和
<Directory "/usr/local/webserver/apache/htdocs">
</Directory>
俩节相应的部分改为 (如有必要,比如不使用虚拟主机来跑网站,要设置虚拟主机可以修改/etc/hosts来增加一点虚拟的域名)
AllowOverride All
Order allow,deny
Allow from all
Shift + G 转到配置文件末尾
取消掉对Virtual hosts和various default settings俩项include的注释
整合apache与php
# vi /usr/local/webserver/apache/conf/httpd.conf
找到
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
将其改为
<IfModule dir_module>
DirectoryIndex index.php index.html index.htm
</IfModule>
找到 Addtype application/x-gzip .tgz
在它下面添加一行
Addtype application/x-httpd-php .php
重启apache,同上
本文出自 “cecotw” 博客,请务必保留此出处http://cecotw.blog.51cto.com/7744188/1635561
标签:ubuntu apache lamp php mysql
原文地址:http://cecotw.blog.51cto.com/7744188/1635561