1、安装LAMP
1.1 安装apache
yum install httpd
1.2 安装mysql
yum install mysql mysql-server
1.3 安装php
yum install php
yum install php-mysql php-gd
yum install libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc
yum install php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt
2、配置
2.1、apache配置(可选)
vi /etc/httpd/conf/httpd.conf #编辑文件
ServerTokens OS 在44行 修改为:ServerTokens Prod (在出现错误页的时候不显示服务器操作系统的名称)
ServerSignature On 在536行 修改为:ServerSignature Off (在错误页中不显示Apache的版本)
Options Indexes FollowSymLinks 在331行 修改为:Options Includes ExecCGI FollowSymLinks(允许服务器执行CGI及SSI,禁止列出目录)
#AddHandler cgi-script .cgi 在796行 修改为:AddHandler cgi-script .cgi .pl (允许扩展名为.pl的CGI脚本运行)
AllowOverride None 在338行 修改为:AllowOverride All (允许.htaccess)
AddDefaultCharset UTF-8 在759行 修改为:AddDefaultCharset GB2312 (添加GB2312为默认编码)
Options Indexes MultiViews FollowSymLinks 在554行 修改为 Options MultiViews FollowSymLinks(不在浏览器上显示树状目录结构)
DirectoryIndex index.html index.html.var 在402行 修改为:DirectoryIndex index.html index.htm Default.html Default.htm
index.php Default.php index.html.var (设置默认首页文件,增加index.php)
KeepAlive Off 在76行 修改为:KeepAlive On (允许程序性联机)
MaxKeepAliveRequests 100 在83行 修改为:MaxKeepAliveRequests 1000 (增加同时连接数)
/etc/init.d/httpd restart #重启
rm -f /etc/httpd/conf.d/welcome.conf /var/www/error/noindex.html #删除默认测试页
2.2、php配置(可选)
vi /etc/php.ini #编辑
date.timezone = PRC #在946行 把前面的分号去掉,改为date.timezone = PRC
disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname
#在386行 列出PHP可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用。
expose_php = Off #在432行 禁止显示php版本的信息
magic_quotes_gpc = On #在745行 打开magic_quotes_gpc来防止SQL注入
short_open_tag = ON #在229行支持php短标签
open_basedir = .:/tmp/ #在380行 设置表示允许访问当前目录(即PHP脚本文件所在之目录)和/tmp/目录,可以防止php木马跨站,如果改了之后安装程序有问题(例如:织梦内容管理系统),可以注销此行,或者直接写上程序的目录/data/www.osyunwei.com/:/tmp/
:wq! #保存退出
/etc/init.d/mysqld restart #重启MySql
/etc/init.d/httpd restart #重启Apche
cd /var/www/html
vi index.php #输入下面内容
<?php
phpinfo();
?>
:wq! #保存退出
注意:apache默认的程序目录是/var/www/html
权限设置:chown apache.apache -R /var/www/html
2.3 mysql 配置
创建用户istore
create user istore@localhost idenified by '1234';
grant all privileges on *.* to istore@localhost;
flush privileges;
3 安装owncloud将owncloud安装包下载后复制到/var/www/html目录,修改owncloud的目录权限。在浏览器中输入ip:port/owncloud,按照提示安装即可。
4、问题与解决办法
4.1 问:yum install不能安装软件。
答:
a、检查了一下,原来是机器没有联网(囧)
b、更新源。方法:http://www.oicto.com/centos-yum-163-sohu/
4.2 问:打开浏览器输入网址后,页面空白
答:查询了apache的日志(这个非常重要),日志目录为/var/log/httpd/,里面的error_log文件,错误显示不能解析一些字符,上网查了一下,原来是php的版本低,要5.3以上。下面是升级php的过程:
Install the extra repositories
The first step requires downloading and installing some RPM files that contain the additional repository definitions, which we'll do with the rpm command:
sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm sudo rpm -Uvh http://repo.webtatic.com/yum/centos/5/latest.rpm
Once installed you should see some additional repository definitions under the /etc/yum.repos.d directory.
$ ls -1 /etc/yum.repos.d/epel* /etc/yum.repos.d/webtatic.repo /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/webtatic.repo
Enable the webtatic repository
The webtatic repository provides a variety of up-to-date packages that are useful or are a requirement for many popular web-based services. That means it generally is not a bad idea to enable the webtatic repository by default.
First, open the /etc/yum.repos.d/webtatic.repo repository file using a text editor of your choice,
sudo vim /etc/yum.repos.d/webtatic.repo
Edit the [webtatic] section of the file so that the enabled option is set to 1. This will enable the remi repository.
[webtatic] name=Webtatic Repository $releasever - $basearch #baseurl=http://repo.webtatic.com/yum/centos/5/$basearch/ mirrorlist=http://repo.webtatic.com/yum/centos/5/$basearch/mirrorlist enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-webtatic-andy
Installing the PHP 5.3 packages
This section will aim to install PHP 5.3 and any relevant additional modules that may be required. If you are upgrading from an older PHP version to PHP 5.3 please skip to the next section.
The following is an example of a single-shot command of the installation of PHP 5.3 and some common modules:
$ sudo yum install php php-cli php-gd php-mysql php-mbstring
The following is a sample trace output (make note of the package version and the repository):
... Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: php x86_64 5.3.20-1.w5 webtatic 1.4 M php-cli x86_64 5.3.20-1.w5 webtatic 2.6 M php-gd x86_64 5.3.20-1.w5 webtatic 108 k php-mbstring x86_64 5.3.20-1.w5 webtatic 1.2 M php-mysql x86_64 5.3.20-1.w5 webtatic 91 k Installing for dependencies: apr x86_64 1.3.12-1.w5 webtatic 102 k apr-util x86_64 1.3.12-1.w5 webtatic 84 k apr-util-ldap x86_64 1.3.12-1.w5 webtatic 15 k ... Transaction Summary ================================================================================ Install 26 Package(s) Upgrade 0 Package(s) ... warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID cf4c4ff9 webtatic/gpgkey | 1.6 kB 00:00 Importing GPG key 0xCF4C4FF9 "Andy Thompson <xx@xx.com>" from /etc/pki/rpm-gpg/RPM-GPG-KEY-webtatic-andy Is this ok [y/N]: y ...
To search for available PHP-related packages we can run the following command:
yum search php
Typically the names of php modules begin with php-. Be careful about any packages that start with php53- as these will conflict with the webtatic versions.
Once you've installed PHP and any required supporting modules, skip to the "Last Steps" section below.
Upgrading to PHP 5.3 packages
If you already have PHP installed the upgrade steps are slightly different.
Warning: Before performing this upgrade please take the time to do a full backup of your system. The upgrade should generally be straightforward, but this will depend on the existing package state of your system.
To upgrade php, run:
$ rpm -q php php-5.1.6-27.el5_5.3 $ sudo yum upgrade php ... Dependencies Resolved =================================================================================== Package Arch Version Repository Size =================================================================================== Updating: php x86_64 5.3.20-1.w5 webtatic 1.4 M Installing for dependencies: ... Updating for dependencies: php-cli x86_64 5.3.20-1.w5 webtatic 2.6 M php-gd x86_64 5.3.20-1.w5 webtatic 108 k php-mbstring x86_64 5.3.20-1.w5 webtatic 1.2 M php-mysql x86_64 5.3.20-1.w5 webtatic 91 k Transaction Summary =================================================================================== ... $ rpm -q php php-5.3.20-1.w5
The above commands will check the installed PHP version then update the existing php package and any associated packages to the 5.3 version in the webtatic and epel repositories.
Last steps
At this point you should have PHP 5.3 installed using the webtatic package repository. The last thing to do is to restart apache if it is currently running so that the new PHP version is loaded.
$ sudo /etc/init.d/httpd restart
A quick confirmation from the terminal should let you check the PHP version:
$ php -v PHP 5.3.20 (cli) (built: Dec 20 2012 18:11:02) Copyright (c) 1997-2012 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies安装之后页面出来了,但是提示php 的dom module没有安装,执行命令yum install php-xml,问题解决。
附:linux下apache的管理与配置:http://blog.csdn.net/ylqmf/article/details/5291680