How to quickly build a LAMP environment on CentOS platform

How to quickly build a LAMP environment on CentOS platform

This article uses an example to describe how to quickly build a LAMP environment on the CentOS platform. Share with you for your reference, the details are as follows:

LAMP -- Linux Apache MySQL PHP

The order of installation on CentOS is usually Apache -> MySQL -> PHP

Step 1: Install and configure Apache

1. Install using yum

yum install httpd

2. Modify the firewall configuration and open port 80. You can also open port 3306 of MySQL.

vi /etc/sysconfig/iptables

Add two records

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

Note the location of the addition, as shown below

3. Turn off SELINUX

vi /etc/selinux/config

Modify SELINUX=disabled

4. Apache configuration file

vi /etc/httpd/conf/httpd.conf

Find ServerName and set it to your own domain name. If you don’t have a domain name, you can set it to localhost:80

5. Automatically start Apache at boot

chkconfig httpd on

6. Restart Apache

service httpd restart

7. Open the browser and enter the address test

Step 2: Install and configure MySQL

1. Install using yum

yum install mysql mysql-server

2. Automatically start MySQL at boot

chkconfig mysqld on

3. Set the root password for MySQL

mysql_secure_installation

After pressing Enter, enter y to set the password. After setting the password, press Enter all the way until the following message appears: Thanks for using MySQL!

4. Restart MySQL

service mysqld restart

Step 3: Install and configure PHP

1. Install using yum

yum install php

2. Install PHP components

yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt

3. Restart Apache and MySQL

4. You can upload PHP files for testing in the default code directory, the default directory is /var/www/html . The path can be modified in the httpd.conf file.

*Then, you can configure Apache MySQL PHP according to your specific needs. The default configuration file path is as follows:

Apache configuration file path: /etc/httpd/conf/httpd.conf
MySQL configuration file path: /etc/my.cnf
PHP configuration file path: /etc/php.ini

I hope this article will help you maintain your CentOS server.

You may also be interested in:
  • CentOS 5.5 uses yum to install LAMP (php operating environment)
  • Detailed explanation of installing LAMP and phpMyadmin using yum in CentOS 6.2
  • Install lamp environment with yum on Centos7.2 system
  • centos6.5 lamp environment (using yum installation method)
  • Detailed explanation of Linux centos yum installation LAMP environment
  • Tutorial on installing lamp-php7.0 in Centos7.4 environment
  • Specific operation method of building LAMP environment in centos7.2
  • CentOS 7.0 Lnmp and Lamp detailed introduction
  • CentOS 6.6 installation and configuration of LAMP server (Apache+PHP5+MySQL)
  • CentOS 6.3 Compile and Install LAMP Environment Notes
  • CentOS uses local yum source to build LAMP environment graphic tutorial

<<:  More Features of the JavaScript Console

>>:  How to make full use of multi-core CPU in node.js

Recommend

Detailed discussion of several methods for deduplicating JavaScript arrays

Table of contents 1. Set Deduplication 2. Double ...

In-depth analysis of the Linux kernel macro container_of

1. As mentioned above I saw this macro when I was...

Vue implements adding watermark effect to the page

Recently, when I was working on a project, I was ...

Solve the problem of IDEA configuring tomcat startup error

The following two errors were encountered when co...

Linux file system operation implementation

This reading note mainly records the operations r...

CSS sets the list style and creates the navigation menu implementation code

1. Set the list symbol list-style-type: attribute...

JavaScript implements H5 gold coin function (example code)

Today I made a Spring Festival gold coin red enve...

Docker Compose one-click ELK deployment method implementation

Install Filebeat has completely replaced Logstash...

How to implement rounded corners with CSS3 using JS

I found an example when I was looking for a way t...

How to remove spaces or specified characters in a string in Shell

There are many methods on the Internet that, alth...

Getting Started Guide to Converting Vue to React

Table of contents design Component Communication ...

MySQL slow query method and example

1. Introduction By enabling the slow query log, M...

7 skills that great graphic designers need to master

1》Be good at web design 2》Know how to design web p...