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

Complete Debian7 configuration, LAMP (Apache/MySQL/PHP) environment, and station building

Lao Zuo has shared in a previous article“ CentOS6 Installation LAMP (Apache/MySQL/PHP) Environment Setup Tutorial "In this article, I will share my other favorite DEBIAN system environment. The two tutorials are slightly different. For beginners, they may prefer to use One click installation package However, the installation of such steps is more clear about what you need to install, and can save resources. Some components do not need to be installed, so it is unnecessary to install them. If Lao Zuo has the opportunity to install these steps into a one button package in the future, it will be a little more convenient.

Installation environment: Debian7 32-bit is used for this article demonstration.

First, install and configure the Apache Web server

Run the upgrade command to ensure that all aspects of our system components are up to date.

apt-get update
apt-get upgrade --show-upgraded

Install the current version of the Apache Web server (in the 2. x series), and execute the following command:

apt-get install apache2

Most application websites use the path rewriting (pseudo static) function. By default, APACHE is not installed. We need to run scripts to support rewriting

a2enmod rewrite

Start rewrite.

Edit the/etc/apache2/apache2.conf file configuration to optimize the system operation (the test machine is based on the 1GB memory VPS)

<IfModule mpm_prefork_module>
StartServers 2
MinSpareServers 6
MaxSpareServers 12
MaxClients 80
MaxRequestsPerChild 3000
</IfModule>

In this step, we can also default to adjust the website operation to compare the differences. Lao Zuo has not yet understood the corresponding performance differences of the parameters in this step. In the past, when I used the MAPN environment, MYSQL occupied too much, and after adjustment, the occupancy rate was much lower.

After configuration, we need to configure the domain name and sub domain name to add sites.

Second, configure the virtual host and bind the domain name

In/etc/apache2/ sites-available/ This folder is used to store the site domain name configuration files of all sites. When setting sites, use the domain name. conf so that you can see the corresponding sites when there are many sites. For example, if we want to create two sites, we need to configure two conf files, as follows:

Site A -/etc/apache2/sites-available/laozuo.org.conf

<VirtualHost *: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
</VirtualHost>

Site B -/etc/apache2/sites available/idcxen.com.conf

<VirtualHost *:80>
ServerAdmin webmaster@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>

According to the above demonstration, we will set up several sites CONF file, and then configure its path. Similarly, we need to create several directories involved above.

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

Execute the command to start the site

a2ensite laozuo.org.conf
a2ensite idcxen.com.conf

Start Apache

service apache2 restart

remarks: If we want to cancel this site, use this command to cancel this site

a2dissite laozuo.org.conf

Third, install and configure MySQL database

A - Install MYSQL

apt-get install mysql-server

During the execution process, we need to enter MYSQL's ROOT user password, which is slightly more complicated. The database configuration file is located in/etc/mysql/my.cnf. If we need to adjust it, we should backup one first.

B - Configure MySQL to create a database

mysql_secure_installation

We need to enter the MYSQL database ROOT password set above to enter. The first time we enter, we will ask whether we need to modify and other settings. We can select the n/y option as required.

mysql -u root -p

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

Use the root permission to enter the MYSQL database, enter the password we set before, and then create the laozuoorg Database name, laozuouser Data sheets, and laozuo.org Set the database password.

 DEBIAN LAMP database addition

Enter after creation quit Exit MYSQL settings.

Fourth, install and set the PHP environment

apt-get install php5 php-pear

After installation, we need to configure the php.ini file (/etc/php5/apache2/php. ini) It can be left unchanged by default

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

We also need to create a log directory and set permissions

mkdir /var/log/php
chown www-data /var/log/php

If we need PHP support for MySQL, we must install the following commands of the PHP 5 MySQL package:

apt-get install php5-mysql

Start Apache

service apache2 restart

In this way, through the above four steps, we can set up the site and database. Later, we just need to upload the web program to/srv/www/idcxen.com/public_html, and then install according to the prompts.

PS: Lao Zuo successfully installed WORDPRESS. The only thing to note is that the root directory permission needs to be writable. htaccess or manually create a pseudo static file, so that the background fixed connection settings will take effect.

chown -R www-data:www-data /srv/www/

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( one )
Do not reprint without permission: Lao Zuo's Notes » Complete Debian7 configuration, LAMP (Apache/MySQL/PHP) environment, and station building


Scan the code to follow the official account

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