Apache + MySQL + PHP Installation Guide

zhaozj2021-02-16  46

L.a.m.p. (Linux, Apache, MySQL, PPH) is a gold combination of open source software, almost every Linux development or management will have a chance to come into contact with LAMP, "How to install?" Is asking the most questions. This article will install Apache, MySQL, and PHP on Linux, I hope to help everyone.

The first is to install MySQL

MySQL installation is relatively complicated, I chose the RPM file provided by RedHat to move the installation, which reduces the opportunity to make mistakes.

Go to http://dev.mysql.com/downloads/mysql/4.0.html to download the RPM file of MySQL 4.0. Find Linux X86 RPM Downloads column, usually only Server (Standard), Client, Shared, and DEVEL four RPM is enough. We download these four RPM files to the / root directory.

Note: The following instructions require root privileges.

Before installing, use the instruction to judge whether you have installed MySQL rpm in your system:

RPM -QA | GREP "* mysql *"

If the RPM with related mysql is already installed on your system, it is recommended to remove these rpm first:

RPM-E RPM_FILE_NAME

If you have a problem with Dependency, use rpm -e --force - nodeps rpm_file_name to force deletion.

Make sure that all RPMs about MySQL are deleted, we start to install MySQL 4.0. In the / root directory, LS displays all RPM files, you should find four mysql rpm that just down Download. start installation:

Rpm -i mysql-server-4.0.18-0.i386.rpm

Rpm -i mysql-shared-4.0.18-0.i386.rpm

Rpm -i mysql-client-4.0.18-0.i386.rpm

Rpm -i mysql-devel-4.0.18-0.i386.rpm

Note: If an error message occurs during the installation process, try to change the order of the above instructions.

After successful installation, files such as mysql mysqladmin will be stored in the / usr / bin directory. And a MySQL file will be added to your /etc/init.d directory, which is used to automatically launch MySQL Service after each system Reboot. You can start, restart, or terminate the MySQL Service by Service MySQL Start, Service MySQL Stop. Use the ChkConfig --List command to find if the mysql service is added to the service list, if not, add mysql service with the following instructions:

Chkconfig --Add MySQL

Note: If you find your system doesn't know the chkconfig this command, you can try to play / sbin / chkconfig.

Note: After installing MySQL RPM, it automatically installs MySQL built-in Database (Mysql and Test).

After installing mysql, use

mysqladmin -u root password your_new_password

Reset the password of the root user mysql, such as Doodoofish.

Mysqladmin -u root password doodoofish

Next time, you must use root and doodoofish as the username and password to use mysql:

Mysql -u root -p

After the prompt, enter your doodoofish password, you should be able to enter mysql.

Note: Enter / Q can exit MySQL.

This is still not finished. For your safety, I recommend execution of the instruction to protect your mysql: mysql -u root -p

Mysql> Use mysql

Mysql> delete from user where not (host = "localhost" and user = "root");

mysql> flush priviledge;

This will be forced, and the user will log in to Mysql with the root account.

It is best to change root into a name that is not easy to guess, such as:

MySQL> Update user set user = "sqladmin" where user = "root";

mysql> flush priviledge;

OK, you have successfully installed MySQL, which is the hardest part of the installation of Apache MySQL PHP.

Install Apache

Install apache is much simple, go http://httpd.apache.org/download.cgi to download the httpd-2.0.49.tar.gz to / root directory.

In / root directory, enter:

Gunzip httpd-2.0.49.tar.gz

Tar-xvf httpd-2.0.49.tar

Will create a new HTTPD-2.0.49 directory in the / root directory. Move the entire directory to / usr / local / src

MV /Root/httpd-2.0.49 / usr / local / src /

Go to /usr/local/src/httpd-2.0.49 directory

CD /usR/local/src/httpd-2.0.49

Ok, let's start installing:

./configure / - prefix = / usr / local / Apache / - enable-shared = max / - enable-module = rEWRITE / - Enable-module = SO Perform the above instructions, there should be no error message. --prefix = / usr / local / apache means we have to install Apache into the / usr / local / apache directory.

Make

Use Make to compile.

Make Install

Install apache.

After the installation is successful, Apache will be stored under / usr / local / apache.

Install PHP

Similarly, you must download PHP first. Go to http://www.php.net/downloads.php Download PHP 4.3.6 (TAR.GZ) Source Code (notice is binary). Download to the / root directory.

Gunzip php-4.3.6.tar.gz

TAR-XVF PHP-4.3.6.tar

Move the new PHP-4.3.6 directory to the / usr / local / src directory. Switch to /usr/local/src/php-4.3.6 directory

CD /usR/local/src/php-4.3.6

Below, we have to install PHP into a Module of Apache.

./configure / - with-apxs2 = / usr / local / apache / bin / APXS / - DISABLE-Debug / - Enable-ftp / - enable-inline-Optimization / - Enable-Safe-Mode / -ENABLE-TRACK-VARS / - Enable-Trans-Sid / - Enable-XML / - with-mysql / - with-XML / There is no error message.

Make

Make Install

Installed. Copy /usr/local/src/php-4.3.6/php.ini-dist to / usr / local / lib /, and renamed PHP.ini

Cp /usr/local/src/php-4.3.6/php.ini-dist /usr/local/lib/php.ini

Successful installation. Below you will configure Apache.

CD / usr / local / apache / confation

Vi httpd.conf

Add in httpd.conf files

AddType Application / X-httpd-php .phpaddType Application / X-httpd-php-source .PHPS should add the above two sentences after other addtype.

Make sure there is a sentence in the file, not adding yourself after all LoadModule.

LoadModule PHP4_Module Modules / Libphp4.so

Ok, ": wq" saves the httpd.conf file and exits the VI. Start Apache Server:

/ usr / local / apache / bin / apachectl start

If you want your Apache to start automatically after the system reboot, you can do this:

Cp /usr/local/src/httpd-2.0.49/support/apachectl /etc/rc.d/init.d/httpd

vi /etc/rc.d/init.d/httpd

In the third line of the HTTPD file, insert the following two sentences:

# chkconfig: 345 85 15 # Description: Starts and stops The apache http server.

": wq" saves the httpd file and exits the VI.

Turn httpd into an executable:

CHMOD X /etc/rc.d/init.d/httpd

Add httpd to the service list:

Chkconfig --Add httpd

Check if httpd is added to the service list

Chkconfig --List

After success, you can start, restart, and terminate the HTTPD Service (Httpd Service is apache service) with Service Httpd Start, Service Httpd Restart, Service Httpd Stop.

Ok, all installations are complete, and PHP and Apache will be tested below.

Test PHP and Apache

Under the / usr / local / apache / htdocs directory, create a Test.php file, only one sentence in the file:

Save this file.

Enter http: // localhost in your browser, you should see the welcome page of Apache.

Enter http://localhost/test.php in your browser, you should see system information of PHP.

Finally, your light bulb (l.a.m.p.) is finally installed. Congratulations!

转载请注明原文地址:https://www.9cbs.com/read-24997.html

New Post(0)