立诚勿怠,格物致知
It's all about connecting the dots

CentOS7安装LAMP环境

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
mysql_secure_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:

<?php
phpinfo();
?>

Then, save and close the file:

:wq!

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.

Reference:
  • Build a LAMP stack (Linux, Apache, MySQL, PHP) – CentOS 7: https://hk.godaddy.com/help/build-a-lamp-stack-linux-apache-mysql-php-centos-7-17344
赞(0) 打赏
文章名称:《CentOS7安装LAMP环境》
文章链接:https://www.orzzone.com/instal-lamp-centos7.html
商业联系:yakima.public@gmail.com

本站大部分文章为原创或编译而来,对于本站版权文章,未经许可不得用于商业目的,非商业性转载请以链接形式标注原文出处。
本站内容仅供个人学习交流,不做为任何投资、建议的参考依据,因此产生的问题需自行承担。

评论 抢沙发

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续给力提供更多优质内容!

支付宝扫一扫打赏

微信扫一扫打赏

登录

找回密码

注册