Complete Debian7 configuration LAMP (Apache/MySQL/PHP) environment and build website

888u

Last update at :2024-06-28,Edit by888u

In a previous article, Snail has shared \\"CentOS6 Installation LAMP (Apache/MySQL/PHP) Environment Building Tutorial\\". In this article, I will share my other favorite DEBIAN system environment. , the two tutorials are slightly different. Newbies may prefer to use a one-click installation package, but such a step-by-step installation will make it clearer what they need to install, and it can save resources. There is no need to install some components if they do not need to be installed. If you have the opportunity, you can also install these steps in the future. It will be much more convenient to make it into a one-click package.

Installation environment: This article uses Debian7 32-bit for demonstration.

Article Directory Hide

First, install and configure the Apache Web server

Second, configure the virtual host and bind the domain name

Third, install and configure the MySQL database

Fourth, install and set up the PHP environment

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 updateapt-get upgrade –show-upgraded

To install the current version of the Apache web server (in the 2.x series), execute the following command:

apt-get install apache2

Most application websites will use the path rewriting (pseudo-static) function. APACHE is not installed by default. We need to run a script to support rewrite

a2enmod rewrite

Start rewrite.

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

StartServers 2MinSpareServers 6MaxSpareServers 12MaxClients 80MaxRequestsPerChild 3000

We can also default to this step and wait until the website is running before making adjustments to compare the differences. Snail has not yet understood the performance differences corresponding to the parameters here. In the past, when I used the MAPN environment, MYSQL took up too much. Then the occupancy rate is much lower after adjustment.

After the configuration is completed, we need to configure the domain name and subdomain name to add the site.

Second, configure virtual host and bind domain name

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

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

ServerAdmin [email protected]ServerName laozuo.orgServerAlias ​​www.laozuo.orgDocumentRoot /srv/www/laozuo.org/public_html/ErrorLog /srv/www/laozuo.org/logs/error.logCustomLog /srv/www/laozuo. org/logs/access.log combined

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

ServerAdmin [email protected]ServerNameidcxen.comServerAlias ​​www.idcxen.comDocumentRoot /srv/www/idcxen.com/public_html/ErrorLog /srv/www/idcxen.com/logs/error.logCustomLog /srv/www/idcxen.com /logs/access.log combined

Following the above demonstration, if we have several sites, we will build several .CONF files and then configure their paths. We also need to create the several directories involved above.

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

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

Execute the command to start the site

a2ensite laozuo.org.confa2ensite idcxen.com.conf

Start Apache

service apache2 restart

Note: If we want to cancel the operation of this site, then use this command to cancel the site

a2dissite laozuo.org.conf

Third, install and configure the MySQL database

A – Install MYSQL

apt-get install mysql-server

During the execution process, we need to enter the ROOT user password of MYSQL, which is slightly more complicated. The database configuration file is in /etc/mysql/my.cnf. If we need to adjust it, try to back it up first.

B - Configure MySQL to create a database

mysql_secure_installation

We need to enter the MYSQL database ROOT password set above before we can enter. When entering for the first time, we will ask whether we need to modify it, as well as various other settings. We select the n/y option as needed.

mysql -u root -p

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

Use root privileges to enter the MYSQL database, enter the password we set before, then create the laozuoorg database name, laozuouser data table, and set the database password for laozuo.org.

After creation, enter quit to exit MYSQL settings.

Fourth, install and set up PHP environment

apt-get install php5 php-pear

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

max_execution_time = 30memory_limit = 128Merror_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERRORdisplay_errors = Offlog_errors = Onerror_log = /var/log/php.logregister_globals = Offmax_input_time = 30

We also need to create a log directory and set permissions

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

If we need PHP support for MySQL, then we must install the PHP5 MySQL package with the following command:

apt-get install php5-mysql

Start apache

service apache2 restart

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

PS: If Snail installed WORDPRESS successfully, the only thing you need to pay attention to is that the root directory permissions need to be writable. htaccess or manually create a pseudo-static file, so that the fixed connection setting in the background will not take effect.

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

Recommended site search: foreign free all-purpose space, virtual host, website ICP filing, 6 yuan per year cloud server, online IP check, station group server Rental, domain name registration number query, domain name registration official website, website query domain name, monthly payment space,

Complete Debian7 configuration LAMP (Apache/MySQL/PHP) environment and build website

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码