Build lamp under Linux (2)

Source: Internet
Author: User
Tags file info safe mode password protection

Centos Build Lamp

To install the Roundcube, first need to build a LAMP operating environment,

LAMP is the acronym for Linux, Apache, MySQL, and PHP, which is the installation of a Web server with PHP5 and MySQL-supported Apache on a CentOS5.3 server.

1. Suppose you already have a server with a Linux system installed, the system can be CentOS5.3, or it can be Ubuntu 9.04. This time we use CentOS5.3 as an example.

2. Installing Apache2

In general, the Apache2 is already included in the CentOS software package, the system can be installed by default, of course, you can use the following command to easily install it:

Yum Install httpd  

You will be prompted for the version that you need to install and install automatically, and if you have an update, you will see the version that needs to be updated.

If the installation is complete, the following information will be displayed:

Package httpd-2.2. 3-El5.centos. 2 . i386 already installed and latest version     Do

After installing Apache, you can start:

/ETC/INIT.D/HTTPD start  

You can view the running status:

/etc/init.d/httpd Status   is running ...  

You can now open http://localhost or http://127.0.0.1 in the browser and see the Apache 2 Test page.

To modify a configuration file:

Nano/etc/httpd/conf/httpd.conf  

You can modify the listening port 8080:

#Listen 12.34.56.78:80

Listen 8080

You can restart the service:

/ETC/INIT.D/HTTPD restart

Then continue to understand the structure of the apache2 version, which helps us configure the application:

/etc/httpd/conf/httpd.conf: The most important configuration file;

/etc/httpd/conf.d/*.conf: This is a CentOS feature, if you do not want to modify the original configuration file httpd.conf, the other configuration in this stand-alone configuration, the launch of Apache, this file will be read into the main configuration file;

/usr/lib/httpd/modules:apache support a lot of modules, the module you want to use by default is placed in this directory;

/var/www/html: This is the CentOS default "home" directory;

/var/www/error: The default system error message, host settings error or browser-side requirements of data errors, the browser appears on the error message is mainly the information here;

/var/www/icons: To provide some small Apache icons;

/var/www/cgi-bin: Default some executable CGI programs to place the directory;

/VAR/LOG/HTTPD: Log file directory, the file here is very easy to become large, need to provide enough space;

/usr/sbin/apachectl: This is Apache's main execution file, this executable file is actually shell script, it can actively detect some settings on the system, so that you start Apache easier;

/USR/SBIN/HTTPD: This is the main Apache binary file;

/USR/BIN/HTPASSWD: When you want to log in to certain pages, you need to enter your account number and password. Then Apache itself provides a basic password protection, the generation of this password is achieved through this command.

3. Installing MySQL5.0

The current version of the official MySQL Web site has reached the 5.1.39, the CentOS binding version is still 5.0, feeling still with the lower version of stability.

Execute the following command to install MySQl:

Yum install MySQL Mysql-server  

Then start the MySQL server:

/etc/init.d/mysqld start

Run the following command to set a password for the root user (otherwise anyone can access your MySQL database!) :

Mysqladmin-u root-p Password bianjie1234  

Enter Password: General initial password is empty

If the initial password is not empty or the password has been forgotten, you can use the following method to reset the root user's password:

/etc/init.d/mysqld Stop   stopping MySQL: [OK]   --user=mysql--skip-grant-tables--skip-networking &   [ 116356   from/var/lib/mysql  

To reset the root user password:

    MySQL-u root mysql           mysqlset passwordpassword=password ('bianjie1234'  where user='root';           MySQL> FLUSH privileges;           MySQL> quit           Bye       

This way your root user password has been successfully reset, then stop running in safe mode and restart MySQL normally:

    /etc/init.d/mysqld stop           from PID file/var/run/mysqld/mysqld.pid              091015: £  mysqld ended           stopping MySQL: [OK]           [1 ]+ done Mysqld_safe--user=mysql--skip-grant-tables--skip-networking           /etc/init.d/  Mysqld Start       

If you need to set a new password for the root user, run the following command:

Mysqladmin-u root-p password bianjie1234 (new password)

Enter Password: enter password

Operation MySQL

Mysql-u root-p

Enter Password: enter password

Welcome to the MySQL monitor ...

...

Server version:5.0.77 ...

...

Mysql>

MySQL has several important directories and files:

/ETC/MY.CNF: This is the MySQL configuration file, including the MySQL database optimization;

/usr/lib/mysql: This directory is the location where the MySQL database is placed, so be sure to back up the directory with a full backup.

4. Installing PHP5

Use the following command to install the PHP5 and Apache PHP5 modules:

Yum Install PHP  

Then you need to restart Apache:

/ETC/INIT.D/HTTPD restart  

This installation is relatively simple and can be tested after completion. The path to the default document for the Apache site is/var/www/html, creating a simple file info.php in this directory, and calling http://localhost/info.php in the browser will display a lot of PHP5 installation information.

nano/var/www/html/info.php

Phpinfo ();

?>

PHP5 is working, you will see that many modules can be used in the PHP5, and MySQL is not listed here, which means that PHP5 does not support MySQL, you also need to install php-mysql this package.

5. Make PHP5 support MySQL

Yum Search ph

Select the installation package that you want, and then install them by using the following command:

Yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc   yum install php-mysql  

Then restart Apache2:

Reload the http://localhost/info.php page in your browser and you'll see more of the MySQL modules you just installed.

6. Set Apache2 and MySQL boot up

Chkconfig--levels3httpd on Chkconfig--list httpd httpd0: Off1: Off2: Off3: On4: Off5: Off6: Off Chkconfig--levels3mysqld on Chkconfig--list mysqld mysqld0: Off1: Off2: Off3: On4: Off5: Off6: Off

Build lamp under Linux (2)

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.