Centos5.4 _x86 _64位操作系统
httpd-2.2.15.tar.gz
mysql-5.5.2-m2.tar.gz
php-5.3.2.tar.gz
如果出现问题 并且在过程中没有说明,请看文章尾部的 常见问题
如果下面不能成功安装的话可以参考我自己的安装过程(注意 php mysql apache 的版本号)
地址:/qingfeng/articles/2080333.html
1.lsb_release –a 查看系统环境
[root@localhost ~]# lsb_release -aLSB Version: :core-3.1-amd64:core-3.1-ia32:core-3.1-noarch:graphics-3.1-amd64:graphics-3.1-ia32:graphics-3.1-noarchDistributor ID: CentOSDescription: CentOS release 5.4 (Final)Release: 5.4Codename: Final[root@localhost ~]#
2.查找是否已经安装过环境
[root@localhost www]# rpm -qa|grep httpd[root@localhost www]# rpm -qa|grep mysqld[root@localhost www]# rpm -qa|grep php[root@localhost www]# rpm -qa|grep apache如果找到 删除 (--nodeps 是强制删除的意思)[root@localhost ~]# rpm -qa|grep httpdhttpd-2.2.3-31.el5.centos[root@localhost ~]# rpm -e --nodeps httpd3.解压缩[root@localhost www]# tar -zxf httpd-2.2.15.tar.gz [root@localhost www]# tar -zxf mysql-5.5.2-m2.tar.gz [root@localhost www]# tar -zxf php-5.3.2.tar.gz
4.安装mysql (新建用户组mysql 当然如果有就不用重建 )
4.安装mysql (新建用户组mysql 当然如果有就不用重建 )[root@localhost www]# groupadd mysql[root@localhost www]# useradd -g mysql -c "MySQL Server" mysql第二句的意思是:添加一个用户mysql 到 mysql这个组中, 备注是 MySQL Server[root@localhost www]# cd /var/www/mysql-5.5.2-m2 (进入mysql的文件夹)[root@localhost mysql-5.5.2-m2]# chown -R root.root * (更改当前文件夹拥有者)(下面代码要复制全 从 ./configure 到 --without-bench)[root@localhost mysql-5.5.2-m2]# ./configure \> --prefix=/usr/local/mysql \ (mysql安装路径)> --localstatedir=/usr/local/mysql/data \(mysql数据库存放路径)> --disable-maintainer-mode \(服务器用来与本地客户端进行通信的Unix套接字文件)> --with-mysqld-user=mysql \> --with-unix-socket-path=/tmp/mysql.sock \> --without-comment \> --without-debug \> --without-bench
网上找到的资料 如果报错 请核对是否是下面的错误 并查看其下面的连接
18-Jul-: If you are installing MySQL 4.0.x on Fedora Core 4, there is a problem with LinuxThreads that prevents MySQL from compiling properly. Installing on Fedora Core 3 works fine though. Thanks to Kevin Spencer for bringing this to my attention. There is a workaround listed at/bug.php?id=9497. Thanks to Collin Campbell for that link. Another solution can be found at/bug.php?id=2173. Thanks to Kaloyan Raev for that one.
[root@localhost mysql-5.5.2-m2]# make;make install (此处需要一段时间,特别到一处要停留一段时间,需要等待一下)
5.配置mysql
[root@localhost mysql-5.5.2-m2]# ./scripts/mysql_install_db (初始化mysql)[root@localhost mysql-5.5.2-m2]# chown -R root:mysql /usr/local/mysql/[root@localhost mysql-5.5.2-m2]# chown -R mysql:mysql /usr/local/mysql/data/[root@localhost mysql-5.5.2-m2]# cp support-files/my-f /etc/f[root@localhost mysql-5.5.2-m2]# chown root:sys /etc/f [root@localhost mysql-5.5.2-m2]# chmod 644 /etc/f
If you get an error message about thedata
directory not existing, etc., something went wrong in themysql_install_db
step above. Go back and review that; make sure you didn't get some sort of error message when you ran it, etc.
[root@localhost mysql-5.5.2-m2]# echo "/usr/local/mysql/lib/mysql/" >> /etc/ld.so.conf[root@localhost mysql-5.5.2-m2]# ldconfig[root@localhost mysql-5.5.2-m2]# cp ./support-files/mysql.server /etc/rc.d/init.d/mysql[root@localhost mysql-5.5.2-m2]# chmod +x /etc/rc.d/init.d/mysql [root@localhost mysql-5.5.2-m2]# /sbin/chkconfig --level 3 mysql on[root@localhost mysql-5.5.2-m2]# cd /usr/local/mysql/bin/[root@localhost bin]# for file in *; do ln -s /usr/local/mysql/bin/$file /usr/bin/$file; done
[root@localhost ~]# cd /etc/rc.d/rc3.d/[root@localhost rc3.d]# ll
总计 292lrwxrwxrwx 1 root root 17 12-16 02:12 K01dnsmasq -> ../init.d/dnsmasqlrwxrwxrwx 1 root root 24 12-16 02:16 K02avahi-dnsconfd -> ../init.d/avahi-dnsconfdlrwxrwxrwx 1 root root 24 12-16 02:17 K02NetworkManager -> ../init.d/NetworkManagerlrwxrwxrwx 1 root root 17 12-16 02:14 K02oddjobd -> ../init.d/oddjobdlrwxrwxrwx 1 root root 16 12-16 02:10 K05conman -> ../init.d/conmanlrwxrwxrwx 1 root root 19 12-16 02:12 K05saslauthd -> ../init.d/saslauthdlrwxrwxrwx 1 root root 17 12-16 02:12 K05wdaemon -> ../init.d/wdaemonlrwxrwxrwx 1 root root 16 12-16 02:10 K10psacct -> ../init.d/psacctlrwxrwxrwx 1 root root 14 12-16 02:10 K10tcsd -> ../init.d/tcsdlrwxrwxrwx 1 root root 13 12-16 02:14 K20nfs -> ../init.d/nfslrwxrwxrwx 1 root root 14 12-16 02:14 K24irda -> ../init.d/irdalrwxrwxrwx 1 root root 19 12-16 02:17 K35vncserver -> ../init.d/vncserverlrwxrwxrwx 1 root root 17 12-16 02:26 K35winbind -> ../init.d/winbindlrwxrwxrwx 1 root root 14 12-16 02:19 K36lisa -> ../init.d/lisalrwxrwxrwx 1 root root 20 12-16 02:12 K50netconsole -> ../init.d/netconsolelrwxrwxrwx 1 root root 16 12-19 06:18 K50vsftpd -> ../init.d/vsftpdlrwxrwxrwx 1 root root 20 12-16 02:14 K69rpcsvcgssd -> ../init.d/rpcsvcgssdlrwxrwxrwx 1 root root 16 12-16 02:26 K73ypbind -> ../init.d/ypbindlrwxrwxrwx 1 root root 14 12-16 02:10 K74nscd -> ../init.d/nscdlrwxrwxrwx 1 root root 14 12-17 00:12 K74ntpd -> ../init.d/ntpdlrwxrwxrwx 1 root root 15 12-16 02:12 K85mdmpd -> ../init.d/mdmpdlrwxrwxrwx 1 root root 20 12-16 02:09 K87multipathd -> ../init.d/multipathdlrwxrwxrwx 1 root root 15 12-16 02:14 K87named -> ../init.d/namedlrwxrwxrwx 1 root root 24 12-16 02:14 K88wpa_supplicant -> ../init.d/wpa_supplicantlrwxrwxrwx 1 root root 14 12-16 02:17 K89dund -> ../init.d/dundlrwxrwxrwx 1 root root 18 12-16 02:09 K89netplugd -> ../init.d/netplugdlrwxrwxrwx 1 root root 14 12-16 02:17 K89pand -> ../init.d/pandlrwxrwxrwx 1 root root 15 12-16 02:07 K89rdisc -> ../init.d/rdisclrwxrwxrwx 1 root root 14 12-16 02:14 K91capi -> ../init.d/capilrwxrwxrwx 1 root root 25 12-16 02:10 K99readahead_later -> ../init.d/readahead_laterlrwxrwxrwx 1 root root 23 12-16 02:12 S00microcode_ctl -> ../init.d/microcode_ctllrwxrwxrwx 1 root root 22 12-16 02:10 S02lvm2-monitor -> ../init.d/lvm2-monitorlrwxrwxrwx 1 root root 25 12-16 02:10 S04readahead_early -> ../init.d/readahead_earlylrwxrwxrwx 1 root root 15 12-16 02:17 S05kudzu -> ../init.d/kudzulrwxrwxrwx 1 root root 18 12-16 02:08 S06cpuspeed -> ../init.d/cpuspeedlrwxrwxrwx 1 root root 19 12-16 02:07 S08ip6tables -> ../init.d/ip6tableslrwxrwxrwx 1 root root 18 12-16 02:07 S08iptables -> ../init.d/iptableslrwxrwxrwx 1 root root 18 12-16 02:12 S08mcstrans -> ../init.d/mcstranslrwxrwxrwx 1 root root 14 12-16 02:14 S09isdn -> ../init.d/isdnlrwxrwxrwx 1 root root 17 12-16 02:12 S10network -> ../init.d/networklrwxrwxrwx 1 root root 16 12-16 02:10 S11auditd -> ../init.d/auditdlrwxrwxrwx 1 root root 21 12-16 02:13 S12restorecond -> ../init.d/restorecondlrwxrwxrwx 1 root root 16 12-16 02:12 S12syslog -> ../init.d/sysloglrwxrwxrwx 1 root root 20 12-16 02:12 S13irqbalance -> ../init.d/irqbalancelrwxrwxrwx 1 root root 17 12-16 02:12 S13portmap -> ../init.d/portmaplrwxrwxrwx 1 root root 17 12-16 02:14 S14nfslock -> ../init.d/nfslocklrwxrwxrwx 1 root root 19 12-16 02:12 S15mdmonitor -> ../init.d/mdmonitorlrwxrwxrwx 1 root root 19 12-16 02:14 S18rpcidmapd -> ../init.d/rpcidmapdlrwxrwxrwx 1 root root 17 12-16 02:14 S19rpcgssd -> ../init.d/rpcgssdlrwxrwxrwx 1 root root 20 12-16 02:16 S22messagebus -> ../init.d/messagebuslrwxrwxrwx 1 root root 19 12-16 02:17 S25bluetooth -> ../init.d/bluetoothlrwxrwxrwx 1 root root 15 12-16 02:12 S25netfs -> ../init.d/netfslrwxrwxrwx 1 root root 15 12-16 02:13 S25pcscd -> ../init.d/pcscdlrwxrwxrwx 1 root root 15 12-16 02:12 S26acpid -> ../init.d/acpidlrwxrwxrwx 1 root root 19 12-16 02:17 S26haldaemon -> ../init.d/haldaemonlrwxrwxrwx 1 root root 14 12-16 02:17 S26hidd -> ../init.d/hiddlrwxrwxrwx 1 root root 20 12-16 02:07 S26lm_sensors -> ../init.d/lm_sensorslrwxrwxrwx 1 root root 16 12-16 02:10 S28autofs -> ../init.d/autofslrwxrwxrwx 1 root root 14 12-16 02:14 S55sshd -> ../init.d/sshdlrwxrwxrwx 1 root root 14 12-16 02:17 S56cups -> ../init.d/cupslrwxrwxrwx 1 root root 20 12-16 02:12 S56rawdevices -> ../init.d/rawdeviceslrwxrwxrwx 1 root root 15 12-19 09:29 S64mysql -> ../init.d/mysql(注意此处下面要用到)lrwxrwxrwx 1 root root 18 12-16 02:12 S80sendmail -> ../init.d/sendmaillrwxrwxrwx 1 root root 13 12-16 02:07 S85gpm -> ../init.d/gpmlrwxrwxrwx 1 root root 15 12-16 02:12 S90crond -> ../init.d/crondlrwxrwxrwx 1 root root 13 12-16 02:16 S90xfs -> ../init.d/xfslrwxrwxrwx 1 root root 17 12-16 02:08 S95anacron -> ../init.d/anacronlrwxrwxrwx 1 root root 13 12-16 02:12 S95atd -> ../init.d/atdlrwxrwxrwx 1 root root 22 12-16 02:17 S97yum-updatesd -> ../init.d/yum-updatesdlrwxrwxrwx 1 root root 22 12-16 02:16 S98avahi-daemon -> ../init.d/avahi-daemonlrwxrwxrwx 1 root root 19 12-16 02:17 S99firstboot -> ../init.d/firstbootlrwxrwxrwx 1 root root 11 12-16 02:12 S99local -> ../rc.locallrwxrwxrwx 1 root root 16 12-16 02:12 S99smartd -> ../init.d/smartd
进/etc/rc.d/rc3.d/ 查看 mysql 对应的名字 每个机器可能都不一样 我的是S64mysql
目地是确保symlink被正确的开设
[root@localhost rc3.d]# /etc/rc.d/rc3.d/S64mysql start (用到了上面的加蓝的那个名称)Starting MySQL.[确定]
查看mysql是否安装成功 成功会返回mysql 的版本信息
[root@localhost rc3.d]# mysqladmin versionmysqladmin Ver 8.42 Distrib 5.5.2-m2, for unknown-linux-gnu on x86_64Copyright 2000- MySQL AB, Sun Microsystems, Inc.This software comes with ABSOLUTELY NO WARRANTY. This is free software,and you are welcome to modify and redistribute it under the GPL licenseServer version5.5.2-m2-logProtocol version 10Connection Localhost via UNIX socketUNIX socket /tmp/mysql.sockUptime: 4 min 58 secThreads: 1 Questions: 1 Slow queries: 0 Opens: 15 Flush tables: 1 Open tables: 8 Queries per second avg: 0.3[root@localhost rc3.d]# mysqladmin -u root password 'rootpassword' (设置mysql 密码, 注:rootpassword 替换成你自己的密码)测试mysql[root@localhost rc3.d]# mysql -u root -pEnter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 3Server version: 5.5.2-m2-log Source distributionType 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>
安装apache
[root@localhost /]# cd /var/www/httpd-2.2.15[root@localhost httpd-2.2.15]# ./configure \> --prefix=/usr/local/apache \> --enable-shared=max \> --enable-module=rewrite \> --enable-module=so[root@localhost httpd-2.2.15]# make;make install后台会接着配置 apache 的配置文件
安装php
[root@localhost httpd-2.2.15]# cd /var/www/php-5.3.2[root@localhost php-5.3.2]# ./configure \> --with-apxs2=/usr/local/apache/bin/apxs \> --disable-debug \> --enable-ftp \> --enable-inline-optimization \> --enable-magic-quotes \> --enable-mbstring \> --enable-mm=shared \> --enable-safe-mode \> --enable-track-vars \> --enable-trans-sid \> --enable-wddx=shared \> --enable-xml \> --with-dom \> --with-gd \> --with-gettext \> --with-mysql=/usr/local/mysql \> --with-regex=system \> --with-xml \> --with-zlib-dir=/usr/lib[root@localhost httpd-2.2.15]# make;make install (等)
开始配置环境
Php.ini 用php.ini-development php.ini-production 两个文件中的任意一个 php.ini-dist 也可以 但有的包里面没有
[root@localhost php-5.3.2]# cp php.ini-development /usr/local/lib/php.ini[root@localhost php-5.3.2]# ln -s /usr/local/lib/php.ini /etc/php.ini[root@localhost php-5.3.2]# ln -s /usr/local/apache/conf/httpd.conf /etc/httpd.conf[root@localhost htdocs]# ln -s /usr/local/apache/bin/apachectl /etc/rc.d/init.d/apache[root@localhost rc3.d]# ln -s /etc/rc.d/init.d/apache /etc/rc.d/rc3.d/S90apache
现在可以向下面这样启动apache
/etc/rc.d/init.d/apache start
现在配置apache 使php能够执行
[root@localhost rc3.d]# vi /etc/httpd.conf如果找不下面的 就添加AddType application/x-tar .tgzAddType application/x-httpd-php .php .foo(主要是这句)AddType application/x-httpd-php-source .phps .phtmlsAddType application/x-httpd-php .php .htm .html<IfModule mod_dir.c>DirectoryIndex index.php index.htm index.html</IfModule>
测试环境
[root@localhost rc3.d]# cd /usr/local/apache/htdocs/[root@localhost htdocs]# vi index.php写入 <?phpphpinfo();?>保存退出
访问http://服务器的ip/index.php 看看会不会有错误出现 (最好从头看到尾)
错误提示 解决办法在下面的常见问题中
Warning: phpinfo() [function.phpinfo]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no
常见问题
mysqladmin 不能使用
/qingfeng/archive//01/03/1924787.html
mysql 安全
/connect/articles/securing-mysql-step-step
mysql 刷新
flush privileges;
Mysql 启动方式
/etc/rc.d/init.d/mysql start | stop | restart
Apache 启动方式
/usr/local/apache/bin/apachectl start | stop | restart
最终启动方式
service apache start | stop | restart
service mysql start | stop | restart
MySQL Security Issues
First, we will assume that only applications on the same server will be allowed to access the database (i.e., not a program running on a physically separate server). So we'll tell MySQL not to even listen on port 3306 for TCP connections like it does by default.
Edit/etc/f
and uncomment the
skip-networking
line (delete the leading#
).
For more security info, check out thisMySQL security tutorial.
Php 出下面错误
Configuring SAPI modules
checking for AOLserver support... no
checking for Apache 1.x module support via DSO through APXS... configure: error: You have enabled Apache 1.3 support while your server is Apache 2. Please use the appropiate switch --with-apxs2
只需 把 ./configure 后面的
Ø --with-apxs=/usr/local/apache/bin/apxs \
换成
Ø --with-apxs2=/usr/local/apache/bin/apxs \
本文中用的是 后者 如果不行 可以 以上两种方式 都式一下
查看 ./configure 的用法
[root@localhost php-5.3.2]# ./configure –help
Php.ini 用php.ini-development php.ini-production 两个文件中的任意一个
php.ini-dist 也可以 但有的包里面没有
输入IP 访问的是 /usr/local/apache/htdocs/ 这个文件夹
你也可以在 httpd.conf 中查找
DocumentRoot 这个后面跟着的路径就是直接输入IP 所访问到的文件夹
访问
http://服务器的ip/index.php
往下看 看看会有错误出现
Warning: phpinfo() [function.phpinfo]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no
解决办法:
1. 把 index.php 修改成 下面的代码
<?php
date_default_timezone_set ('Asia/Shanghai');
phpinfo();
?>
重启 apache
[root@localhost htdocs]# /etc/rc.d/init.d/apache restart
如果不出现错误 可以去 编辑/etc/php.ini 添加设置时区
添加 下面一句话
date.timezone =Asia/Shanghai
保存 退出
重启 apache
[root@localhost htdocs]# /etc/rc.d/init.d/apache restart
默认打开的程序 设置
编辑 /etc/httpd.conf 修改下面内容DirectoryIndex后面跟的 所有文件名以空格格开 打开时 会按先后顺序打开 如果index.php存在则打开;index.php 不存在 则打开 index.html
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
保存 退出
记得要重启 apache
service apache restart
要撑握的知识
命令
groupadd
useradd
ln
了解mysql安全
如果觉得《linux centos apache+php+mysql 安装( 用包安装 非yum 安装)》对你有帮助,请点赞、收藏,并留下你的观点哦!