CentOS uses local yum source to build LAMP environment graphic tutorial

CentOS uses local yum source to build LAMP environment graphic tutorial

This article describes how to use the local yum source to build a LAMP environment on CentOS. Share with you for your reference, the details are as follows:

【Preparation】

Configure the firewall and open port 80 and port 3306

vi /etc/sysconfig/iptables

As shown in the figure, add the following two items:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT #Allow port 80 to pass through the firewall -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT #Allow port 3306 to pass through the firewall

Restart the firewall to make the configuration take effect

/etc/init.d/iptables restart

Turn off SELINUX

vi /etc/selinux/config

#SELINUX=enforcing #Comment out #SELINUXTYPE=targeted #Comment out SELINUX=disabled #Add :wq! #Save and exit

Restart the system

shutdown -r now

Install Apache

Perform the installation

yum -y install httpd

Start Apache

service httpd restart

or:

/etc/init.d/httpd start

After Apache is started , an error message will pop up: Could not reliably determine the server's fully qualifdomain name, using ::1 for ServerName . Solution:

vi /etc/httpd/conf/httpd.conf

Find #ServerName www.example.com:80
Change to ServerName www.lws.com:80 (set to your own domain name or ServerName localhost:80 )
:wq!#Save and exit

Set to start at startup

chkconfig httpd on

Check the installation access host address as shown in the figure. The installation is successful

Modify Apache configuration

vi /etc/httpd/conf/httpd.conf #It is recommended to use ftp tool to make a backup before modifying

Modify as follows:

ServerTokens OS #Change line 44 to: ServerTokens Prod (Do not display the name of the server operating system when an error page appears)
ServerSignature On #Change line 536 to: ServerSignature Off (do not display the Apache version on the error page)
Options Indexes FollowSymLinks #Change line 331 to: Options Includes ExecCGI FollowSymLinks (allow the server to execute CGI and SSI, and prohibit directory listing)
#AddHandler cgi-script .cgi #Change line 796 to: AddHandler cgi-script .cgi .pl (allows CGI scripts with the extension .pl to run)
AllowOverride None #Change line 338 to: AllowOverride All (allow .htaccess)
AddDefaultCharset UTF-8 #Change line 759 to: AddDefaultCharset GB2312 (add GB2312 as the default encoding)
Options Indexes MultiViews FollowSymLinks #Change line 554 to Options MultiViews FollowSymLinks (do not display the tree directory structure on the browser)
DirectoryIndex index.html index.html.var #Change in line 402 to: DirectoryIndexindex.html index.htm Default.html Default.htm index.php Default.phpindex.html.var (set the default homepage file and add index.php)
KeepAlive Off #Change line 76 to: KeepAlive On (allow programmatic connection)
MaxKeepAliveRequests 100 #Change line 83 to: MaxKeepAliveRequests1000 (increase the number of simultaneous connections)

Delete the two default test pages

rm -f /etc/httpd/conf.d/welcome.conf /var/www/error/noindex.html

Restart Apache

service httpd restart

or

/etc/init.d/httpd restart

Installing MySQL

Perform the installation

yum -y install mysql mysql-server

Start MySQL

/etc/init.d/mysqld start

Set to start at startup

chkconfig mysqld on

Copy the configuration file (Note: If there is a my.cnf file in the /etc directory by default, just overwrite it)

cp /usr/share/mysql/my-medium.cnf /etc/my.cnf

Set a password for the root account

mysql_secure_installation
#Press Enter, enter Y as prompted, enter the password twice, press Enter, and enter Y as prompted. Finally, it will appear: Thanks for using MySQL. Setup completed

or

mysqladmin -u root password 'password'

Allow remote login

mysql -u root -p

Enter the password and enter the mysql command:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;

Exit mysql: exit

Restart MySQL

service mysqld restart

Installing PHP5

Perform the installation

yum -y install php

Install PHP components (select the following installation package here, enter Y and press Enter to install)

Copy the code as follows:
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

Modify PHP configuration

vi /etc/php.ini #It is recommended to use ftp tool to make a backup before modification

Modify as follows:

date.timezone = PRC #Remove the semicolon in line 946 and change it to date.timezone = PRC

Copy the code as follows:
: : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :

expose_php = Off #Disable the display of PHP version information in line 432
magic_quotes_gpc = On #Turn on magic_quotes_gpc in line 745 to prevent SQL injection
short_open_tag = On #Support PHP short tags in line 229
open_basedir = .:/tmp/
#Setting in line 380 allows access to the current directory (the directory where the PHP script file is located) and the /tmp/ directory, which can prevent PHP Trojans from crossing sites. If there is a problem with the installation program after the change, you can cancel this line, or directly write the program directory /data/www.osyunwei.com/:/tmp/

Restart MySQL and Apache

service mysqld restart
service httpd restart

(This completes the construction of the LAMP environment with the yum source. We can check the installed versions of each part)

Check Apache version

httpd -v

Check PHP version

php –v

Check MySQL version

mysql -V

(Note the capitalization)

I hope this article will help you configure 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
  • How to quickly build a LAMP environment on CentOS platform
  • 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

<<:  TypeScript generic parameter default types and new strict compilation option

>>:  A quick solution to the problem that there is no data directory and my-default.ini in the unzipped package of Windows 64-bit MySQL 5.7 or above, and the service cannot be started (problem summary)

Recommend

How to install and configure mysql 5.7.19 under centos6.5

The detailed steps for installing mysql5.7.19 on ...

MySQL and MySQL Workbench Installation Tutorial under Ubuntu

Ubuntu install jdk: [link] Install Eclipse on Ubu...

HTML table markup tutorial (10): cell padding attribute CELLPADDING

Cell padding is the distance between the cell con...

How to use JavaScript to get the most repeated characters in a string

Table of contents topic analyze Objects of use So...

How to write the introduction content of the About page of the website

All websites, whether official, e-commerce, socia...

How to forget the password of Jenkins in Linux

1.Jenkins installation steps: https://www.jb51.ne...

Vue implements upload component

Table of contents 1. Introduction 2. Ideas Two wa...

Example code for implementing 3D text hover effect using CSS3

This article introduces the sample code of CSS3 t...

Detailed explanation of nginx configuration file interpretation

The nginx configuration file is mainly divided in...

MySQL database SELECT query expression analysis

A large part of data management is searching, and...

Introduction to the usage of common XHTML tags

There are many tags in XHTML, but only a few are ...

MySQL data aggregation and grouping

We often need to summarize data without actually ...

Detailed explanation of the use of CSS3 rgb and rgba (transparent color)

I believe everyone is very sensitive to colors. C...