Centos6.5 install and configure the LAMP (linux, apache, mysql, php) Environment

Source: Internet
Author: User
Tags apache php mcrypt php error php mysql apache log fully qualified domain name
1. Install apahce1, update yumyumupdate, input y update, install apacheyuminstallhttpd, input y, and install apache. 3. Select the yuminstallhttpd-manual help document: localhostmanualhowtocgi4 and start apacheetcinit. dhttpdstart (restart: heavy

1. install apahce 1. update yum update input y update 2. install apache yum install httpd input y install 3. You can choose to install apache's help documentation yum install httpd-manual: http: // localhost/manual/howto/cgi 4. Start apache/etc/init. d/httpd start (restart: heavy

1. Install apahce

1. Update yum

Yum update

Enter y to update


2. install apache

Yum install httpd

Enter y to install


3. You can choose to install the apache help documentation.

Yum install httpd-manual

Access document: http: // localhost/manual/howto/cgi


4. Start apache

/Etc/init. d/httpd start (restart: restart) or service httpd start (restart: restart)

An error will be reported after startup: Starting httpd: cocould not reliably determine the server's fully qualified domain name, using 10.171.202.8 for ServerName

You can ignore this error or solve it as follows:

Open the apache configuration file vim/etc/httpd/conf/httpd. conf.

Find # ServerName www.example.com: 80 and change my domain name or localhost to restart apache.


5. Start apache

Chkconfig httpd on


Ii. Install mysql

(

Available resource package:

Http://centos.ustc.edu.cn/epel/6/x86_64/epel-release-6-8.noarch.rpm
Http://rpms.famillecollet.com/enterprise/6/remi/x86_64/remi-release-6.5-1.el6.remi.noarch.rpm
)


1. Select a version: You can search for a third-party yum resource package.

Version 5.1. *: yum install mysql-server mysql-devel

Version 5.5. *: yum -- enablerepo = remi install mysql-server mysql-devel


2. Start mysql

/Etc/init. d/mysqld start (restart: restart) or service mysqld start (restart: restart)


3. Start mysql at startup

Chkconfig mysqld on


4. Change the my. cnf File

Cp/usr/share/mysql/my-medium.cnf/etc/my. cnf directly Overwrite


5. Set the password

After mysql is installed, a password is automatically set for the primary installation information.

You can also use msyql_secure_installation: Press enter in the first step, enter the password twice, and press Y all the time.


3. install php

1. Select a version: You can search for a third-party yum resource package.

Version 5.3. *: yum install php-mysql php-mcrypt php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc

Version 5.4. *: yum -- enablerepo = remi install php-mysql php-mcrypt php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc

2. Restart apache mysql


Simple configuration of apache

Open the file vim/etc/httpd/conf/httpd. conf


These three items are useless. I can add them when I see a lot of people writing them.

Modify KeepAlive Off to KeepAlive On (allow procedural connection) In line 76)

Modify Options Indexes FollowSymLinks to: Options shortdes ExecCGI FollowSymLinks on line 3 (allows the server to execute CGI and SSI)

# Modify AddHandler cgi-script. cgi to AddHandler cgi-script. cgi. pl in line 3 (run a CGI script with the extension of. pl)


These five items are useful

AllowOverride None is changed to AllowOverride All (allow. htaccess) in row 338)

AddDefaultCharset UTF-8 set character encoding in line 759, configured as needed

Options Indexes: If Indexes is deleted when the domain name is configured, the tree directory structure is not displayed on the browser.

DirectoryIndex index.html. var: Set the default homepage file in row 402, and add index. php and so on.

Modify MaxKeepAliveRequests 100 in line 83 to 1000 (Increase the number of simultaneous connections)


Modify the apache parsing directory

Modify DocumentRoot "/var/www/html" to your directory "/data0/www/xxx" (This directory is the mounted data disk)

Rm-f/etc/httpd/conf. d/welcome. conf/var/www/error/noindex.html # Delete the default test page

Apache Log Files
ErrorLog/etc/httpd/logs/error_log (php error logs are also output here)
CustomLog/etc/httpd/logs/access_log combined


Simple php configuration

Open the configuration file vim/etc/php. ini

Date. timezone = PRC remove the semicolon and change it to date. timezone = PRC China Time Zone

Magic_quotes_gpc = On # Open magic_quotes_gpc On Line 1 to prevent SQL injection (not supported at php5.4 ))

Restart apache


For more information about the configuration of apache php mysql, see related documents.

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.