Build a dynamic website development platform based on Linux

Source: Internet
Author: User
Tags localhost mysql
The current web site is no longer a dynamic Web site that only allows the viewer or the user to browse the static Web content, but requires dynamic information exchange with the user. Therefore, building a Web site platform not only supports simple HTML web page browsing, but also enables the web site to implement a dynamic interactive operation with the user. This requires the Web server to provide a technology that can communicate with users in addition to standard HTML web page browsing. This technology not only collects and feedbacks user information, but also supports database operations (storing information in the database and retrieving information from the database ).

Directory

Comparison of several existing technologies
Software acquisition
Install and set the MySQL database server
Installation and configuration of Apache and PHP
Build a rapid development platform

Comparison of several existing technologies

Currently, the most popular and widely used dynamic Web website technologies include ASP, JSP, and PHP. These three technologies are embedded in an existing web server.Programming LanguageDynamic Web pages can be integrated with standard HTML pages. The three technologies are described below.

ASP: Full name: Active Server Pages. It is a web server Development Environment launched by Microsoft. It can be used to generate and execute dynamic, interactive, and high-performance Web service applications.Program. It is closely integrated with Microsoft's IIS server and can take advantage of many features in the Windows operating system. ASP uses VBScript or JScript as the development language, which is easy for developers to use. ASP. NET is a new technology launched by Microsoft. It is a major innovation based on the original ASP technology and is gradually replacing ASP. ASP can only be used in Microsoft's operating system. You must pay for the software used.

JSP: The full name is Java Server Page. It is a new-generation website development language launched by Sun. It can use almost all the features of Java. JSP supports Servlet and JavaBean to develop powerful web sites. JSP is fully based on the Java language and can be used across platforms in a variety of mainstream operating systems. JSP is suitable for developing large websites with high requirements on developers (generally familiar with Java programming languages ).

PHP: it is a cross-platform server-side embedded scripting language. It draws a lot from the syntax of C, Java, and Perl languages and adds PHP's own features, allows web developers to quickly write dynamic pages. PHP supports all mainstream databases. It is completely free of charge and does not need to be paid for use.

This article will discuss how to implement a completely free PHP Technology Based on Linux. We will build a free dynamic website development platform that supports databases.

Software acquisition

The software we use is completely open for free throughout the configuration process.Source codeSoftware, which can be downloaded from the Internet for free. We will use MySQL to build a free database server, use Apache and PHP to build a dynamic website, and use the Samba server to quickly develop website programs.

Http://www.mysql.com/download MySQL source from MySQL Official WebsiteCodePackage (tar.gz). The latest version is 4.0.14.

Download the source code package (tar.gz) from the Apache official website http://www.apache.org, the latest version is 1.3.28 and 2.0.47, this article mainly introduces version 1.3.28.

Download PHP source code package file (Suffix: tar.gz) from PhP official website http://www.php.net, the latest version is 4.3.2.

Install and set the MySQL database server

Before compilation and installation, make sure that at least one C language compiler, such as cc or GCC, is installed in the current Linux operating system. If the installation is not performed, follow these steps.

Assume that the download directory of all the software is the root user's home directory, that is, the "/root" directory.

1. decompress the package

Run the following command to decompress the package:


     
      
[Root @ localhost root] # tar zxvf mysql-4.0.14.tar.gz

     

After decompression, A mysql-4.0.14 source code directory is generated.

2. Software Configuration, compilation, and installation

Switch to the source code directory and configure, compile, and install the software before installation. The command is:


     
      
[Root @ localhost root] # cd mysql-4.0.14 [root @ localhost mysql-4.0.14] # groupadd MySQL [root @ localhost mysql-4.0.14] # useradd-G MySQL [root @ localhost mysql-4.0.14] #. /configure--Prefix =/usr/local/MySQL [root @ localhost mysql-4.0.14] # Make [root @ localhost mysql-4.0.14] # make install [root @ localhost mysql-4.0.14] # scripts/mysql_install_db [root @ localhost mysql-4.0.14] # chown-r root/usr/local/MySQL [root @ localhost mysql-4.0.14] # chown-r MySQL/usr/local/MySQL/var [root @ localhost mysql-4.0.14] # chgrp-r MySQL/usr/local/MySQL [root @ localhost mysql-4.0.14] # cp support-files/my-medium.cnf/etc/My. CNF

     

Run the following command to start the MySQL database ):


     
      
[Root @ localhost mysql-4.0.14] #/usr/local/MySQL/bin/safe_mysqld -- user = MySQL &

     

Append the preceding startup command to the end of the file "/etc/rc. d/rc. Local" so that the MySQL database server is automatically started when the operating system starts.

3. Initial settings of the MySQL server

The newly installed MySQL server does not have relevant permission settings, and must be set manually. Use the following command in the command line:


     
      
[Root @ localhost root] #/usr/local/MySQL/bin/MySQL

     

Go to the mysql client tool operation interface, and then perform the following operations:


     
      
Mysql> drop database test; mysql> use MySQL; mysql> Delete from user where user = ''; mysql> Delete from user where host = '%'; mysql> Delete from dB;

     

Currently, the MySQL database only allows the root user of the local MySQL Administrator (different from the root user of the operating system) to connect. Use the following command to specify the password for the root user:


     
      
[Root @ localhost root] # cd/usr/local/MySQL/bin/[root @ localhost bin] #./mysqladmin-u root @ localhost password '123'

     

In the above command, "123456" is the root user password, please change according to the actual situation.

4. Create a database and set its permissions

Run the following command to create a database "mydb" and set the permissions:


     
      
[Root @ localhost bin] #. /MySQL-u root-P mysql> Create Database mydb; mysql> grant all privileges on mydb. * To mydb @ localhost identified by 'mydb'; mysql> exit [root @ localhost bin] #. /mysqladmin-u root @ localhost-P flush-privileges;

     

The above command creates a "mydb" database and grants all its permissions to the "mydb" user. The password is "mydb" and can only log on to the database from the local machine.

Installation and configuration of Apache and PHP

Apache and PHP are inherited and installed in two modes:

1. decompress the package

Run the following command to decompress the package:


     
      
[Root @ localhost root] # tar zxvf apache_1.3.28.tar.gz [root @ localhost root] # tar zxvf php-4.3.2.tar.gz

     

After decompression, two Source Code Directories, apache_1.3.28 and php-4.3.2, are generated.

2. Software Configuration, compilation, and installation

Switch to the source code directory to configure, compile, and install the software. The command is:


     
      
[Root @ localhost root] # cd apache_1.3.28 [root @ localhost apache_1.3.28] #. /configure--Prefix =/usr/local/apache \ -- enable-module = so [root @ localhost apache_1.3.28] # Make [root @ localhost apache_1.3.28] # make install [root @ localhost apache_1.3.28] # CD .. /php-4.3.2 [root @ localhost php-4.3.2] #. /configure -- enable-track-vars \ -- With-mysql =/usr/local/MySQL -- With-apxs =/usr/local/Apache/bin/apxs [root @ localhost php-4.3.2] # Make [root @ localhost php-4.3.2] # make install [root @ localhost php-4.3.2] # cp PHP. ini-Dist/usr/local/lib/PHP. ini

     

3. basic configuration and testing of Apache and PHP

Edit the Apache configuration file "/usr/local/Apache/CONF/httpd. conf" and add the following line:


     
      
Addtype application/x-httpd-php.php

     

Modify the line "directoryindex index.html":


     
      
Directoryindex index.html index.htm index. php

     

Edit the PHP configuration file "/usr/local/lib/PHP. ini" and change "register_globals = off":


     
      
Register_globals = on

     

Run the following command to start Apache (and add it to the file "/etc/rc. d/rc. Local ):


     
      
[Root @ localhost root] #/usr/local/Apache/bin/apachectl start

     

Create the test. php file in the directory "/usr/local/Apache/htdocs/" with the following content:


     
      
<? PHP phpinfo ();?>

     

Enter the address "http: // your_ip/test. PHP "(your_ip is the IP address of the server), you can see the basic configuration information of PHP, and the support information of the MySQL database. If no error is displayed, check the preceding steps.

Build a rapid development platform

To make full use of the rich application software on the Windows platform, we will use the Samba server in Linux to communicate with the Windows host. Web pages and related PHP program files are directly stored on the Linux server after being developed in Windows. You do not need to use ftp or other tools to upload them.

First, confirm that the Samba package is installed in the current Linux operating system. If not, install the package and continue the following steps.

Edit the samba configuration file "/etc/samba/smb. conf" and add the following content at the end:


     
      
[Homepage] Path =/usr/local/Apache/htdocs Valid users = PHP public = No writable = Yes printable = No create mask = 0765

     

Run the following command to add system users and Samba users:


     
      
[Root @ localhost root] # adduser PHP [root @ localhost root] # smbadduser PHP: PhP (enter the samba password and use it when logging on to the Samba server in Windows)

     

Run the following command to start the Samba server:


     
      
[Root @ localhost root] #/etc/rc. d/init. d/SMB start

     

Run the following command to enable automatic startup of the Samba server at startup:


     
      
[Root @ localhost root] # chkconfig -- level 3 SMB on

     

On the Windows client (Windows NT/2000 is recommended), use the Server IP Address "Search for a computer ". After finding the password, double-click the computer icon and enter "php" in the user column of the pop-up dialog box. In the Password box, enter the samba password set using the "smbadduser" command. Next, you will see the "Homepage" directory shared by the Samba server. Right-click the icon and select "ing network drive" to map it to a local logical drive letter. All the following web pages and programs can be directly stored on the Linux server through the disk operator.

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.