CentOS下安装AMP

1、安装mysql
shell> groupadd mysql
shell> useradd -g mysql mysql
shell> tar zxvf mysql.tar.gz
shell> cd mysql-VERSION
shell> ./configure --prefix=/usr/local/mysql --enable-assembler --with-mysqld-ldflags=-all-static --with-extra-charsets=all --with-big-tables --with-charset=utf8 --with-collation=utf8_unicode_ci
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 & (启动服务器)
shell> mysqladmin -u root -p password '1234' (修改root用户密码)
shell> cp /usr/local/mysql/share/mysql/mysql.server /etc/rc.d/init.d/mysqld
shell> chmod 700 /etc/rc.d/init.d/mysqld
shell> chkconfig --add mysqld (以上三行作为mysql自动启动来用)

2、安装apache
解压httpd-2.0.59.tar.gz
# tar -zvxf httpd-2.0.59.tar.gz
进入httpd-2.0.59目录
# cd httpd-2.0.59
生成/usr/local/apache2目录
# mkdir -p /usr/local/apache2
配置安装目录
# ./configure --prefix=/usr/local/apache2 --enable-modules=so --enable-rewrite
编译
# make
安装
# make install
安装完毕
#/usr/local/apache2/bin/apachectl -k start
启动测试

让apahce系统启动时自动启动
从/usr/local/apache2/bin/apachectl 到 /etc/rc.d/init.d/httpd 建立一个符号连接:
# ln -s /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd

然后在此文件总添加以下几行(大概在文件顶部,约第二行的地方):

# chkconfig: 2345 30 100
# description: Activates/Deactivates Apache Web Server

最后,运行chkconfig把Apache添加到系统的启动服务组里面:

# /sbin/chkconfig --del httpd
# /sbin/chkconfig --add httpd

另外一种方法系统启动时加载apache
cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpd
cd /etc/rc.d/rc3.d
ln -s ../init.d/httpd S80httpd

3、第三方库

安装 libxml2
tar -zxvf libxml2-2.6.19.tar.gz
cd libxml2-2.6.19
./configure --prefix=/usr/local/libxml2
make
make install
这一步结束时,libxml2被安装在/usr/local/下。

安装 zlib
tar -zxvf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure --prefix=/usr/local/zlib
make
make install
这一步结束时,zlib被安装在/usr/local/下。

安装 libpng
tar -zxvf libpng-1.2.10.tar.gz
cd libpng-1.2.10
cp scripts/makefile.linux makefile
make
make install
注意:这里的makefile不是用./configure 生成的,而是直接从script/目录里拷一个
这一步结束时,zlib被安装在/usr/local/lib下

安装 freetype
tar -zxvf freetype-2.2.1.tar.gz
cd freetype-2.2.1
./configure --prefix=/usr/local/freetype
make
make install
这一步结束时,freetype被安装在/usr/local/lib下

安装 jpeg6
建立目录
mkdir /usr/local/jpeg6
mkdir /usr/local/jpeg6/bin
mkdir /usr/local/jpeg6/lib
mkdir /usr/local/jpeg6/include
mkdir /usr/local/jpeg6/man
mkdir /usr/local/jpeg6/man/man1
tar -zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b
./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
make
make install
注意:这里./configure一定要带--enable-shared参数,不然,不会生成共享库

安装 gd
tar -zxvf gd-2.0.33.tar.gz
cd gd-2.0.33
./configure --prefix=/usr/local/gd --with-png=/usr/local/lib --with-freetype=/usr/local/freetype --with-jpeg=/usr/local/jpeg6
make && make install

4、安装PHP
./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/etc --with-libxml-dir=/usr/local/libxml2 --with-zlib-dir=/usr/local/zlib --with-gd=/usr/local/gd --with-jpeg-dir=/usr/local/jpeg6 --with-png-dir=/usr/local/lib --with-freetype-dir=/usr/local/freetype --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-openssl --enable-gd-native-ttf --enable-mbstring --enable-ftp --enable-bcmath --enable-sockets --enable-zip --enable-soap --enable-calendar
make
make install
cp php.ini-dist /etc/php.ini

5、整合apache2和php5
apache 配置文件及目录是:
/usr/local/apache2/conf/httpd.conf
apache 默认存放主页的位置是:
/usr/local/apache2/htdocs
以下是配置文件里面的信息:(有的地方要做修改)
ServerRoot "/usr/local/apache2"
这是指定apache程序所在的目录,比如日志文件、配置文件等目录。
DocumentRoot "/usr/local/apache2/htdocs"
这个是存放网页的目录

这一句应该和DocumentRoot的目录保持一致。
找到 DirectoryIndex index.html
改为 DirectoryIndex index.html index.html.var index.htm index.php
找到 AddType application/x-gzip .gz .tgz
加 AddType application/x-httpd-php .php (注意空格)
AddType application/x-httpd-php-source .phps
添加 AddDefaultCharset utf8 使apache默认支持utf8字符集
保存配置文件就重启apache 的守护进程。
/usr/local/apache2/bin/apachectl restart

注意: 
每次更改配置文件。要重启服务。
对存放网页的目录执行:命令chmod 755 目录名 或者 chmod -R 755 目录名

编辑php.ini文件,找到
;default_charset="iso-8859-1"
增加一行:default_charset="utf8"

以上步骤都执行完后。在/usr/local/apache2/htdocs/里编辑文件进行测试。
phpinfo.php
里面的内容:
phpinfo();
?>
在浏览器地址栏中输入:
http://localhost/phpinfo.php
出现php说明页面说明安装成功。

 

 

在linux上安装有些东西时会出现 Permission denied 的情况:以下就是解决它的办法之一
编辑/etc/selinux/config,找到这段:
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=enforcing

把 SELINUX=enforcing 注释掉:#SELINUX=enforcing ,然后新加一行为:
SELINUX=disabled
保存,关闭。
......

编辑/etc/sysconfig/selinux,找到:
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=enforcing

如果SELINUX已经是 SELINUX=disabled,那么就不用改了,否则就把SELINUX=enforcing 注释掉,新加一行:
SELINUX=disabled
保存,退出。

如果你碰到其他类似提示:
cannot restore segment prot after reloc: Permission denied
哪应该是SELinux的问题,可以考虑把它关闭。
-------------------------------------------------------------------------------------
郁闷的是.我把SELinux关闭后还是不行.于是到google上search.发现这个很有用.
在你保证SElinux 被disable后.还执行下
chcon -t texrel_shlib_t
如: chcon -t texrel_shlib_t /路径/路径/名字.so (这个文件视具体执行文件.)

以上两步.已经解决了很多server的问题了.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值