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

Build lamp by CentOS7 yum

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Easy to build lamp

Environment description:

Server:CentOS7-192.168.230.202

Client: win8.1-192.168.230.59

Apache/2.4.6

Php Version 5.4.16

5.5.52-MariaDB

Yum group install Development Tools

# install development tools, GCC...

Yum install httpd mariadb mariadb-server php 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-y

# install apache mariadb php and various runtime libraries and tools

Service httpd start start

Local curl is OK.

Unable to communicate with 80 on other clients

The reason is so simple.

Selinux and firewalld

Setenforce 0

# turn off selinux

Systemctl stop firewalld

# turn off the firewall

Add on the client-side local hosts

192.168.230.202 www.rex.com

Vi / etc/httpd/conf/httpd.conf # editing

Find # ServerName www.example.com:80

Change to ServerName www.rex.com:80

find

#

DirectoryIndex index.php index.html

Add index.php

You can now add web pages to the working directory

The path is / var/www/html

[root@localhost ~] # vim / var/www/html/index.php [root@localhost ~] # cat / var/www/html/index.php

Systemctl restart httpd

# reload will report an error Empty reply from server

After refreshing, the version and details of php will be displayed.

Mysql

Many tutorials on the Internet use mysql

Due to the problem with the version, mariadb with open source protocol is still used in the same way as mysql.

The above yum has been installed at one time.

Cp / usr/share/mysql/my-huge.cnf / etc/my.cnf # copy the configuration file (Note: if there is a my.cnf by default under the / etc directory, you can overwrite it directly)

There is a difference between the two files.

Service mariadb start## asked me to start the service Redirecting to / bin/systemctl start mariadb.service [root@localhost ~] # mysqladmin-u root password## to change the root password of mysql. Of course, you can use New password: rexConfirm new password: rex

In the simple configuration of MySQL seen in a post, we mainly use encryption and authorization.

Mysqladmin-u root passwordgrant all privileges on *. * to 'root'@'192.168.230.%';#% refers to the * character of shell, which represents all users who enter the MySQL management backend with a root account. It prompts you to enter a password: [root@localhost ~] # mysql-u root-p to create a local user: mysql > create user' user name'@ 'localhost' identified by' password'; create a new database: mysql > create database database name Limit the ownership of the specified database to the specified user: mysql > grant all privileges on database name. * to 'user name' @ 'localhost'; refresh the system permission table: mysql > flush privileges; enter the mysql database (included with the system) and query whether the specified user exists (if there is a bunch of things, it means it exists): mysql > use mysql;mysql > select * user =' user name' If you want to delete a local user, use: mysql > drop user 'username' @ 'localhost'; if you want to delete the database, use: mysql > drop database database name; view the existing database: mysql > show databases; exit MySQL management backend: mysql > exit

[root@localhost] # mysql-uroot-pEnter password: Welcome to the MariaDB monitor. Commands end with; or\ g.Your MariaDB connection id is 9Server version: 5.5.52-MariaDB MariaDB ServerCopyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.MariaDB [(none)] > create user 'rex'@'localhost' identified by' rex'->; # # forgot to add the; sign at the end of the above sentence, so add Query OK until the next line, 0 rows affected (0.02 sec) # # successful feedback MariaDB [(none)] > create database rexhome # # create rexhome database Query OK, 1 row affected (0.00 sec) MariaDB [(none)] > grant all privileges on *. * to 'rex' @' localhost';ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'localhost'' at line 1 error # error message MariaDB [(none)] > grant all privileges on rexhome.* to' rex' @ 'localhost';ERROR 1064 (42000): You have an error in your SQL syntax Check the manual that corresponds to your MariaDB server version for the right syntax to use near''localhost'' at line 1room# added database name to test or error MariaDB [(none)] > grant all privileges on rexhome.* to' rex'@'localhost'; # # originally added a space Query OK in 'user'@'host', 0 rows affected (0.02 sec) MariaDB [(none)] > grant all privileges on *. * to' rex'@'localhost' # # Authorization to rex account, permissions for all data and tables Query OK, 0 rows affected (0.00 sec) MariaDB [(none)] > flush privileges; update permission table Query OK, 0 rows affected (0.00 sec)

Test whether the database is connected

Vim / var/www/html/index.php

After testing, the phpinfo.php file should be deleted because the information on this page is quite important.

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

Database

Wechat

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

12
Report