How to Build a LAMP Stack on CentOS 7 and Deploy WordPress
This guide walks through installing the LAMP stack (Linux, Apache, MySQL/MariaDB, PHP) on CentOS 7, explains HTTP request processing for static and dynamic resources, and then shows step‑by‑step deployment of WordPress and phpMyAdmin, including common pitfalls and fixes.
Introduction
The LAMP stack—Linux, Apache, MySQL/MariaDB, and PHP—is a classic “golden combination” for web development. Linux has many distributions; the three major families are Debian, Red Hat, and Slackware. Apache HTTP Server is the world’s most widely used web server, extensible via modules to embed interpreters such as PHP, Perl, or Python. PHP is a leading scripting language for web applications, while Python is a powerful high‑level language.
MySQL, now owned by Oracle, is a commercial database that requires a license for many features. MariaDB was created by the original MySQL developers to provide a fully open‑source alternative.
HTTP Request Flow
1. A single HTTP transaction consists of a client request and a server response.
2. Static resource request – The client request reaches the kernel’s network stack, which forwards it via the listening socket to the httpd process. The httpd process asks the kernel to read the file from disk; if found, the kernel returns the data, the process builds the HTTP response headers, and the response is sent back through the kernel to the client. During the kernel‑process hand‑off the process is blocked.
To avoid this blocking, asynchronous I/O (AIO) can be used. The sendfile mechanism allows the kernel to attach HTTP headers and transmit the file directly, eliminating a round‑trip through user space and improving efficiency.
3. Dynamic resource request – After loading a script from disk, the httpd process hands it to PHP. PHP may query a database (MySQL/MariaDB) and then returns the generated output to the httpd process.
PHP can be integrated with httpd in three ways:
Compiled as an Apache module (mod_php)
Via CGI
Via FastCGI
The data flow is roughly:
Client → HTTP → httpd → libphp5.so → MySQL → MySQL serverSetting Up LAMP on CentOS 7
1. System environment
OS: CentOS 7
IP: 192.168.1.109
Firewall: disabled
SELinux: disabled2. Install LAMP components
yum install -y httpd php-fpm php-mysql mariadb-server3. Start and enable MariaDB
systemctl start mariadb.service
systemctl enable mariadb.service4. Test database access
mysql
GRANT ALL PRIVILEGES ON testdb.* TO gwx@'192.168.%.%' IDENTIFIED BY '1';Deploying WordPress
1. Download WordPress
wget -O /www/b.net/htdocs/wordpress.zip https://cn.wordpress.org/wordpress-4.4.2-zh_CN.zip2. Unpack and configure
unzip wordpress.zip
cd wordpress
cp wp-config-sample.php wp-config.php
CREATE DATABASE wpdb;
GRANT ALL ON wpdb.* TO 'wpuser'@'%' IDENTIFIED BY 'passwd';
vim wp-config.php # edit database credentials
service httpd restart3. Test – Open http://www.b.net/wordpress in a browser.
Setting Up phpMyAdmin
1. Download and extract
wget -O /www/c.org/htdocs/phpadmin.zip https://files.phpmyadmin.net/phpMyAdmin/4.6.5.2/phpMyAdmin-4.6.5.2-all-languages.zip
unzip phpadmin.zip
ln -sv phpMyAdmin-4.6.5.2-all-languages/ pma
cd pma
cp config.sample.inc.php config.inc.php
openssl rand -base64 15 # generate secretInitial tests showed the installed PHP version was too low; a lower phpMyAdmin version was downloaded and the missing php-mbstring package was installed:
yum install php-mbstring
systemctl restart httpdAfter these steps phpMyAdmin worked correctly.
Key Tips
Ensure the MySQL grant statement matches the credentials in wp-config.php and that the database exists before testing WordPress.
Author
Author: yezi Source: http://www.178linux.com/63490
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
