lamp安装教程

摘要:
LAMP环境配置安装注意安装步骤及说明事项。下图分别为selinux关闭前和关闭后:2.依赖软件查询http://rpmfind.net一.安装gccgcccloog-pplpplcppmpfrgcc-c++libstdc++-develmpfr-2.4.1-6.el6.i686.rpm和ppl-0.10.2-11.el6.i686.rpm快捷键rzsz:rz、sz命令没找到?安装lrzsz即可:shell>#yum-yinstalllrzsz二.安装zlib压缩库shell>##cd/home/jinnan/tarshell>#tar–zxvfzlib-1.2.5.tar.gzshell>#cdzlib-1.2.5shell>#./configure//这个配置编译命令不要加目录参数shell>#make&&makeinstall三.安装apacheshell>#cd/home/jinnan/tarshell>#tar-jxvfhttpd-2.2.19.tar.bz2shell>#cdhttpd-2.2.19shell>#./configure--prefix=/usr/local/http2--enable-modules=all--enable-mods-shared=all--enable-soshell>#make&&makeinstall启动Apacheshell>#/usr/local/http2/bin/apachectlstart/stop/restart#测试apache浏览器打开:http://虚拟机IP看到"itworks!

LAMP环境配置安装注意安装步骤及说明事项。

Linux + apache+mysql+php

附件:

1. 访问ftp报错

解决:

关闭selinux

vi /etc/selinux/config

内容修改为: selinux=disable

之后重启reboot。

下图分别为selinux关闭前 和 关闭后:

2. 依赖软件查询

http://rpmfind.net

一.安装gcc

gcc

cloog-ppl

ppl(libppl.so.7/libppl_c.so.2)

cpp

mpfr(libmpfr.so.1)

gcc-c++

libstdc++-devel

mpfr-2.4.1-6.el6.i686.rpm和ppl-0.10.2-11.el6.i686.rpm

快捷键rz sz:

rz、sz命令没找到?

安装lrzsz即可:

shell># yum -y install lrzsz

二.安装zlib压缩库

shell>##cd /home/jinnan/tar

shell>#tar –zxvf zlib-1.2.5.tar.gz

shell>#cd zlib-1.2.5

shell>#./configure //这个配置编译命令不要加目录参数

shell>#make && make install

三.安装apache

shell>#cd /home/jinnan/tar

shell>#tar -jxvf httpd-2.2.19.tar.bz2

shell>#cd httpd-2.2.19

shell>#./configure --prefix=/usr/local/http2

--enable-modules=all

--enable-mods-shared=all

--enable-so

shell>#make && make install

启动Apache

shell>#/usr/local/http2/bin/apachectl start/stop/restart

#测试apache

浏览器打开: http://虚拟机IP

看到 "it works!",即为成功

配置虚拟主机

1)配置host文件

打开C:/windows/system32/drivers/etc/hosts 文件

增加域名记录

如:

192.168.9.38 www.ec1.com

192.168.9.38 www.ec2.com

2) 增加虚拟主机

vi /usr/local/http2/conf/httpd.conf

取消# Include conf/extra/httpd-vhosts.conf

这一行前面的#号

保存退出

vi /usr/local/http2/conf/extra/httpd-vhosts.conf

增加虚拟主机记录

<VirtualHost *:80>

ServerAdmin webmaster@dummy-host.example.com

DocumentRoot "/usr/local/http2/htdocs/ec1"

ServerName www.ec1.com

ServerAlias www.dummy-host.example.com

ErrorLog "logs/dummy-host.example.com-error_log"

CustomLog "logs/dummy-host.example.com-access_log" common

</VirtualHost>

<VirtualHost *:80>

ServerAdmin webmaster@dummy-host2.example.com

DocumentRoot "/usr/local/http2/htdocs/ec2"

ServerName www.ec2.com

ErrorLog "logs/dummy-host2.example.com-error_log"

CustomLog "logs/dummy-host2.example.com-access_log" common

</VirtualHost>

<VirtualHost *:80>

DocumentRoot "/var/www/shop"

ServerName www.ec1.com

</VirtualHost>

注意:/var/www/shop 以上三个目录var www shop 的其他用户必须有x可执行权限

3)

shell># cd /usr/local/http2/htdocs

shell># mkdir ec1 ec2

shell># echo this is ec1.com > ec1/index.html

shell># echo this is ec2.com > ec2/index.html

4)重启apache

/usr/local/http2/bin/apachectl restart

5)浏览器打开www.ec1.com,和www.ec2.com

看到不同的网站内容,虚拟主机创建完毕!

安装图形库,为编译PHP做准备

libxml2-2.7.2.tar.gz

jpegsrc.v8b.tar.gz

libpng-1.4.3.tar.gz

freetype-2.4.1.tar.gz

gd-2.0.35.tar.gz

四.安装libxml2

shell>#cd /home/jinnan/tar

shell>#tar zxvf libxml2-2.7.2.tar.gz

shell>#cd libxml2-2.7.2

shell>#./configure --prefix=/usr/local/libxml2

--without-zlib

shell>#make && make install

五.安装jpeg8

shell>#cd /home/jinnan/tar

shell>#tar -zxvf jpegsrc.v8b.tar.gz

shell>#cd jpeg-8b

shell>#./configure --prefix=/usr/local/jpeg

--enable-shared --enable-static

shell>#make && make install

--enable-shared 把jpeg需要的函数库程序都编译到该软件里边

优点:函数调用速度快

缺点:软件本身比较大

--enable-static 静态方式函数处理,需要什么函数,马上include来

优点:软件本身比较小

缺点:函数调用速度慢

六.安装libpng

shell>#cd /home/jinnan/tar

shell>#tar zxvf libpng-1.4.3.tar.gz

shell>#cd libpng-1.4.3

shell>#./configure #和zlib一样不要带参数,让它默认安装到相应目录

shell>#make && make install

七.安装freetype(字体库)

shell>#cd /home/jinnan/tar

shell>#tar zxvf freetype-2.4.1.tar.gz

shell>#cd freetype-2.4.1

shell>#./configure --prefix=/usr/local/freetype

shell>#make && make install

八.安装GD库

shell>#cd /home/jinnan/tar

shell>#tar -zvxf gd-2.0.35.tar.gz

shell>#mkdir -p /usr/local/gd

shell>#cd gd-2.0.35

shell>#./configure --prefix=/usr/local/gd

--with-jpeg=/usr/local/jpeg/

--with-png --with-zlib

--with-freetype=/usr/local/freetype

shell>#make && make install

九.安装 php5

shell>#cd /home/jinnan/tar

shell>#tar -jxvf php-5.3.6.tar.bz2

shell>#cd php-5.3.6

shell>#./configure --prefix=/usr/local/php

--with-apxs2=/usr/local/http2/bin/apxs

--with-mysql=mysqlnd

--with-pdo-mysql=mysqlnd

--with-mysqli=mysqlnd

--with-freetype-dir=/usr/local/freetype

--with-gd=/usr/local/gd

--with-zlib --with-libxml-dir=/usr/local/libxml2

--with-jpeg-dir=/usr/local/jpeg

--with-png-dir

--enable-mbstring=all

--enable-mbregex

--enable-shared

shell>#make && make install

复制php.ini配置文件到指定目录

shell>#cp php.ini-development /usr/local/php/lib/php.ini

配置Apache使其支持php

vi /usr/local/http2/conf/httpd.conf

1) 在httpd.conf(Apache主配置文件)中增加:

AddType application/x-httpd-php .php

2) 找到下面这段话:

<IfModule dir_module>

DirectoryIndex index.php

DirectoryIndex index.html

</IfModule>

在index.html 前面添加index.php

3) 建立php测试网页

vi /usr/local/apache2/htdocs/index.php

输入如下内容:

<?php

phpinfo();

?>

4) 重启apache

shell># /usr/local/http2/bin/apachectl restart

5) 再次浏览器查看http://虚拟机IP

如果看到php信息,工作就完成了!

十.安装MySQL

1.安装cmake(更先进的configure)

shell>#cd /home/jinnan/tar

shell>#tar zxvf cmake-2.8.5.tar.gz

shell>#cd cmake-2.8.5

shell>#./bootstrap

shell>#make && make install

2.编译安装MySQL

shell>#cd /home/jinnan/tar

shell>#tar zxvf mysql-5.5.17.tar.gz

shell>#cd mysql-5.5.17

shell>#cmake

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql

-DMYSQL_DATADIR=/usr/local/mysql/data

-DDEFAULT_CHARSET=utf8

-DDEFAULT_COLLATION=utf8_general_ci

(准备安装到那里

数据存储目录

默认的字符集

校对字符集)

(报错就安装ncurses-devel)

shell># mount .....挂载光盘/

shell>#rpm -ivh ncurses-devel-5.7-3.20090208.el6.i686.rpm

shell># rm -f CMakeCache.txt //删除该文件

shell>#cmake 。。。 。。。 //重新cmake

shell>#make && make install

shell>#cp support-files/my-medium.cnf /etc/my.cnf

3.配置并初始化MySQL

shell># useradd mysql (该mysql用户会存在于同名的组下)

shell># chmod +x /usr/local/mysql

(数据库用户信息不小心删除光了,删除data目录,从此开始执行以下指令,直至结束)

shell># chown -R mysql.mysql /usr/local/mysql

初始化mysql数据库

shell># /usr/local/mysql/scripts/mysql_install_db

--user=mysql

--basedir=/usr/local/mysql

--datadir=/usr/local/mysql/data &

把mysql安装文件(除了data)的主人都改为root,避免数据库恢复为出厂设置。

shell># chown -R root /usr/local/mysql

shell># chown -R mysql /usr/local/mysql/data

& 后台运行mysql服务

shell># /usr/local/mysql/bin/mysqld_safe --user=mysql &

//查看mysql是否有启动

shell># ps –A | grep mysql

测试数据库

shell># /usr/local/mysql/bin/mysql –u root

mysql> show databases;

接上步,修改mysql密码(可不做此步,默认无密码)

mysql> UPDATE user SET Password=password('123456') WHERE user='root';

mysql> flush privileges;

4.配置开机自启动服务项

shell># cp 安装包解压目录/support-files/mysql.server /etc/init.d/mysqld

shell># chmod +x /etc/init.d/mysqld

shell># chkconfig --add mysqld

shell># chkconfig mysqld on //设置开机自启动

配置文件路径:

shell># vi /etc/rc.d/rc.local

在 文件中增加启动相关服务的命令如下:

/usr/local/http2/bin/apachectl start

/usr/local/mysql/bin/mysqld_safe --user=mysql &

service vsftpd start

重新安装apache启动失败

[root@localhost httpd-2.2.19]# /usr/local/http2/bin/apachectl restart

httpd not running, trying to start

(98)Address already in use: make_sock: could not bind to address [::]:80

(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80

no listening sockets available, shutting down

Unable to open logs

原因是80端口被占用

解决:

查看80端口使用情况

[root@localhost httpd-2.2.19]# netstat -lnp|grep 80

tcp 0 0 :::80 :::* LISTEN 28195/httpd

unix 2 [ ACC ] STREAM LISTENING 6580 1957/gpm /dev/gpmctl

unix 2 [ ACC ] STREAM LISTENING 5422 1800/pcscd /var/run/pcscd.comm

查看80的使用者是谁端口

[root@localhost httpd-2.2.19]# ps 28195

PID TTY STAT TIME COMMAND

28195 ? Ss 0:00 /usr/local/http2/bin/httpd -k restart

经过分析知道了80端口被系统的一个进程占用,这个进程是旧的apache服务

将这个进程杀之

[root@localhost httpd-2.2.19]# kill -9 28195

[root@localhost httpd-2.2.19]#

免责声明:文章转载自《lamp安装教程》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇Android Layout: TableLayout核心期刊下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

Linux部署Tomcat、JDK、MySQL(详细步骤)

一、Tomcat安装 1.将tomcat安装包apache-tomcat-7.0.57-windows-x64.zip在本地解压后放到/usr/local目录 2.修改解压后的目录的权限 [root@localhost local]# chmod -cfvR 777 apache-tomcat-7.0.57/ 3.修改环境变量: [root@localho...

MySQL 数据同步

  在当今互联网行业,大多数人互联网从业者对"单元化"、"异地多活"这些词汇已经耳熟能详。而数据同步是异地多活的基础,所有具备数据存储能力的组件如:数据库、缓存、MQ等,数据都可以进行同步,形成一个庞大而复杂的数据同步拓扑。   本文将先从概念上介绍单元化、异地多活、就近访问等基本概念。之后,将以数据库为例,讲解在数据同步的情况下,如何解决数据回环、数据冲...

PHP站内搜索:多关键字、加亮显示

一、SQL语句中的模糊查找       主要通过LIKE(不区分大小写)关键字实现模糊查找。LIKE条件一般用在指定搜索某字段的时候, 通过"%"或者" _" 通配符的作用实现模糊查找功能,通配符可以在字段前面也可以在后面或前后都有。只通过LIKE是无法实现模糊查找的,因此通配符的作用不可忽略。下面是三个实例:搜索以PHP开头:SELECT * FROM ...

Linux的环境变量配置在/etc/profile或/etc/profile.d/*.sh文件中的区别是什么?

@ 目录 login shell non-login shell 它们的区别 Linux的环境变量可在多个文件中配置,如/etc/profile,/etc/profile.d/*.sh,~/.bashrc等,下面说明上述几个文件之间的关系和区别。 bash的运行模式可分为login shell和non-login shell。 login she...

MySQL具体解释(8)----------MySQL线程池总结(二)

这篇文章是对上篇文章的一个补充,主要环绕下面两点展开。one-connection-per-thread的实现方式以及线程池中epoll的使用。 one-connection-per-thread 依据scheduler_functions的模板,我们也能够列出one-connection-per-thread方式的几个关键函数。 static sche...

Mysql,SqlServer,Oracle主键自动增长的设置

在mysql中,如果把表的主键设为auto_increment类型,数据库就会自动为主键赋值。例如: CREATE TABLE google(id INT AUTO_INCREMENT PRIMARY KEY NOT NULL,NAME VARCHAR(15),age INT,email VARCHAR(50),gender VARCHAR(10)) i...