The configuration of PHP+MYSQL development environment under Linux

Source: Internet
Author: User
Tags install php ini php language linux


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 this feature to get a quicker startup with -A
Database changed
mysql> delete from user where user=''; (Delete all users with empty usernames 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.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.