今天介绍一下Linux下LAMP(Apache+PHP+MySql)环境配置:

1、下载软件

MySql:wget http://down1.chinaunix.net/distfiles/mysql-5.0.56.tar.gz

Apache:wget http://apache.freelamp.com/httpd/httpd-2.2.13.tar.gz

PHP:wget http://125.39.113.23:9203/CDE349DEF7D7A6AC19DE5771F752CA258C693F634815D4BE/cn.php.net/distributions/php-5.2.10.tar.bz2

2、安装MySql

安装步骤:

shell> groupadd mysql

shell> useradd -g mysql mysql

shell> gunzip < mysql-VERSION.tar.gz | tar -xvf – 或 tar -zxvf  mysql-5.0.56.tar.gz(解压mysql源码包)

shell> cd mysql-VERSION(进入mysql源码文件夹)

shell> ./configure –prefix=/usr/local/mysql

shell> make

shell> make install

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

shell> cd /usr/local/mysql

shell> bin/mysql_install_db –user=mysql

shell> chown -R root  .

shell> chown -R mysql var

shell> chgrp -R mysql .

shell> bin/mysqld_safe –user=mysql &

修改mysql root 密码
$ mysqladmin -u root password newpass
添加服务项
cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
chkconfig –add mysqld

3、安装Apache

tar zvxf httpd-2.2.13.tar.gz
cd httpd-2.2.13
修改src/include/httpd.h 增大最大线程数

#define HARD_SERVER_LIMIT 256

改成

#define HARD_SERVER_LIMIT 2560

保存退出编译apache
./configure –prefix=/usr/local/apache –enable-module=so –enable-module=rewrite –enable-shared=max –htdocsdir=/var/www &&
make
make install

#这里我们通过enable-module参数告诉设置脚本,我们需要启动so和rewrite模块,so模块是用来提DSO支持的apache核 心模块,而rewrite模块则是用意实现地址重写的模块,由于rewrite模块需要DBM支持,如果在初次安装时没有编译进apache,以后需要用 到时需要重新编译整个apache才可以实现。为此除非你可以确定以后不会用到rewrite模块,否则还是建议你在第一次编译的时候把rewrite模 块编译好。

enable-shared=max 这个参数的作用时编译apache时,把除了so以外的所有apache的标准模块都编译成DSO模块。而不是编译进apache核心内。

好了安装apache很简单的哦,启动apache看看

/usr/local/apache/bin/apachectl start
然后 通过浏览器查看http://youhost/,如果正常则说明安装成功。

apache设为linux服务

cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd
vi /etc/init.d/httpd

在在#!/bin/sh后面加入下面两行
#chkconfig:345 85 15
#description: Start and stops the Apache HTTP Server.

然后
chmod +x /etc/rc.d/init.d/httpd
chkconfig –add httpd

4、安装PHP

(1)tar zvxf php-5.2.10.tar.bz2
(2)cd php-5.2.10

(3)./configure -prefix=/usr/local/php –with-config-file-path=/usr/local/php/etc -with-mysql=/usr/local/mysql –with-mysqli=/usr/local/mysql/bin/mysql_config –with-iconv-dir=/usr/local –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –with-libxml-dir=/usr –enable-xml –disable-rpath –enable-discard-path –enable-safe-mode –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –with-curl –with-curlwrappers –enable-mbregex –enable-fastcgi –enable-fpm –enable-force-cgi-redirect –enable-mbstring –with-mcrypt –with-gd –enable-gd-native-ttf –with-openssl –with-mhash –enable-pcntl –enable-sockets –with-ldap –with-ldap-sasl –-with-apxs2=/usr/local/apache/bin/apxs

(4)make

(5)make install

最后一步重新启动apache报如下错误:
httpd: Syntax error on line 53 of /usr/local/apache/conf/httpd.conf: Cannot load /usr/local/apache/modules/libphp5.so into server: /usr/local/apache/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied

原因:是Linux有一个SELinux保护模式引起的。

解决办法:

1关闭SELINUX的方法:
vi /etc/selinux/config 将SELINUX=enforcing 改成SELINUX=disabled 需要重启
这个方法可能会对服务器带来风险。

2不关闭SELINUX的方法:
依次执行如下命令
# setenforce 0
# chcon -c -v -R -u system_u -r object_r -t textrel_shlib_t /usr/local/apache/modules/libphp5.so

# service httpd restart
# setenforce 1

vi /usr/local/apache/conf/httpd.conf

查找

在此范围添加

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

然CPOPY PHP的配置文件

cp ../php-5.2.10/php.ini.dist /usr/local/php/lib/php.ini

修改php.ini文件
register_globals = On

ok!重新启动一下apache服务器
/usr/local/apache/bin/apachectl restart

然后写个php测试页info.php:内容如下

<?php
phpinfo();
?>
正常的话,应该能看到php的信息了,恭喜你的Apche+Mysql+PHP安装成功。

此文章为转载  http://www.fovweb.com/web/lamp-2.html

转载于:https://www.cnblogs.com/dcj890828/articles/3497094.html

ubuntu 安装 lamp 环境相关推荐

  1. ubuntu lamp php5.6,Ubuntu安装LAMP环境(PHP5.6) 以及下载安装phpmyadmin

    参考路径: http://blog.nciaer.com/?p=133 修改apache(2.4.18)的web路径时, 需要将 /etc/apache2/sites-available/000def ...

  2. Ubuntu一键安装LAMP环境

    ubuntu是一款以桌面应用为主的开源linux操作系统,作为初学者学习linux操作系统,也更为简单和容易上手.在Ubuntu上搭建lamp系统的方式有很多,这里就介绍一种最简单高效的安装方法: a ...

  3. CentOS 6.5系统使用yum方式安装LAMP环境和phpMyAdmin,mysql8.0.1/mysql5.7.22+centos7,windows mysql安装、配置...

    介绍如何在CentOs6.2下面使用YUM配置安装LAMP环境,一些兄弟也很喜欢使用编译的安装方法,个人觉得如果不是对服务器做定制,用yum安装稳定简单,何必去download&make&am ...

  4. 利用yum 安装 lamp环境搭载 cacti监控和memcached数据库

    今天测试了一下yum安装lamp和cacti监/控已经memcached数据库 首先介绍下我的系统环境 centos6.7 x86-64 1安装cacti yum install cacti 安装ca ...

  5. centos 7 安装 mantisbt-2.12.0 —— 安装LAMP环境、安装mantisbt-2.12.0

    一.安装LAMP环境 1 二. 环境的启动 6 三. Mantis数据库的创建 6 四. 安装mantis-2.12.0 9 1>安装配置 9 2>登录管理员账号 13 3>新建用户 ...

  6. 一键编译安装LAMP环境

    一键编译安装LAMP环境 说明:请把所需要的软件包放在文件夹中,把文件夹重命名为packages,然后压缩成packages.zip的包,上传到linux系统上任何目录都可以,然后在上传package ...

  7. Ubuntu安装Go环境以及GoLand编辑器

    GO Ubuntu安装Go环境 下载Go包 地址: Go官网 下载 根据主机架构uname -i选择对应的包 wget https://golang.google.cn/dl/go1.18.3.lin ...

  8. 源码编译安装LAMP环境

    1.请描述一次完整的http请求处理过程: 2.httpd所支持的处理模型有哪些,他们的分别使用于哪些环境. 3.源码编译安装LAMP环境(基于wordpress程序),并写出详细的安装.配置.测试过 ...

  9. Ubuntu安装Java环境

    Ubuntu安装Java环境 执行以下命令即可安装 #安装依赖 sudo apt-get install python-software-properties sudo add-apt-reposit ...

最新文章

  1. 这样给学妹讲原码、反码、补码,帮她彻底解决困扰了三天的问题
  2. golang 所有进程休眠_golang 垃圾回收(三)插入写屏障
  3. Vue项目实战08 : vue之mixin理解与使用
  4. Serverless 终结 Kubernetes?
  5. static详解java_java中static作用详解
  6. 这是一个成长差异化的时代
  7. ios pull代码不提示成功_pullRefresh ios版问题 跪求大神帮助啊
  8. React-native集成tfs自动发版问题
  9. Redis配置和持久性
  10. 终点与起点——诺基亚 N9 初步上手
  11. 交换机的接口类型和Ensp中线缆类型
  12. 计算流体动力学软件和服务市场现状研究分析-
  13. mongodb数据库添加账号
  14. 答读者:数学不好,能学好算法吗?
  15. 帝国cms 留言反馈 问题
  16. php留言板的实验步骤,PHP实现基本留言板功能原理与步骤详解
  17. 五-中, Spark 算子 吐血总结(转化+行动算子共三十七个)
  18. 汇编入门(长文多图,流量慎入!!!)
  19. 【矩阵论笔记】谱半径
  20. 聊一聊,如何做好垂直域稳定性

热门文章

  1. 批量插入/修改网页代码的asp脚本
  2. 一个具体的例子学习Java volatile关键字
  3. gitlab8.2-8.16-8.17-9.0升级
  4. PXE自动化安装系统
  5. MongoDB分片详细说明(ITSOM)
  6. Uber将动态调价机制引入其外卖服务UberEats
  7. 数据管控引领科技未来
  8. Ubuntu 安装NVidia驱动
  9. 2、ESXI安装出错
  10. Visual Studio跨平台开发实战(2) - Xamarin.iOS基本控制项介绍