Author: Yuhai Hair
The development languages that Web developers use today are PHP, ASP, and JSP. These three languages have their own strengths, and each has a large number of loyal developers and users. For people who use PHP for Web development, many people choose to develop under Windows, and the programs that are eventually developed run on Unix-like LINUX/FREEBSD operating systems. The difference between the development environment and the implementation environment makes the system knowledge of many developers slightly deficient. This is not uncommon as a person who uses PHP for Web development without using Linux. Not to mention a few simple Linux system knowledge, you can install the development environment. It is necessary for a developer to understand some system knowledge, and it is also helpful for development. Here's how to frame Linux under the Php+mysql development environment.
To develop Web applications under Linux, be sure to have an HTTP Server, which is the famous Apache. Of course, the database must be indispensable, Linux supports a variety of databases, including such as Oracle, DB2, such as large databases. However, the most compatible with PHP, but also the most used database is MySQL. In addition, the PHP language itself is essential. The following are their corresponding Web sites:
Apache http://www.apache.org
MySQL http://www.mysql.com
PHP http://www.php.net
Software on Linux usually has a very fast upgrade speed, which may be one of the advantages of open source software. In the case of Apache, there is a 1.3.X version and a 2.X version of two branches. Because of the 2. X is rewritten on 1.3.X, so there are significant improvements in both structure and functionality. About the Apache 1.3.X installation Introduction More, so this article selected the Apache 2.X version. Similarly, PHP versions that support the Apache 2.X version are also selected. You can download the latest version of Apache, MySQL, and PHP from their respective websites. The following packages are downloaded from September 16, 2003:
Mysql-4.0.15.tar.gz
Php-4.3.3.tar.gz
Httpd-2.0.47.tar.gz
With these three packages, you can start building a Web server that supports Php+mysql under Linux. This is also the current common Web application environment.
We put the downloaded three packages into the/var/local directory (this is the author's personal habit), they are tar.gz package, you can use the command TAR-XZPVF package name, they are in the current directory (/var/local/) untie:
Cd/var/local
TAR-XZPVF mysql-4.0.15.tar.gz
TAR-XZPVF php-4.3.3.tar.gz
TAR-XZPVF httpd-2.0.47.tar.gz
After unpack, you can begin to enter the formal installation.
installing MySQL
1. Compile
CD mysql-4.0.15/
.. /configure--prefix=/usr/local/mysql
Make
Make install
Cd..
2. Increase User
Adduser-s/bin/false MySQL
3. Initialize and set directory permissions
/usr/local/mysql/bin/mysql_install_db
Chown-r root/usr/local/mysql/
Chown-r Mysql/usr/local/mysql/var
Chgrp-r mysql/usr/local/mysql/
4. Join the library
Echo/usr/local/mysql/lib/mysql/lib >>/etc/ld.so.conf
Ldconfig
5. Make it run automatically when it starts
echo "/usr/local/mysql/bin/mysqld_safe &" >>/etc/rc.d/rc.local
6. Start MySQL
/usr/local//mysql/bin/mysqld_safe &
7. Security Settings
To modify the MySQL root password:
/usr/local/mysql/bin/mysqladmin-uroot Password ABCDEFG
8. Test
[Root@terry bin]#/usr/local/mysql/bin/mysql-u root-p
Enter Password:
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 3 to server version:4.0.15
Type ' help, ' or ' \h ' for help. Type ' \c ' to clear the buffer.
mysql> use MySQL;
Reading table information for completion of table and column names
You can turn off the feature to get a quicker startup with-a
Database changed
mysql> Delete from user where user= '; (Remove all users with blank names to improve security)
Query OK, 2 rows Affected (0.00 sec)
Mysql> quit
Bye
Install Apache
CD httpd-2.0.47/
.. /configure--prefix=/usr/local/httpd--enable-so
Make
Make install
Cd..
Apache 2.0.47 has now been installed into the/USR/LOCAL/HTTPD directory, and Apache is installed to support loadable modules and standard MPM prefork. If no errors occur during installation, you can start the Apache service using the following command:
/usr/local/httpd/bin/apachectl start
If the startup succeeds, the start command is added to the rc.local to run automatically when the system starts:
echo "/usr/local/httpd/bin/apachectl Start &" >>/etc/rc.d/rc.local
Stop the Apache service and continue installing PHP:
/usr/local/httpd/bin/apachectl stop
Installing PHP
CD php-4.3.3
.. /configure--with-apxs2=/usr/local/httpd/bin/apxs--with-mysql=/usr/local/mysql
Make
Make install
CP Php.ini-dist/usr/local/lib/php.ini
This installation method is to install PHP as the Apache SAPI module, it is only one of the installation methods, more ways to see the relevant documentation.
basic configuration of PHP and Apache after installation
1.Apache of configuration
The Apache configuration file is/usr/local/httpd/conf/httpd.conf, edit the httpd.conf file, and add the following two lines to the end of the file:
LoadModule Php4_module modules/libphp4.so
AddType application/x-httpd-php. php. php3
At the same time modify DirectoryIndex to:
DirectoryIndex index.html index.php index.php3
Apache configuration is rich in content, other Apache related configuration Please refer to the Apache related documentation.
2.PHP of configuration
The Apache configuration file is/usr/local/lib/php.ini, editing the php.ini file to configure PHP options. It is particularly noted that the Register_globals variable is set to off by default after installation, and needs to be changed to ON. Otherwise, there will be a phenomenon that PHP cannot read the post data.
Register_globals=on
Other PHP options please refer to the relevant documentation.
3. Test
Can write a simple php file to test the installation, the file contains the following line:
? Phpinfo ();? >
Save it as/usr/local/httpd/htdocs/info.php, start Apache, and then browse through the browser.
Figure 1 PHP Information
If you see the information shown in Figure 1, you are successful. The above installation is done on Red Hat 9.0. So far, a web environment that supports Php+mysql is already installed. In addition Linux has a lot of powerful editors can be used to write PHP programs, such as VI, Emacs and so on, in addition to a number of graphical editors or Web development-specific editors, this is a personal discovery. When the real move to Linux for development, it will slowly realize its strong and handy.
This article differs from other articles that introduce Apache installation, rather than introducing Apache 1.3.x, but instead describes how to use the red Hat 9.0+apache 2.0+php 4.3+mysql 4.0来 Architecture Web Development environment, with the latest version of the software selected. Are compiled from the source code, rather than downloading the binaries for installation.