Friday, November 14, 2008

Php+Mysql+Apache+BBS set up

START APACHE SERVER
------------------------------------------------------
[root@QuentinFedoraHome q.yang]# pwd
/home/q.yang
[root@QuentinFedoraHome q.yang]# uname -a
Linux QuentinFedoraHome 2.6.25-14.fc9.i686 #1 SMP Thu May 1 06:28:41 EDT 2008 i686 i686 i386 GNU/Linux

[root@QuentinFedoraHome q.yang]# /opt/apache/bin/apachectl start

now, you can see your page from browser
http://10.1.1.7/


INSTALLATION OF PHP + MYSQL + APACHE
---------------------------------------------------

[q.yang@QuentinFedoraHome ~]$ rpm -qa | grep mysql

mysql-connector-java-3.1.12-5.fc9.i386

mysql-libs-5.0.51a-1.fc9.i386

[q.yang@QuentinFedoraHome ~]$ rpm -qa | grep httpd

httpd-tools-2.2.8-3.i386

httpd-2.2.8-3.i386

[q.yang@QuentinFedoraHome ~]$ rpm -qa | grep php

[q.yang@QuentinFedoraHome ~]$

uninstall mysql-connector-java-3.1.12-5.fc9.i386

[root@linuxsir01 root]#rpm -e mysql-connector-java



From: http://doc.linuxpk.com/43251.html

and http://www.linuxsir.org/bbs/showthread.php?t=77079&highlight=apache

and http://doc.linuxpk.com/5557.html



==1== Obtain software.

Download mysql-5.0.67-linux-i686-glibc23.tar.gz from:

http://dev.mysql.com/downloads/mysql/5.0.html#downloads



Download php-5.2.6.tar.gz from:

http://www.php.net/



Download httpd-2.2.10.tar.gz from:

http://apache.wildit.net.au/httpd/ mirror of appache

or from http://www.apache.org/dyn/closer.cgi to get mirror list



==2== Installation from source



以Root登录,将以上文件均拷贝至/opt/software下。

[root@xxxx opt]#mv -f /home/user/

  1.安装MySQL

[root@linuxsir01 root]# cd /opt/software

[root@linuxsir01 software]# ls mysql-4.0.16.tar.gz

[root@linuxsir01 software]#tar zxvf mysql-4.0.16.tar.gz

编译和安装:在这个地方值得注意的是,我们要把mysql-4.0.16安装到我们指定的目录中,

为了系统和安全和优化,建议把自己用源码包安装的服务器 类软件都放在/opt 目录里。

所以在这里,我们就要把mysql-4.0.16也安装到/opt/mysql这个目录中;

[root@linuxsir01 software]#cd



[root@linuxsir01 software]# cd mysql-4.0.16

[root@linuxsir01 mysql-4.0.16]#

./configure --prefix=/opt/mysql --with-mysqld-user=beinan --with-extra-charsets=all --with-unix-socket-path=/opt/mysql/var/mysql.sock



[注]关于configure的选项的一点说明:



--prefix=/opt/mysql 把mysql-4.0.16指定安装到/opt/mysql目录中;

--with-extra-charsets=all 对多语言的支持;

--with-unix-socket-path=/opt/mysql/var/mysql.sock 这个是指定mysql服务器启动后,联机套接字文件所处的位置和文件名,也就是说,如果mysql服务器成功启动后,就能在/opt/mysql/var 目录中看到mysql.sock文件。如果看不到,肯定是mysql启动不了。

--with-mysqld-user=beinan 这个是让mysql服务器也能让系统中普通用户beinan也能启动mysql服务器。当然要活学活用了:)你也可以把beinan换成你的系统中已经存 在的普通用户,比如您的系统中已经存在sir这个用户,那就把beinan替换成sir就行了。用普通用户来启动mysql的好处是:mysql的进程会 自己死掉自动退出。当然root用户也可以,不过有时mysql有些进程死了,但不会自动退出,root自己也杀不掉。所以用普通用户就有这样的好处,大 多不会出现mysql进程已死,但不会退出的情况;



[root@linuxsir01 mysql-4.0.16]#make



[root@linuxsir01 mysql-4.0.16]#make install



我们把/opt/mysql/share/mysql这个目录下的my-medium.cnf,复制为my.cnf到/etc目录下。



做了这些工作以后,还得创造MySQL授权表, 否则数据库也是启动不了。mysql_install_db,这个命令的用途就是做这个的。

[root@linuxsir01 mysql]#/opt/mysql/bin/mysql_install_db

[root@QuentinFedoraHome mysql]# ./bin/mysql_install_db
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/opt/mysql/bin/mysqladmin -u root password 'new-password'
/opt/mysql/bin/mysqladmin -u root -h QuentinFedoraHome password 'new-password'

Alternatively you can run:
/opt/mysql/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /opt/mysql ; /opt/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /opt/mysql/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /opt/mysql/bin/mysqlbug script!

The latest information about MySQL is available at http://www.mysql.com/
Support MySQL by buying support/licenses from http://shop.mysql.com/



[root@QuentinFedoraHome var]# chown -R q.yang ./
[root@QuentinFedoraHome var]# ll
total 776
drwxrwx--x 2 q.yang root 4096 2009-05-21 22:54 mysql
-rwxrwx--x 1 q.yang root 125 2008-12-01 22:12 mysql-bin.000001
-rw-rw---- 1 q.yang root 106 2009-03-24 22:19 mysql-bin.000002
-rw-rw---- 1 q.yang root 106 2009-03-24 22:20 mysql-bin.000003
-rw-rw---- 1 q.yang root 125 2009-03-24 23:10 mysql-bin.000004
-rw-rw---- 1 q.yang root 106 2009-05-20 22:16 mysql-bin.000005
-rw-rw---- 1 q.yang root 125 2009-05-20 22:34 mysql-bin.000006
-rw-rw---- 1 q.yang root 106 2009-05-21 21:55 mysql-bin.000007
-rw-rw---- 1 q.yang root 125 2009-05-21 22:36 mysql-bin.000008
-rw-rw---- 1 q.yang root 18928 2009-05-21 22:23 mysql-bin.000009
-rw-rw---- 1 q.yang root 696216 2009-05-21 22:23 mysql-bin.000010
-rw-rw---- 1 q.yang root 106 2009-05-21 22:36 mysql-bin.000011
-rw-rw---- 1 q.yang root 106 2009-05-21 22:59 mysql-bin.000012
-rw-rw---- 1 q.yang root 125 2009-05-21 23:02 mysql-bin.000013
-rw-rw---- 1 q.yang root 125 2009-05-21 23:18 mysql-bin.000014
-rwxrwx--x 1 q.yang root 266 2009-05-21 23:18 mysql-bin.index
-rwxrwx--x 1 q.yang root 11477 2009-05-21 22:59 QuentinFedoraHome.err
drwxrwx--x 2 q.yang root 4096 2008-11-28 21:47 test
[root@QuentinFedoraHome var]# /opt/mysql/bin/mysql_install_db --user=q.yang --datadir=/opt/mysql/var/
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/opt/mysql/bin/mysqladmin -u root password 'new-password'
/opt/mysql/bin/mysqladmin -u root -h QuentinFedoraHome password 'new-password'

Alternatively you can run:
/opt/mysql/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /opt/mysql ; /opt/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /opt/mysql/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /opt/mysql/bin/mysqlbug script!

The latest information about MySQL is available at http://www.mysql.com/
Support MySQL by buying support/licenses from http://shop.mysql.com/


=============================================


mysql服务器启动,应该是/opt/mysql/share/mysql目录中的 mysql.server

启动方法是:

[root@linuxsir01 mysql]# /opt/mysql/share/mysql/mysql.server start



add " datadir=/opt/mysql/var" into /etc/my.cnf,

#chown smith.y /opt/mysql/var/mysql-bin.index



#mysql_install_db --user=smith.y --datadir=/opt/mysql/var



[root@linuxsir01 mysql]# /opt/mysql/share/mysql/mysql.server start --skip-grant-table

--skip-grant-table is used to avoid 'unfound mysql.plugin' error.



commented out 'skip-federated' in /etc/my.cnf to avoid error 'unknown option '--skip-federated'



changed the /etc/sysconfig/iptables, to add 3306 socket ports.

/sbin/service iptables restart Not sure whether this helped the start of MySQL server.



Now, 'Starting MySQL [OK]'



[root@QuentinFedoraHome var]# /opt/mysql/bin/mysqladmin -u root password 123456/opt/mysql/bin/mysqladmin: You cannot use 'password' command as mysqld runs with grant tables disabled (was started with --skip-grant-tables).Use: "mysqladmin flush-privileges password '*'" instead



????? how to start MySal server without --skip-grant-table



[root@QuentinFedoraHome var]# /opt/mysql/bin/mysqladmin flush-privileges password '*'/opt/mysql/bin/mysqladmin: reload failed; error: 'Table 'mysql.host' doesn't exist'



2.安装Apache、PHP3、Mod―Auth―MySQL

  由于PHP3、Mod―Auth―MySQL是作为Apache的两个模块进行编译,故Apache要与它们联合编译。

   #tar xvzf httpd-2.2.10.tar.gz(产生httpd-2.2.10目录)

  # tar xvzf php-5.2.6.tar.gz(产生php-5.2.6目录)

  # tar xvzf mod_auth_mysql-3.0.0.tar.gz(产生mod_auth_mysql-3.0.0目录)

------------------------------------------------------------



  #cd httpd-2.2.10

[root@QuentinFedoraHome httpd-2.2.10]#./configure --prefix=/opt/apache --enable-track-vars --enable-cgi --with-config-file-path=/opt/apache/conf



  # ./configure --prefix=/opt/apache(把Apache的安装目录定为/opt/apache)



 #./configure --prefix=/usr/local/apache --activate-module=src/modules/ php3/libphp3.a --activate-module=src/modules/mod―auth/libmod―auth.a   



#make; make install



[root@linuxsir01 httpd-2.0.48]#./configure --prefix=/opt/apache --enable-track-vars --enable-cgi --with-config-file-path=/opt/apache/conf一点简单的说明:这个apache的安装,有很多的选项,如果您是比较精通,所以必要看此文,可以自己定义来安装。因为我大多是采用默认的配制,如果您想让apache有更多的功能,比如支持压缩输出以及jsp等支持,可以看其它的文章。这篇文件主还要给初学linux的弟兄写的一个简单的入门型文章,直接的说,就是给一点都不懂在linux如何安装apache,并支持php+mysql的。能让初学linux的弟兄自己架一个最简单的网站,这样弄明白原理以后,就便于深入学习和研究。我写此文的目的仅此而已;



--prefix=/opt/apache 指定把apahce安装到/opt/apache目录中;



--enable-cgi 支持CGI;



--with-config-file-path=/opt/apache/conf 指定把apache的配制文件放在/opt/apache/conf中;比如httpd.conf配制文件就在这个目录中;



--enable-track-vars 为启动cookie的get/post等追踪功能



如果需要更多的选项,可能通过下面的命令来查看;



[root@linuxsir01 httpd-2.0.48]#./configure --help



下一步就是make 和make install



[root@linuxsir01 httpd-2.0.48]#make



[root@linuxsir01 httpd-2.0.48]#make install

启动apache守护进程;

[root@linuxsir01 httpd-2.0.48]# /opt/apache/bin/apachectl start

打开浏览器,输入 http://localhost/ 就能看到一个apache的欢迎页面了,这表示我们已经成功解决了apache的安装。

back up apache config file

# cp /opt/apache/conf/httpd.conf /opt/apache/conf/httpd.confBAK

ServerAdmin beinan@linuxsir.com

ServerName 192.168.0.1:80

DocumentRoot "/var/home/freewill"

Add follows into "/etc/sysconfig/iptables"

-A INPUT -m state --state NEW -m udp -p udp --dport 80 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

Then restart firewall

/sbin/service iptables restart

Now, you should be able to view your webpage through Internet.

--------------------------------------------------------------

#cd ./php-5.2.6

# ./configure --prefix=/opt/php --with-mysql=/opt/mysql --with-apxs2=/opt/apache/bin/apxs --enable-force-cgi-redirect --with-config-file-path=/opt/php/etc



#./configure --with-mysql=/usr/local/mysql --with-apache=../apache―1.3.6 --enable-track-vars

  配置PHP模块支持MySQL,并作为Apache功能模块、跟踪变量有效。

[from linuxsir ]

[root@linuxsir01 php-4.3.4]#./configure --prefix=/opt/php --with-mysql=/opt/mysql --with-apxs2=/opt/apache/bin/apxs --enable-force-cgi-redirect --with-config-file-path=/opt/php/etc

一点说明:



--prefix=/opt/php 指定把php-4.3.4安装到/opt/php目录中;

--with-mysql=/opt/mysql 指定mysql数据服务器安装的位置;

--with-apxs2=/opt/apache/bin/apxs 这是加入apache中为DSO模块的位置;

-enable-track-vars 为启动cookie的get/post等追踪功能

--with-config-file-path=/opt/php/etc 指定php的配制文件存放的目录是/opt/php/etc目录,我们安装完成后,也要把php.ini复制到这个目录中来。

  #make; make install


[root@QuentinFedoraHome php-5.2.6]# libtool --finish /opt/software/php-5.2.6/libs

[root@QuentinFedoraHome php-5.2.6]# chmod 755 /opt/apache/modules/libphp5.so

  PHP安装完毕。 

-----------------------------------------------------------

  #cd ./mod―auth―mysql-2.20


[root@QuentinFedoraHome software]# /opt/apache/bin/apxs -cia -L/opt/mysql/lib/mysql -I/opt/mysql/include/mysql -lmysqlclient mod_auth_mysql.c

Failed to build.

   #./configure --with-mysql=/usr/local/mysql --with-apache=../apache―1.3.6 --enable-track-vars



  配置支持MySQL、作为Apache功能模块、跟踪变量有效。

  #make (注意:这里不再用make install命令)

  Mod―Auth―MySQL安装完毕。

---------------------------------------------------------------

    #cp -fp /opt/software/php-5.2.6/php.ini-dist /opt/php/etc/php.ini
    #vi /opt/apache/conf/httpd.conf
       DirectoryIndex index.html index.php     "added index.php in this line -Quentin commented"
       AddType application/x-httpd-php .php     "added php application support."
AddType application/x-httpd-php-source .phps


/*


 #cd ../apache―1.3.6   #./configure --prefix=/usr/local/apache --activate-module=src/modules/ php3/libphp3.a --activate-module=src/modules/mod―auth/libmod―auth.a  #make; make install  重新编译Apache并激活PHP3模块和Mod―Auth―MySQL模块。  Apache安装完毕。


*/

-------------------------------------------------------------------------

  3.安装phpMyAdmin

  #tar -zvxf phpMyAdmin―2.0.5.tar.gz

  产生phpMyAdmin-2.11.9.5-all-languages 目录

  #mv ./phpMyAdmin-2.11.9.5-all-languages /opt/apache/htdocs/phpMyAdmin

  移到/usr/local/mysql

  #cd /opt/apache/htdocs/phpMyAdmin

  #chmod a+r * 置为可读

----------------------------------------------------------------------------


  三、软件运行



  1.启动MySQL

  第一次运行之前,先进行数据库初始化:

  #cd /usr/local/mysql

  #scripts/mysql―install―db

  #bin/safe―mysqld & (运行MySQL数据库)

  #bin/mysql -u root (默认没有设口令)

  #mysql〉use mysql; (打开MySQL数据库)



  注意,命令后的“;”是必不可少的。



  #mysql〉select * from user;

  #mysql〉exit

  这样就可以了,先不急着加口令。



  2.启动Apache

  #/usr/local/apache/bin/apachectl start



  测试:

  #telnet localhost 80



  Trying 127.0.0.1... Connected to localhost.Escape character is ′^]′.



  #cd /usr/local/apache/htdocs

  #vi test.php3



  在文件里敲入:

  〈? Echo ″HELLO WORLD!″?〉

  存盘退出,再用浏览器看一下这个文件,是不是一条问候信息?



  3. 使用phpMyAdmin

 用浏览器打开/phpMyAdmin/index.php3 (注意大小写),会出现一个简陋的界面,千万别小看它,它能完成很多让你意想不到的功能。



  四、MySQL及phpMyAdmin的设置



  1. phpMyAdmin设置

  #cd /usr/local/apache/htdocs/phpMyAdmin

  将require(″english.inc.php3″)改为require(″chinese―gb.inc.php3″)。这样就显示简体中文界面了。



  2. MySQL的用户及口令设置

  浏览/phpMyAdmin/index.php3,看到一个MySQL库,在其中的表User中,可查找当前数据库中所有用户,在Password字段中可更改Root口令。



  设置口令后,phpMyAdmin也要作相应设置:

  #vi config.inc.php3将

  $cfgServers[1][′adv―auth′]=true;

  $cfgServers[1][′stduser′]=′root′;

  $cfgServers[1][′stdpass′]=′root password′。



  五、MySQL、Apache由普通用户身份运行



  1. 运行Apache

  为Apache增加普通用户后,将Httpd.conf中的User、Group改为Apache的用户和组。

  在/etc/rc.d/rc.local中增加下面一行:

  /bin/sh -c ′/usr/local/apache/bin/apachectl start′

  使其在系统启动时自动运行Apache。



  2. 运行MySQL

  为MySQL增加普通用户后,在/etc/rc.d/rc.local中增加下面一行:

  /bin/sh -c ′/usr/local/mysql/bin/safe―mysqld --user=mysql &′

  一切准备就绪,剩下的就是使用各种工具来建立一个属于自己的网站。







==========================================================================

webmin install
Install webmin using rpm, 'i'-install, 'v' -details 'h' - show progress bar.
#rpm -ivh webmin-1.470-1.noarch.rpm

No comments: