Full installation of super server apache + mysql + php + ssl

Source: Internet
Author: User
Tags website server

Our goal is to install a web server that allows us to host multiple websites, some of which are security solutions for e-commerce, most websites are script-driven by connecting to a database server and extracting its data.

 

The tools required for this task are:

Apache-a website Server

Mod_SSL-A Secure Socket Layer (SSL) Module

OpenSSL-open source toolkit (required for mod_ssl)

RSARef-only for American users

MySQL-A Database Server

PHP-a scripting language

"Rome is a great path "...... Therefore, this is only one of the many configurations that meet our requirements. I chose this configuration because it is the simplest and fastest. The reason for choosing Mod_SSL/OpenSSL is that I have previous experience and is the fastest configuration and the easiest installation. To facilitate integration with Apache, I chose PHP and MySQL. Remember, Perl can do whatever you want, But PHP is simple and easy for any programmer who wants to learn it.

<Br> we hope that you will successfully complete the following goals after finishing this simple guide.

<Br> install and set up the MySQL database server

O know how to check the status of the MySQL server

O know how to use the command line client program to access the MySQL server

O know how to access your DB server from the web

Install and set up an Apache website server with SSL

O configure a simple virtual website

O know how to stop and start the server

O know how to make some basic host hosting configurations

Install and configure the PHP 4.0 Hypertext Preprocessor for server scripts

O know How to Write simple php code

O know how to connect to a database using php

O create a simple website with PHP enabled to communicate with a database

Create sample certificates for Apache SSL

O know how to generate a CSR File

O know how to encrypt a key code

O know how to sign your own certificate

This article will cover a large amount of information. As an entry-level guide, this guide introduces you to the world of e-commerce, website scripting, and Secure Sockets Layer (SSL, the purpose is to help you build a secure website driven by dynamic information stored in the database.

<Br> This document is not a detailed and comprehensive document. Of course, it will have some errors (hopefully the least). Remember this when you read it. However, it will arouse your enthusiasm and run the products mentioned above, hoping that you can better understand how these things work. You do not need previous programming knowledge, but assume that you have a background in computer knowledge. My goal is to write this document so that any newbie can understand what I'm talking about. If I do, I do a good job. If you have easily established an e-commerce site, it is better than me:-) Give me some explanations.

 

Hypothesis

<Br> This document assumes that you have installed the following software on your system.

 

Perl (preferably ver 5 +)

Gzip or gunzip

Gcc and GNU make

<Br> if you have not installed these, you will need to take the necessary steps to install them before explaining any process in this article.

<Br> you also need a basic understanding of UNIX commands, HTML, and SQL. You should have a basic understanding of how to manage your Linux machines. You also need a completely normal Linux machine. You will install software on it. Of course, you will need to list the necessary software packages to compile the source code. Finally, ensure that you have not installed MySQL, Apache, or PHP on the Linux machine.

 

Working Principle

<Br> understanding what happened behind the scenes is helpful. Here is an overly simplified working principle, and the subsequent explanations are not completely correct at the moment, just an overview of its key points:

<Br> the problem is: we have a webpage that extracts some data from a database. John Doe requests this page from his browser, the request is sent to the web server, and then calls a PHP script. The PHP script is interpreted by the PHP Preprocessor and the data is retrieved from the database. The result is processed and converted into HTML by the remaining PHP script, and the HTML is sent back to the user's browser.

 

Let's take a step-by-step look:

<Br> John Doe clicks a link from his browser. His browser sends a request to http://www.yourserver.com/test.php.

Apache gets a request for test. php. It knows that the. PHP file should be processed by the PHP pre-processor (mod_php), so it notifies php to process it. It knows this because it is specified in Apache configuration.

Test. php is a PHP script containing commands. One of these commands is to open a connection to a database and capture data. PHP processes the connection to the database and explains how SQL calls extract data from the database.

The server receives a connection request from the PHP interpreter and processes the request. A request may be similar to a simple selection statement or database table creation.

The database then sends the response and result back to the PHP interpreter.

Apache returns the result to John Doe's browser as a response to his request. John Doe now sees a webpage containing some information from a database.

If this is.

The server decrypts the request and authenticates it. It processes files, encrypts and sends them. Then the browser decrypts it with the server's key code. Remember that since the connection is encrypted, different ports are used. Port 80 is used for non-secure connections, while port 443 is used for secure connections.

Again, it is not 100% correct, but it is fast enough to let you know a very simple overview of what happened behind the scenes.

<Br> since we have a basic understanding of what we are trying to achieve, let's continue to install the software.

<Br> preparation

 

Apache-http://www.apache.org

Mod_SSL-http://www.modssl.org

OpenSSL (SSL Toolbox)-http://www.openssl.org

PHP (scripting language)-http://www.php.net

MySQL (SQL database server)-http://www.mysql.com

Download the source code of all (tar files) to a temporary directory. Make sure you put them in a place with a lot of space ...... You should download them as root to avoid permission issues.

<Br> our plan

 

Our plan is to first install the MySQL server and ensure it works, then we will install PHP and Mod_SSL, and finally we will install the Apache website server. After Apache is installed, we can test whether PHP and Mod_SSL support works.

<Br> install MySQL source code (UNIX)

The basic command you must use to install and install MySQL source code distribution is (from the "tar" file ):

<Br> Use su to become the root user.

<Br> $ su

<Br> directly go to the directory where you have a tar file. (Use a temporary directory. Use/tmp/download/here /)

<Br> # cd/tmp/download/

<Br> use the following command to Extract files.

<Br> # gunzip-d-c mysql-3.22.xx.tar.gz | tar xvf-

<Br> change to the new directory, which is created during extraction.

<Br> # cd mysql-3.22.xx

<Br> now you can "Configure" the MySQL server. You can use configure to specify multiple options and use configure -- help to view all options. I have selected -- prefix to specify the direct path to the installation location. Configure will check your compiler and some other things. If you have any errors, you can check the config. cache file for errors.

<Br> # configure -- prefix =/usr/local/mysq

<Br> after you complete the configuration, You can execute the following command to make the real binary code.

<Br> # make

<Br> now you are ready to install all the binary code. Run the following command to install the binary code in the directory specified by the configure -- prefix option.

<Br> # make install

<Br> after you have installed the binary code, it is time to create a mysql table for permission definition.

<Br> # scripts/mysql_install_db

# Cd/usr/local/mysql/bin

#./Safe_mysqld &

#./Mysqladmin-u root password "new-password"

<Br> Note:/usr/local/mysql is the directory where I chose to install the MySQL server. You can select another place by changing the directory.

<Br> you can run some simple tests to verify that the server is working to ensure that MySQL is running. The output should be similar to the following: BINDIR =/usr/local/mysql/bin. BINDIR depends on the directory you selected with the prefix above.

<Br> # BINDIR/mysqlshow-p

+ --------------- +

| Databases |

+ --------------- +

| Mysql |

+ --------------- +

<Br> once you have installed MySQL, it automatically creates two databases. A mysql table that controls user, host, and database permissions on the actual server; a test database that we can use. However, we want to give you a quick and simple overview of some command line options available for MySQL. This will also ensure that the root user has all the access permissions on the DB server, that is, the root user has permission to create databases, database tables, and so on. Therefore, we will create a test2 database, we will use it for our testing later. Before you enter MySQL through the command line, you will be prompted with the new password of the root user. Remember that you changed it before.

<Br> # mysql-u root-p

Mysql> show databases;

+ ---------------- +

| Database |

+ ---------------- +

| Mysql |

| Test |

+ ---------------- +

Mysql> create database test2;

Query OK, 1 row affected (0.00 sec)

<Br> select a new database and create a new table named tst_tbl. The following two fields are available. Field 1 is an id field that allows you to know the record id. In essence, to simplify this is just a row number. The second field is your name field, which stores the title information. The format of these fields is: Field 1 (I

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.