Faster, Higher, Stronger


LAMP is short for Linux, Apache, MySQL, PHP. Of course, you already have a Linux OS (CentOS), so  this article mainly introduces installation of Apache, MySQL and PHP. I need this environment because I use WordPress program which should run on basis of this environment.

Install Apache
# update software
yum update

# install Apache
yum install httpd

# start Apache
systemctl start httpd.service

# set apache to start on server boot
systemctl enable httpd.service

To verify the installation of Apache, open “http://your server’s IP address”, and if Apache was successfully installed, you should see an Apache Text Page.

Install MySQL
# install MariaDB, which is a community-developed fork of MySQL:
yum install mariadb-server mariadb

# start the service
systemctl start mariadb

# set MySQL to start on server boot
systemctl enable mariadb.service

# run this command to finish setting up the installation

You will be asked for the root password, because you didn’t set it earlier. Press Enter to set a password now.

Set root password and confirm the new password (this password is the password for your MySQL root account).

You will then be asked a series of questions as part of the security configuration. It’s a best practice to respond “Y” to these system prompts.

Install PHP
# install PHP
yum install php php-mysql

# restart Apache
systemctl restart httpd.service

Install PHP modules

If your applications requires any PHP modules, you can install them now.

# view available PHP modules
yum search php-

# to view the description of a specific package, use the following command:
yum info "the name of the package you want to use"(quotes not required)

# install the package you desire
yum install "the name of the package you desire"(quotes not required)

Test PHP processing on Apache

Firstly, create a new PHP file under the /var/www/html directory:

vi /var/www/html/info.php

Then, type in the following code to info.php:


Then, save and close the file:


Lastly, open the url in your browser: “http://your server’s IP address/info.php”. You should see a page displaying information such as the PHP version, extensions, build date and etc., if PHP is successfully installed.

  • Build a LAMP stack (Linux, Apache, MySQL, PHP) – CentOS 7:
赞(0) 打赏
未经允许不得转载:峰间的云 » CentOS7安装LAMP环境

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址