php_mysql_apache [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

php_mysql_apache [Electronic resources] - نسخه متنی

Julie C. Meloni

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید









Linux/Unix Installation




Whenever you compile applications from a source archive, the build process is dependent upon your system having the correct development tools and libraries in place.


The instructions below were written with Red Hat Linux specifically in mind, but the steps are the same for a default installation of all other Linux or commercial Unix distributions.


Should you encounter unexpected error messages during compilation, contact your systems administrator or refer to the documentation for your particular operating system.


Begin as the super user (either log in as root or su from a regular system user) and mount the CD-ROM under /mnt on your filesystem.




# mount /dev/cdrom /mnt t iso9660

Installing MySQL



Before installing MySQL we need to create a user on the system that will run the MySQL server.




# /usr/sbin/groupadd mysql
# /usr/sbin/useradd g mysql mysql


We will put all the source code to be built in the /usr/local/src directory, so let's extract the MySQL archive from the CD-ROM.




# cd /usr/local/src
# gunzip < /mnt/MySQL/Linux/tarballs/source/mysql-4.0.15.tar.gz | tar xf


This creates a directory called mysql-4.0.15 containing the source code. Change to the new directory and configure MySQL with the following commands.




# cd mysql-4.0.15
# ./configure --prefix=/usr/local/mysql


The --prefix compile-time option specifies that the MySQL server and client programs will reside under /usr/local/mysql, which is the same location that is used for a binary install. The default location for a source install is actually /usr/local, so you should change this here to match the location that MySQL would have been installed to in Chapter 2.


Once the configure script has run, we can begin compilation by issuing the make command.




# make


Issue the make install command to have the newly installed MySQL server, client programs, and libraries copied to their correct places on your system:




# make install


The next step is to create the default set of tables using the mysql_install_db script. From the source directory, issue the command




# scripts/mysql_install_db


Next we need to set the permissions on the MySQL data directory so the mysql user we created earlier can run the server and read and write the data files.




# chown R mysql /usr/local/mysql/var


Finally, we can start the MySQL server using the mysqld_safe command, and you should see a message like that below.




# /usr/local/mysql/bin/mysqld_safe &
[1] 9678
Starting mysqld daemon with databases from /usr/local/mysql/var


The command above can be added to your system startup script to ensure the MySQL server is always started following a reboot. For instance, on Red Hat Linux add the command to /etc/rc.d/rc.local.


If you want to test that MySQL is running, use the mysqladmin status command to get a short status message from a running server.




# /usr/local/mysql/bin/mysqladmin status
Uptime: 8826 Threads: 1 Questions: 10 Slow queries: 0 Opens: 8
Flush tables: 1 Open tables: 2 Queries per second avg: 0.000

Installing Apache



Extract the Apache source code from the CD-ROM to /usr/local/src and change to that directory.




# cd /usr/local/src
# gunzip < /mnt/Apache/Linux/source/httpd-2.0.47.tar.gz | tar xf
# cd httpd-2.0.47


We want to install Apache under /usr/local/apache2 and configure the Web server to allow Dynamic Shared Objects (DSO), so that we don't need to rebuild Apache to add in PHP support. The configure command therefore looks like this:




# ./configure --prefix=/usr/local/apache2 --enable-module=so


Other compile-time options can be specified above, but for the purposes of this book the example given will be sufficient.


Compile and install Apache, and then start the Web server with the apachectl command.




# make
# make install
# /usr/local/apache2/bin/apachectl start


To test that the Web server is running, open a Web browser and enter the name or IP address of your server as the location. If you are installing Apache on a Linux workstation, you can use localhost or 127.0.0.1 to access your server. The default page for a new installation (shown in Figure A.1) tells you that everything has worked.


Figure A.1. The default Apache page.




Installing PHP



Extract the PHP source code from the CD-ROM to /usr/local/src and change to that directory.




# cd /usr/local/src
# gunzip < /mnt/PHP/Linux/source/php-4.3.3.tar.gz | tar xf
# cd php-4.3.3


We need PHP to include MySQL support and to link into Apache using DSO using the apxs utility. We'll also use the prefix /usr/local/php for the essential PHP files.




# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-apxs2=/
usr/local/apache2/bin/apxs


Then use the make and make install commands to compile and install PHP.




# make
# make install


The apxs utility does most of the hard work here. Once PHP is built, it's copied to the correct place and the Apache configuration modified in order to load the module at start time.


We need to make one more change to the Apache configuration file to instruct the Web server to process any .php file as a PHP script. We'll also activate PHP for files ending .phtml and l. Edit /usr/local/apache2/conf/httpd.conf and add the following line:




AddType application/x-httpd-php .php .phtml l


Restart Apache with the apachectl command to make sure the changes to the configuration file are acted upon.




/usr/local/apache/bin/apachectl restart


To test that PHP is now a part of your Web server, create a simple script as /usr/local/apache2/htdocs/index.php that looks like this:




<?php
phpinfo();
?>


In your Web browser, visit index.php on your new server and you should see a page giving lots of information on the PHP configuration (Figure A.2).


Figure A.2. The phpinfo() page.






/ 323