Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build a LAMP environment for centos7.2

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to build a LAMP environment with centos7.2". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to build a LAMP environment with centos7.2".

Installation of apache, php and mysql

1. Install php

Step by step installation:

Download php

Decompress: tar-zxvf mirror

Install gcc:yum install-y gcc gcc+ libxml2-devel

Compile:. / configure-- prefix=/usr/local/php7-- enable-fpm

There is also a relatively simple way to install yum (online installation, convenient and easy):

Yum install-y php waits for installation to complete

Then enter the following command to install the php component:

Yum install-y 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

To test whether php is installed properly, enter php echo "xxx". If could not open input file echo is displayed, the installation is successful, or you can write a php file to execute it.

two。 Install apache

Server networking is required

Installation: yum install-y httpd

Run: / bin/systemctl start httpd.service

After executing the run command, you will not see the effect. Enter the command to check the status of the apache service to see if the service has been started:

View status: service httpd status

Apache enables service: systemctl start httpd

Apache out of service: systemctl stop httpd

To test whether the apache service is enabled properly, enter the public network ip of the CVM in our local browser. Let me take 118.89.32.6 as an example.

As shown above, apache is enabled normally.

3. Install mysql

Wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

Rpm-ivh mysql-community-release-el7-5.noarch.rpm

Yum install mysql-community-server

Restart the mysql service after successful installation

Service mysqld restart

When mysql is installed for the first time, the root account has no password.

How to set the password:

Enter mysql-uroot to enter the mysql database

Mysql > set password for 'root'@'localhost' = password (' mypasswd')

Mysql > exit

Remote Authorization connection mysql

Mysql > grant all privileges on *. * to 'root'@'%' identified by' the database password you want to set 'with grant option

Mysql > flush privileges

Notes:

1.rpm: rpm package manager (rpm package Manager), a packaging and installation tool for downloading packages from the Internet, which is included in some linux distributions. It generates a file with the .rpm extension. Similar to dpkg.

Corresponding command:

In terminal, the basic installation instructions are as follows:

Rpm-I xv-3.10a-13.i386.rpm

If you are fast enough to connect to the Internet, you can also install the application directly from the network, just add the appropriate url path to the file name of the software.

As a software package management tool, rpm manages the information of all rpm program components installed in the system. We can also use rpm to uninstall related applications.

Rpm-e xv

Other common parameters of rpm include:

-vh: displays the installation progress

-u: upgrade package

-qpl: lists the file information in the rpm package

-qpi: lists the description of the rpm software package

-qf: finds which rpm package the specified file belongs to

-va: check all rpm packages to find missing files

-qa: find the appropriate file, such as rpm-qa mysql

2.yum: yum (yellow dog updater, modified) is a shell front-end package manager in fedora and redhat as well as in centos. Based on rpm package management, rpm packages can be downloaded and installed automatically from designated servers, dependencies can be automatically dealt with, and all dependent software packages can be installed at one time without tedious downloading and installation.

Corresponding command:

Install software (take foo-x.x.x.rpm as an example): yum install foo-x.x.x.rpm

Delete software: yum remove foo-x.x.x.rpm or yum erase foo-x.x.x.rpm

Upgrade software: yum upgrade foo or yum update fo

Query information: yum info foo

Search software (take including foo field as an example): yum search foo

Show package dependencies: yum deplist foo

-e silent execution

-t ignore errors

-r [minutes] set waiting time

-y Auto answer yes

-- skip-broken ignores dependency issues

-- nogpgcheck ignores gpg authentication

Check-update checks for updatable packages

Clearn clears all

Clean packages clears temporary package files (files under / var/cache/yum)

Clearn headers clears the rpm header file

Clean oldheaders clears old rpm header files

Deplist lists package dependencies

List installable and updatable rpm package

List installed installed packages

Packages with list extras installed and not in the repository

Info installable and updatable rpm package information

Information about info installed installed packages (the-qa parameter is similar)

Install [RPM package] installation package

Localinstall installs the local rpm package

Update [RPM package] update package

Upgrade upgrade system

Search [keywords] search package

Provides [keyword] search for specific package file names

Reinstall [RPM package] reinstall package

Repolist displays the configuration of the repository

Resolvedep specifies dependencies

Remove [RPM package] uninstall package

3.wget:

Wget is a free tool for automatically downloading files from the Internet. It supports downloading through the three most common tcp/ip protocols, http, https, and ftp, and can use the http proxy. The name "wget" comes from the combination of "world wide web" and "get".

The so-called automatic download means that wget can continue to execute in the background after the user exits the system until the download task is completed.

If the above two lines of commands are executed successfully and complete is displayed, you can use things like navicat to manage the mysql database

2. Configure apache and php

2.1 configure apache

Use the httpd-v command to view the directory where the apache configuration file httpd.conf file is located:

As shown in the red circle, the apache configuration file is in the etc/httpd/conf/ directory

Enter the directory, cd / etc/httpd/conf

What to modify:

1. Add # load php processing module

How to add suffixes such as php to loadmodule php5_module modules/libphp5.so#

Addtype application/x-httpd-php .php

2. Modification

Directoryindex index.html

Change to

Directoryindex index.php index.html

3. Modify the default access path

Documentroot = "/ var/www"

For convenience, all subsequent directory has been changed to / var/www

After modifying all the configurations, click the ESC key and press and hold shift+; to enter the bottom line mode, and type wq to save and exit.

2.2 configure php.ini

1. Enter the php-- ini command to view the path of the php.ini file: it is no longer pictured above, too motor.

2. Find the place with the most extension, and remove the previous one to make php support mysql, and specify the value of-- with-mysql when configuring. If it is not configured before installation, you need to reconfigure, compile, and install.

; extension=php_mysql.dll

To open it using the phpmyadmin or mysqli function, and specify the value of-- with-mysqli during configuration. If it was not configured before, you need to reconfigure, compile, install.

; extension=php_mysqli.dll

If you want php to support png,jpg,gif, etc. (phpcmsv9 must) open

; extension=php_gd2.dll

Large character set, support for conversion between multiple character sets on

; extension=php_mbstring.dll

The difference between php5 default time and Beijing time is eight hours (less than eight hours)

Why? the php5 series version adds a new time zone setting, which defaults to Greenwich mean time, which is exactly 8 hours different from the East 8 District in China.

; date.timezone =

Remove and modify to date.timezone = prc

Except for e_notice type errors (notice) are not reported, everything else is reported, look for error_reporting = e_all

Change it to error_reporting = e_all & ~ e_notice

3. Find extension_dir

Remove the previous semicolon and change it to extension_dir = "your php installation directory / ext"

View the php installation directory:

4. Enter rpm-ql php in linux to view the php installation directory:

Restart apache after modifying all the configurations:

Systemctl stop httpd

Systemctl start httpd

Or:

Systemctl restart httpd

3. One-click installation: (convenient and convenient ^ _ ^)

You need to install the package with one click. I am using the installation package provided by Aliyun:

Open xshell and enter the xftp interface: drag the local installation package to the remote server root directory:

Switch to the xshell window and go to the root directory: cd / root

Type the following command to install:

Chmod-r 777 sh-1.5.5

Cd sh-1.5.5

. / install.sh

The remaining configuration steps are the same as above, and the details are as follows:

After that, you can upload your project to the root of the site through xftp.

At this point, I believe you have a deeper understanding of "how to build a LAMP environment in centos7.2". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report