Table of Contents
Step 1: Install and configure Apache server
Step 2: Set up and bind site directory files
Step 3: Install MYSQL database
Step 4: Install PHP environment
Summary
>>Begin:
Step 1: Install and configure Apache server
yum update #Update yum
yum install httpd # Use yum to install httpd (httpd is the Apache server) Click->Learn about yum
Install the current version of the Apache configuration environment, and then configure the httpd.conf (located in /etc/httpd/conf/httpd.conf) file. You can also use the default configuration file directly.
KeepAlive Off
...
StartServers 2
MinSpareServers 6
MaxSpareServers 12
MaxClients 80
MaxRequestsPerChild 3000
When configuring, it is not necessary to delete all the settings, but to modify the corresponding parameters.
Step 2: Set up and bind site directory files
Manually installing LAMP is different from using the one-click package to directly add a domain name and build a site using commands. All of these require manual operations. For example, here we need to add a domain name to build a site.
vim /etc/httpd/conf.d/vhost.conf #vim is an editing tool under Unix/Linux; the meaning of this command: in the /etc/httpd/conf.d/ directory Create vhost.conf text configuration file
Create the vhost.conf file in the above directory, and then configure the site
NameVirtualHost *:80
ServerAdmin admin@laozuo.org
ServerName laozuo.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
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
We can see in the above file that 2 sites are added. If multiple sites are added, similarly copy and modify the corresponding directories. 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/logsmkdir -p /srv/www/idcxen.com/public_html
mkdir /srv/www/idcxen.com/logs
The corresponding directory path such as srv was created by me. If other paths are needed, we create them ourselves according to our own needs.
Start httpd and set it to start at boot.
/etc/init.d/httpd start
/sbin/chkconfig --levels 235 httpd on
/etc/init.d/httpd reload
Step 3: Install MYSQL database
A - Install and start
yum install mysql-server #Install 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 ROOT permissions, and set the ROOT password according to the prompts
During this installation process, you can select to remove the default other users and other default data.
mysql -u root -p # Log in to ROOT database user
Step 4: Install PHP environment
yum install php php-pear #Use yum to install the php environment
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.
Create a log file. If we need to support MYSQL in PHP, we need to enter the following command to install the php5-mysql package.
mkdir /var/log/php
chown apache /var/log/php
Install and set up to start.
yum install php-mysql
/etc/init.d/httpd restart
Summary:
In this way, our domain name site binding and MYSQL database have been added. For example, if we need to install the WORDPRESS program or other programs under the laozuo.org domain name, we only need to install it in the /srv/www/laozuo.org/public_html/ directory Just upload the program and then install it using the set database user.
In addition, you must also be able to use vim to edit files (vim learning reference), and use basic Unix/Linux commands (Linux command learning reference);