一、使用apt-get方式为Ubuntu安装PHP+MYSQL+Apache
分别执行如下命令:
(1)安装MYSQL
sudo apt-get install mysql-server
sudo apt-get install mysql-client
(2)安装Apache
sudo apt-get install apache2
(3)安装PHP
www.2cto.com
sudo apt-get install php5
sudo apt-get install libapache2-mod-auth-mysql
sudo apt-get install php5-mysql
安装结束后,检测是否成功:
(1)检测Mysql是否正常
在终端中输入:mysql -uusername -ppassword (将username和password替换为你所设置的)看是否可以正常登陆
(2)检测Apache是否正常
在浏览器中打开:http://localhost/
如果出现如下信息,则表明正常。
It works!
This is the default web page for this server.
www.2cto.com
The web server software is running but no content has been added, yet.
(3)检测PHP是否正常
Ubuntu下Apache的默认安装路径为/var/www/,到其目录下新建info.php文件,文件内容为:
<?php
phpinfo();
?>
然后在浏览器中打开:http://localhost/info.php 看是否正常。
注:在该目录直接新建文件是没有权限的,为其增加当前用户权限:
su root(用root用户)
chown username /var/www(将username替换为您当前用户的用户名)
exit(退出root)
如果,您的ubuntu系统root用户还不可用,那是因为ubuntu系统默认root密码为空,您可以通过如下命令设置密码:
sudo passwd -l root
二、手工编译为Ubuntu安装PHP+MYSQL+Apache
www.2cto.com
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:wgethttp://125.39.113.23:9203/CDE349DEF7D7A6AC19DE5771F752CA258C693F634815D4BE/cn.php.net/distributions/php-5.2.10.tar.bz2
2、安装MySql
安装步骤:
shell> groupadd mysql
www.2cto.com
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
www.2cto.com
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
www.2cto.com
保存退出编译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看看
www.2cto.com
/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
www.2cto.com
(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
www.2cto.com
(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保护模式引起的。
解决办法:
www.2cto.com
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
www.2cto.com
修改php.ini文件
register_globals = On
ok!重新启动一下apache服务器
/usr/local/apache/bin/apachectl restart
然后写个php测试页info.php:内容如下
<?php
phpinfo();
?>
正常的话,应该能看到php的信息了,恭喜你的Apche+Mysql+PHP安装成功。
- ubuntu下搭建LAMP环境
本文参考:http://www.linuxdiyf.com/linux/21265.html 请支持原创. 步骤一:安装apache root@mrwang:~$ sudo apt install a ...
- linux下搭建lamp环境以及安装swoole扩展
linux下搭建lamp环境以及安装swoole扩展 一.CentOS 6.5使用yum快速搭建LAMP环境 准备工作:先更新一下yum源 我安装的环境是:apache2.2.15+mysql5 ...
- 在Ubuntu下搭建ASP.NET 5开发环境
在Ubuntu下搭建ASP.NET 5开发环境 0x00 写在前面的废话 年底这段时间实在太忙了,各种事情都凑在这个时候,没时间去学习自己感兴趣的东西,所以博客也好就没写了.最近工作上有个小功能要做成 ...
- CentOS下搭建LAMP环境详解
前言:在这里将介绍如何在CentOS下搭建LAMP环境(全部使用源码编译安装),用于web服务器开发. •LAMP: Linux + Apache + PHP + Mysql. •系统: CentOS ...
- 在Linux(Ubuntu)下搭建ASP.NET Core环境并运行 继续跨平台
最新教程:http://www.cnblogs.com/linezero/p/aspnetcoreubuntu.html 无需安装mono,在Linux(Ubuntu)下搭建ASP.NET Core环 ...
- Ubuntu下搭建NodeJS+Express WEB开发框架
Ubuntu下搭建NodeJS+Express WEB开发框架 2012-12-27 15:06 作者: NodeJSNet 来源: 本站 浏览: 2,966 次阅读 我要评论暂无评论 字号: 大 中 ...
- Centos6.4版本下搭建LAMP环境
Centos6.4版本下搭建LAMP环境 配置yum mkdir/mnt/cdrom mount/dev/cdrom /mnt/cdrom 装载光盘 vi /etc/yum.repos.d/Cent ...
- 如何在Ubuntu下搭建Android NDK开发环境
1 搭建Android SDK开发环境 参考在在Ubuntu下搭建Android SDK开发环境(图文)首先在Ubuntu下搭建Android SDK开发环境. 2 下载NDK开发包 打开官网: ht ...
- Ubuntu下搭建ASP.NET 5
在Ubuntu下搭建ASP.NET 5开发环境 0x00 写在前面的废话 年底这段时间实在太忙了,各种事情都凑在这个时候,没时间去学习自己感兴趣的东西,所以博客也好就没写了.最近工作上有个小功能要 ...
随机推荐
- 分享我用Qt开发的应用程序【二】在Qt应用程序中使用字体图标fontawesome
为了使用简单,需要先写一个单件类,头文件的代码如下: 其中静态方法Instance保证IconHelper的实例全局唯一 (注意构造函数已经私有化了) #ifndefICONHELPER_H #def ...
- [ACM_水题] ZOJ 3706 [Break Standard Weight 砝码拆分,可称质量种类,暴力]
The balance was the first mass measuring instrument invented. In its traditional form, it consists o ...
- [MFC] 如何更改MFC程序图标
方法一: >_<:找一张ICO图标,替换programname/res/programname.ico文件,就可以啦,这时候你运行后得到的图标可能还是原来MFC的默认图标,这时候你只要把工 ...
- C# 通过SerialPort简单调用串口
问题 最近比较经常使用串口进行发送以及传输数据,但是笔者在刚开始接触SerialPort类时,对于Write之后去Read数据的时候,由于设备上面还没有返回数据,读取到的只能是空值.然而,再进行下一次 ...
- DigitalOcean上使用Tornado+MongoDB+Nginx+Supervisor+DnsPod快速搭建个人博客
DigitalOcean 之前买了个便宜的VPS并且在上面搭建了我自己写的博客程序,后来VPS里运行MongoDB经常自己挂掉就索性没理了.直到现在VPS已经过期,服务器被强制关掉了.周末在家索性想着 ...
- CentOS下搭建NFS服务器总结
环境介绍: . 服务器: 192.168.0.100 . 客户机: 192.168.0.101 安装软件包: . 服务器和客户机都要安装nfs 和 rpcbind 软件包: yum -y instal ...
- iOS开发---分类和扩展(Categories和Extensions)
1.分类能够做到的事情主要是:即使在你不知道一个类的源码情况下,向这个类添加扩展的方法. 此外,分类能够保证你的实现类和其他的文件区分开. 1 #import “UIViewControl ...
- IT 需要知道的一些专业名词和解释 (长期更新)
c2c: 就是我卖东西你来买 (comsumer to comsumer个人对个人) b2c: 就是我开公司卖东西你来买 (business to comsumer 公司对个人) o2o: 就是我开 ...
- Java 线程 — JMM Java内存模型
JMM Java Memory Model,Java内存模型,属于语言级的内存模型 并发编程中存在的问题: 如何通信:用于线程之间交换信息.两种方式:共享内存,消息传递 如何同步:用于控制不同线程间操 ...
- [GO编程]GO编程环境
GO是一个开源项目,由Google大神发明的,他主要是用于应用程序级开放,可以编译成机器码,和C++一样不需要.NET或JAVA那样的运行框架,因此是个不错的编程语言.更何况发明者都是高手中的高手,而 ...