Focus on cloud service provider activities
Notes on website operation and maintenance

Complete configuration CentOS6 installation LAMP (Apache/MySQL/PHP) environment setup tutorial

Lao Zuo's blog also shared it very early“ LAMP one button installation package ", but sometimes the machine is not suitable for one click package. The best way is to install the environment step by step. If you need to install LAMP (Linux/Apache/MySQL/PHP) environment, it is recommended to adopt the following step-by-step method, so that you can not make errors, but also be familiar with the entire installation process. This original LAMP installation method is based on the CENTOS6 32-bit environment. It has been tested to be fully effective and can build a PHP+MYSQL site after installing the Apache/MySQL/PHP environment.

 LAMP environment installation process

Step 1: Install and configure the Apache server

yum update
yum install httpd

Install the current version of the Apache configuration environment, and then configure the httpd.conf file (located in/etc/httpd/conf/httpd. conf). Generally, similar to the Linode 1GB scheme, this can be set or defaulted.

KeepAlive Off
......
<IfModule prefork.c>
StartServers 2
MinSpareServers 6
MaxSpareServers 12
MaxClients 80
MaxRequestsPerChild 3000
</IfModule>

When configuring, it is not necessary to delete all the settings, but to modify the corresponding parameters.

Step 2: Set and bind the site directory file

Installing LAMP manually is different from using one click package to add a domain name and establish a site directly with a command. All of these must be done manually. For example, we need to add a domain name to establish a site here.

/etc/httpd/conf.d/vhost.conf

Create the vhost.conf file in the above directory, and then configure the site

NameVirtualHost *:80

<VirtualHost *:80>
ServerAdmin admin@laozuo.org
ServerNamelaozuo.org
ServerAlias www.laozuo.org
DocumentRoot /srv/www/laozuo.org/public_html/
ErrorLog /srv/www/laozuo.org/logs/error.log
CustomLog /srv/www/laozuo.org/logs/access.log combined
</VirtualHost>

<VirtualHost *:80>
ServerAdmin admin@idcxen.com
ServerNameidcxen.com
ServerAlias www.idcxen.com
DocumentRoot /srv/www/idcxen.com/public_html/
ErrorLog /srv/www/idcxen.com/logs/error.log
CustomLog /srv/www/idcxen.com/logs/access.log combined
</VirtualHost>

We can see in the above file that it is to add two sites. If it is to add multiple sites, it is necessary to modify the corresponding directory for similar replication. Similarly, we need to create a directory path that does not exist in the corresponding directory.

mkdir -p /srv/www/laozuo.org/public_html
mkdir /srv/www/laozuo.org/logs

mkdir -p /srv/www/idcxen.com/public_html
mkdir /srv/www/idcxen.com/logs

The corresponding directory path, such as srv, is created by me. If we need other paths, we can create them according to our own needs.

/etc/init.d/httpd start
/sbin/chkconfig --levels 235 httpd on
/etc/init.d/httpd reload

Start httpd and set startup.

Step 3: Install the MYSQL database

A - Install and start

Yum install mysql server # Install the MySQL service

/Sbin/chkconfig -- levels 235 mysqld on # Set startup

/Etc/init.d/mysqld start # Start MYSQL

B - Set database user

Mysql_secure_installation # Install and set the ROOT permission, and set the ROOT password according to the prompt

You can remove the default other users and other default data.

MySQL - u root - p # Log in to ROOT database user

create database laozuo;
grant all on laozuo.* to 'laozuouser' identified by 'laozuo.org';

Create laozuo database user, laozuuser database user name, and laozuo.org database password, which we need to use later when building the website. After creation, enter quit to exit.

Step 4: Install the PHP environment

yum install php php-pear

Install the PHP environment, and then configure the/etc/php.ini file.

error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR
display_errors = Off
log_errors = On
error_log = /var/log/php/error.log
max_execution_time = 30
memory_limit = 128M
register_globals = Off
max_input_time = 30

Use vi to find the above parameters, then modify the parameters accordingly, save and exit.

mkdir /var/log/php
chown apache /var/log/php

Create log files. If we need to support MYSQL in PHP, we need to enter the following command to install the php5 mysql package.

yum install php-mysql
/etc/init.d/httpd restart

Install and set up startup.

In this way, our domain name site binding and MYSQL database have been added. For example, we need to install the WORDPRESS program or other programs under the laozuo.org domain name. We just need to upload the program under the/srv/www/laozuo.org/public_html/directory, and then use the set database for user installation.

Domain name host preferential information push QQ group: six hundred and twenty-seven million seven hundred and seventy-five thousand four hundred and seventy-seven Get preferential promotion from merchants.
Like( zero )
Do not reprint without permission: Lao Zuo's Notes » Complete configuration CentOS6 installation LAMP (Apache/MySQL/PHP) environment setup tutorial


Scan the code to follow the official account

Get more news about webmaster circle!
Entrepreneurship, operation and new knowledge