Linux5.4RHCEApache Advanced Configuration learning notes

Source: Internet
Author: User
Objectives: 1. Set up a LAMP environment (based on the rpm package) and install the Forum. 2. Set up the personal homepage and perform user authentication. 3. Use an alias to convert the website directory. 1. IP address Description: 192.168.1.6 -- Host Name: apache.wqmsl.com & nbs

Goals: 1. Set up the LAMP environment (based on the rpm package) and install the Forum

2. Personal Homepage settings and User Authentication

3. Use aliases to convert website Directories

1. IP address description:

192.168.1.6 -- Host Name: apache.wqmsl.com apache server

192.168.1.4 -- Host Name: dns.wqmsl.com dns Client

2. Preparations

Change Host Name (three changes): 1. Change hostname, 2. Change hosts, 3./etc/sysconfig/network

3. the required software packages are as follows:

(1) install MySQL

Perl-DBI-1.52-1.fc6.i386.rpm
Perl-DBD-MySQL-3.0007-1.fc6.i386.rpm
Mysql-5.0.22-2.1.0.1.i386.rpm
Mysql-server-5.0.22-2.1.0.1.i386.rpm
Mysql-devel-5.0.22-2.1.0.1.i386.rpm

(2) PHP installation

Php-5.1.6-15.el5.i386.rpm
Php-cli-5.1.6-15.el5.i386.rpm
Php-common-5.1.6-15.el5.i386.rpm
Php-mysql-5.1.6-15.el5.i386.rpm
Php-pdo-5.1.6-15.el5.i386.rpm

(3) httpd Installation

Httpd-2.26

I. Below we will achieve the first experiment goal, build a LAMP environment (based on the rpm package) and install the Forum

I chose to use yum to install mysql first.

Automatically resolves mysql-5.0.22-2.1.0.1.i386.rpm dependencies when installing the perl-DBI-1.52-1.fc6.i386.rpm

Automatically resolves mysql-server-5.0.22-2.1.0.1.i386.rpm dependencies when installing the mysql-server-5.0.22-2.1.0.1.i386.rpm

Last install mysql-devel-5.0.22-2.1.0.1.i386.rpm

Let's start mysql.

Started successfully. Set the MySQL root User Password.

Mysqladmin-u root password 123456 -- set the password

Mysql-u root-p -- use the root user to log on to the MySQL database

After creating the database we need, we can see that the bbs database we created has been successfully created.

Exit with exit

The second step to install the rpm package required by PHP, the default system has installed php-5.1.6-15.el5.i386.rpm,
Php-cli-5.1.6-15.el5.i386.rpm, php-common-5.1.6-15.el5.i386.rpm these three

Automatically resolves the dependent package php-mysql-5.1.6-15.el5.i386.rpm when installing the php-pdo-5.1.6-15.el5.i386.rpm

In this way, PHP installation is complete.

The third part is to install the httpd service (which has been installed by default). If it is not installed, install httpd through yum install.

Configure the Apache configuration file

Configure the Administrator mailbox and listening address and port

Configure the directory for storing web pages

Modify simultaneously (same as above)

Modify the homepage document and add the PHP homepage document

Save and exit

Create a directory for storing web pages and grant permissions

Start the httpd service

Write a PHP test webpage and test whether the installation is successful.

Use a browser on the client to open the IP address or domain name of the server for testing.

The following is what I opened:

PHP Information

Apache Information

MySQL-related information

Information about Mysqli

With such content, your LAMP can be determined that the installation is successful.

Let's install a forum program.

This is a PHP Forum program I downloaded and the language is UTF-8 (Apache is UTF-8 by default)

There are also GB2312, so you have to modify the language of the httpd. conf configuration file. This is described in the general configuration.

Upload All files in upload to the directory where your server stores webpages (you can use winSCP to upload files. The actual environment is FTP)

Open the file in the browser after the upload is complete.

Click to start Installation

As prompted, some files require 777 permissions. You only need to set permissions. Otherwise, the installation will fail.

Enter basic information, such as the database password.

Then, the installation details are output, and the database is created.

Click Finish.

Let's take a look at the self-installed forum.

Front-end page

Background login interface

Background Management Interface

Now, the installation is complete.

You can also try to use the source code for installation.

2. Personal Homepage settings

Edit the Apache configuration file to enable the settings of the user's personal homepage.

Comment out this line: UserDir disable

Delete the line before UserDir public_html #

Create the public_html directory under the user's home directory and Set permissions

Create the user's homepage in the public_html directory

Let's test it in a browser (http: // domain name or IP address /~ Username /)

In this way, the personal homepage of a user is set up.

Next we configure basic authentication, based on the user name and password

We use a flexible authentication configuration method and directory-based authentication to put the authentication file in the main business directory that users can manage, so that users can modify it at will.

Let's perform user authentication for the bbs Forum installed with LAMP.

Add the permission settings for the directory where the forum is located.

Add the following content to set permissions for the webpage directory and enable basic user authentication:

Save and exit

Configure the authentication file in the web directory

Note: There is "." In Front Of. htaccess, which is a hidden file.

Description:

<> Directory

Authtype is the Basic authentication of the authentication type Basic apache.

Authname indicates the Authentication Name. It is a prompt in the dialog box prompting you to enter the password.

Authuserfile is a file that stores authenticated users.

Require user allows access by one or more specified users, that is, the redking user

If there are other users in the authentication file, they still cannot access

If require valid-user is used, all users in the authentication file can access

Require group is authorized to a group. This parameter is rarely used.

Generate an htpasswd file and add user data to htpasswd.

Note:-c is used to create bbs. htpasswd file. The last bbs is to be added to bbs. users in htpasswd. bbs is a system user. I have already set up the bbs system user in advance.

You can also add other users. For example, you can add another www User:

Note: Because the bbs. htpasswd file already exists, we do not need to add the-c parameter in this add user statement, and then prompt you to enter the password

Check out the content of bbs. htpasswd.

The added user information is displayed.

Next, restart the service.

Access for testing

In this way, user-based authentication is successfully configured.

To make everyone better understand, let's set up another one, that is, to authenticate the user's home page configuration in the second experiment target.

Add the permission configuration for the webpage directory as above

Configure the authentication file in the user's home directory. I have configured the content.

Generate the htpasswd file and add user data to htpasswd.

Restart the service and access the test user homepage for testing.

You can access it...

Wow, this is so much that I have finally finished writing it. The alias configuration is implemented below.

2. The third goal is to use aliases to convert website directories.

Next let's configure and search for Alias. Add "Alias/test"/home/test/public_html/"under the default 539 line /""

In this line, Alias/test: Is the Alias name, "/home/test/public_html/": is the location of the real website Directory, and Directory is the permission setting for your real Directory.

After the modification, keep and restart the service. Let's test it and check the result.

Note: enter the name of the http: // domain name or IP/alias in the browser.

Alias set,

 

 

If you use the compilation and installation of apache to start the service, you may encounter the following problems:
Error message:
Make_sock: cocould not bind to address 0.0.0.0: 80
No listening sockets available, shutting down
Unable to open logs
Solution:
This problem occurs because the default port of APACHE is occupied. The solution is to remove the port occupied by the program or change the port occupied by APACHE.
Of course, APACHE's port is a good solution. Just change the configuration file. Now let's talk about how to change other files to occupy APACHE's default port 80.
First, check which program occupies the port. The method is:

1. netstat-lnp | grep 80

Tcp 0 0 192.168.1.6: 61027 0.0.0.0: * LISTEN 6289/oproxyd
Tcp 0 0: 80: * LISTEN 846/httpd
Tcp 0 0: ffff: 192.168.180.68: 7001: * LISTEN 32015/java

Find pid 846

# View data in ps 846

# Kill-9 kill 846

Restart your service.

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.