首页 > 代码库 > LAMP安装细则
LAMP安装细则
利用xshell从Windows向Linux传输文件
[root@nanainux ~]#yum install lrzsz
[root@nanalinux ~]#rz
MySq二进制包安装
mysql包——搜狐
http://222.21.218.207/mirrors.sohu.com/mysql/MySQL-5.0/mysql-5.0.95-linux-x86_64-glibc23.tar.gz
http://mirrors.sohu.com/mysql/MySQL-5.0/ ;
2. cd /usr/local/src
tar zxvf mysql-5.0.95-linux-x86_64-glibc23.tar.gz //解压二进制包
mv mysql-5.0.95-linux-x86_64-glibc23 /usr/local/mysql/ //移动到mysql
cd mysql/
3.useradd -s /sbin/nologin mysql //添加mysql用户
mkdir datadir
chmod -R mysql:mysql /data/mysql/ //将刚才创建的mysql添加的mysql组中
4.cp support-files/mysql/mysql_install_ db/my-large.cnf /etc/my.cnf //拷贝配置文件
vim /etc/my.cnf //将bin-log 注释掉 //修改配置文件
cp support-files/myslql.server /etc/init.d/mysqld //拷贝 启动文件
vim /etc/init.d/mysqld //修改 datadir=/data/mysql basedir=/usrlocal/mysql
5 ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql //初始化数据库
6. /etc/init.d/mysqld //启动mysql服务
7. ps aux|grep mysql //查看mysql进程是否存在
Apache安装
安装的三部曲:
1.配置安装参数 以及编译参数
2.make 编译
3.make isntall 安装
apache安装包下载地址
http://archive.apache.org/dist/httpd/
[root@nanalinux src]#cd /usr/local/src
[root@nanalinux src]#rz //传输apache的安装包
[root@nanalinux src]#tar zxvf httpd-2.2.0.tar.gz //解压包 ; 注 tar.ga2包需要将参数 zxvf 换为 jxvf ; 去掉参数V不显示解压过程
[root@nanalinux src]#cd httpd-2.2.0
[root@nanaLinux src]# ./configure --prefix=/usr/local/apache2 --with-included-apr --with-pcre --enable-nodes-shared==most
//配置编译参数 apache2为安装的位置, 红字部分很重要(可移植的.....),不加的话影响make install过程;
[root@nanaLinux src]# yum install gcc //编译所需的$PATH(变量环境), 这是个 C语言在Linux下的 编译器;
[root@nanaLinux src]# make //编译
[root@nanaLinux src]# make isntall //安装
PHP安装
下载PHP包 http://www.php.net/downloads.php
cd /usr/local/src
rz
tar zxf php-5.5.30.tar.gz
cd php-5.5.30/
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif --disable-ipv6
//配置编译参数;
//config-file->配置文件
//libxml,jpeg,.......->为各种模块
configure: error: xml2-config not found. Please check your libxml2 installation. //错误1:缺少libxml2模块
yum list|grep -i ‘xml2‘ //查找本地yum
yum install libxmllibxml2-devel.x86_64
yum install libxml2-devel.x86_64
configure: error: Cannot find OpenSSL‘s <evp.h> //同错误1解决方式
yum list |grep openssl-devel
yum install openssl-devel.x86_64
checking for BZip2 in default path... not foundconfigure: error: Please reinstall the BZip2 distribution
yum list | grep bzip2
yum install bzip2-devel.x86_64
error:jpeg
yum list | grep jpeg
yum install libjpeg-turbo-devel.x86_64
configure: error: png.h not found.
yum list |grep png
yum install libpng-devel.x86_64
configure: error: freetype.h not found.
yum list |grep freetype
yum install freetype-devel.x86_64
configure: error: mcrypt.h not found. Please reinstall libmcrypt. //最经典的一个错误
yum list|grep mcrypt //结果是本地yum中没找到,必须依靠epel扩展源
rpm -ivh ‘http://www.lishiming.net/data/attachment/forum/epel-release-6-8_64.noarch.rpm‘ //安装epel 扩展源
yum list|grep mcrypt //能在epel扩展源中找到
yum isntall libmcrypt-devel.x86_64
make //编译
echo $? //查看上条命令的执行结果(是否编译成功)
make install //安装
/usr/local/php/bin/php -i|less //查看PHP配置文件
// Configuration File (php.ini) Path => /usr/local/php/etc
// Loaded Configuration File => (none) (加载配置文件路径不存在)
cp php.ini-production /usr/local/php/etc/php.ini //复制配置文件到解决上个路径不存在
apache结合php
vim /usr/local/apache2/conf/httpd.conf //apache的配置文件
找到:
AddType application/x-gzip .gz .tgz
在该行下面添加:
AddType application/x-httpd-php .php
找到:
<IfModule dir_module> DirectoryIndex index.html</IfModule>
将该行改为:
<IfModule dir_module> DirectoryIndex index.html index.htm index.php</IfModule>
找到:
#ServerName www.example.com:80
修改为:
ServerName localhost:80
测试LAMP是否成功
/usr/local/apache2/bin/apachectl -t //启动apache之前先检验配置文件是否正确->Syntax OK
/usr/local/apache2/bin/apachectl start //启动apache,如果打开之后测试出问题,去修改上边的httpd.conf文件
//一定要重启apache——>/usr/local/apache2/bin/apachectl restart
netstat -lnp |grep httpd //查看是否启动
curl localhost //测试
<html><body><h1>It works!</h1></body></html>
vim /usr/local/apache2/htdocs/1.php //测试是否解析PHP
<?php echo "php解析正常";?>
curl localhost/1.phpphp解析正常[root@localhost ~]# //解析正常,如果解析失败,要去仔细检查
//vim /usr/local/apache2/conf/httpd.conf
初次使用浏览器访问我们的web服务的时候,你可能无法访问,这是因为防火墙的缘故
iftables -F //关闭防火墙
在浏览器中输入 127.0.0.1
页面显示 welcome nana //测试成功
LAMP安装细则