CentOS5.3 build a LAMP (Linux + Apache + MySQL + PHP) Web server

Source: Internet
Author: User
Tags file info website server password protection roundcube
Recently, I am preparing to install roundcube. I need to build a LAMP runtime environment and search for it from the internet. I have a lot of information. I installed it step by step and sorted out the process. LAMP is short for Linux, Apache, MySQL, and PHP. it is installed with PHP5 on a CentOS5.3 server.

Recently, I am preparing to install roundcube. I need to build a LAMP runtime environment and search for it from the internet. I have a lot of information. I installed it step by step and sorted out the process.

LAMP is the abbreviation of Linux, Apache, MySQL, and PHP. it is to install a website server with PHP5 And Mysql supporting Apache on a CentOS5.3 server.

1. suppose you already have a server installed with Linux, which can enable CentOS5.3 or Ubuntu 9.04. This is an example using CentOS5.3.

 

2. install Apache2
Generally, Apache2 is included in the CentOS Package. you can install Apache2 by default. of course, you can use the following command to install it easily:
Yum install httpd
The system prompts the version to be installed and automatically installs it. if any version is updated, the system displays the version to be updated.
If the installation is complete, the following information is displayed:
Package httpd-2.2.3-22.el5.centos.2.i386 already installed and latest version
Nothing to do
After installing Apache, you can start:
/Etc/init. d/httpd start
You can view the running Status:
/Etc/init. d/httpd status
Httpd is running...
Now you can open http: // localhost or http: // 127.0.0.1 in the browser to see the Apache 2 Test Page.
Modify the configuration file:
Nano/etc/httpd/conf/httpd. conf
You can modify the listening port 80> 8080:
# Listen 12.34.56.78: 80
Listen 8080.
You can restart the service:
/Etc/init. d/httpd restart
Next, let's take a look at the structure of apache2, which helps us to configure the application:
/Etc/httpd/conf/httpd. conf: The main configuration file;
/Etc/httpd/conf. d /*. conf: this is a feature of CentOS. if you do not want to modify the original configuration file httpd. conf, other configurations are configured independently here. When apache is started, this file will be read into the main configuration file;
/Usr/lib/httpd/modules: apache supports many modules. the modules you want to use are stored in this directory by default;
/Var/www/html: the default "homepage" directory of CentOS;
/Var/www/error: the default system error message. if the host is set incorrectly or the data requested by the browser is incorrect, the error message displayed in the browser is based on the information here;
/Var/www/icons: provides some small icons of apache;
/Var/www/cgi-bin: The Directory of some executable CGI programs by default;
/Var/log/httpd: Directory of log files. the files here are easy to increase and sufficient space is required;
/Usr/sbin/apachectl: this is the main execution file of Apache. the execution file is actually a shell script, which can actively detect some settings on the system, this makes Apache startup easier;
/Usr/sbin/httpd: this is the main apache binary file;
/Usr/bin/htpasswd: when you want to log on to some Web pages, you need to enter your account and password. Apache itself provides the most basic password protection method. This command is used to generate the password. 3. install MySQL5.0
At present, the official MySQL website version has reached 5.1.39, and the CentOS binding version is still 5.0. it still feels stable with a lower version.
Run the following command to install MySQl:
Yum install 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: Generally, the initial password is empty.
If the initial password is not blank or has forgotten the password, you can reset the password of the root user using the following methods:
/Etc/init. d/mysqld stop
Stopping MySQL: [OK]
Mysqld_safe -- user = mysql -- skip-grant-tables -- skip-networking &
[1] 16356
Starting mysqld daemon with databases from/var/lib/mysql
Reset the root user password:
Mysql-u root mysql
Mysql> update user set password = password (bianjie1234) where user = root;
Mysql> flush privileges;
Mysql> quit
Bye
In this way, your root user password has been successfully reset, then the security mode is stopped, and MySQL is restarted normally:
/Etc/init. d/mysqld stop
STOPPING server from pid file/var/run/mysqld. pid
091015 16:57:28 mysqld ended
Stopping MySQL: [OK]
[1] + Done mysqld_safe -- user = mysql -- skip-grant-tables -- skip-networking
/Etc/init. d/mysqld start
To set a new password for the root user, run the following command:
Mysqladmin-u root-p password bianjie1234 (new password)
Enter password: Enter the password
Operate MySQL
Mysql-u root-p
Enter password: Enter the 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 mysql database optimization;
/Usr/lib/mysql: The Directory where the MySQL database is stored. make sure that the directory is completely backed up during backup.


4. install PHP5
Run the following commands to install the PHP5 and Apache PHP5 modules:
Yum install php
Then you must restart Apache:
/Etc/init. d/httpd restart
This installation is relatively simple. you can test it after installation. The default document path of the Apache website is/var/www/html. create a simple file info in this directory. php, and call http: // localhost/info in the browser. php 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 PHP5, and MySQL is not listed here, which means PHP5 does not support MySQL, you also need to install the php-mysql package.

5. make PHP5 support MySQL
Yum search ph
Select the required installation package and run the following command to install them:
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:

 

/Etc/init. d/httpd restart
Reload the http: // localhost/info. php page in the browser, and you will see the newly installed MySQL module.

6. set startup for Apache2 and MySQL
Chkconfig -- levels 3 httpd on
Chkconfig -- list httpd
Httpd 0: off 1: off 2: off 3: on 4: off 5: off 6: off
Chkconfig -- levels 3 mysqld on
Chkconfig -- list mysqld
Mysqld 0: off 1: off 2: off 3: on 4: off 5: off 6: off

Okay. a LAMP server is built!

 

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.