centos7⽤yum搭建LAMP环境更新PHP版本
⽤yum快速搭建LAMP平台
实验环境:
# cat /etc/redhat-release
CentOS release 7.3.1611 (AltArch)
# uname -a
st 3.10.s.plus.i686 #1 SMP Wed Jan 25 12:55:04 UTC 2017 i686 i686 i386 GNU/Linux 1. 安装apache
1.1 安装apache
# yum install httpd httpd-devel
1.2 启动apache服务
# systemctl start httpd
1.3 设置httpd服务开机启动
# systemctl enable httpd
Created symlink from/etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
1.4 查看服务状态
# systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since 五 2017-07-21 17:21:37 CST; 6min ago
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 2449 (httpd)
Status: "Total requests: 11; Current requests/sec: 0; Current traffic: 0 B/sec"
CGroup: /system.slice/httpd.service
├─2449 /usr/sbin/httpd -DFOREGROUND
├─2450 /usr/sbin/httpd -DFOREGROUND
├─2451 /usr/sbin/httpd -DFOREGROUND
├─2452 /usr/sbin/httpd -DFOREGROUND
├─2453 /usr/sbin/httpd -DFOREGROUND
├─2454 /usr/sbin/httpd -DFOREGROUND
├─2493 /usr/sbin/httpd -DFOREGROUND
├─2494 /usr/sbin/httpd -DFOREGROUND
└─2495 /usr/sbin/httpd -DFOREGROUND
7⽉ 21 17:21:st systemd[1]: Starting The Apache
7⽉ 21 17:21:st httpd[2449]: AH00558: httpd: Could not reliably determine the server's ssage
7⽉ 21 17:21:st systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
1.5 防⽕墙设置开启80端⼝
# firewall-cmd --permanent --zone=public --add-service=http
success
# firewall-cmd --permanent --zone=public --add-service=https
success
# firewall-cmd --reload
success
1.6确认80端⼝监听中
# netstat -tulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN 1084/sshd
tcp 0 0 localhost:smtp 0.0.0.0:* LISTEN 1486/master
tcp6 0 0 [::]:ssh [::]:* LISTEN 1084/sshd
tcp6 0 0 localhost:smtp [::]:* LISTEN 1486/master
php项目搭建tcp6 0 0 [::]:http [::]:* LISTEN 2449/httpd
udp 0 0 localhost:323 0.0.0.0:* 592/chronyd
udp6 0 0 localhost:323 [::]:* 592/chronyd
1.7 查服务器IP
# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:56:bc:cf brd ff:ff:ff:ff:ff:ff
inet 192.168.8.9/24 brd 192.168.8.255 scope global ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe56:bccf/64 scope link
valid_lft forever preferred_lft forever
3: bridge0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN qlen 1000 link/ether ea:89:d5:c7:32:73 brd ff:ff:ff:ff:ff:ff
1.8 浏览器登陆
1.9 测试php
2、安装mysql
2.1安装mysql
# yum install mariadb mariadb-server mariadb-libs mariadb-devel
root@nmserver-7 ~]# rpm -qa |grep maria
mariadb-libs-5.5.52-1.el7.i686
mariadb-5.5.52-1.el7.i686
mariadb-server-5.5.52-1.el7.i686
mariadb-devel-5.5.52-1.el7.i686
2.2 开启mysql服务,并设置开机启动,检查mysql状态
# systemctl start mariadb
# systemctl enable mariadb
Created symlink from/etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
# systemctl status mariadb
● mariadb.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Active: active (running) since 六 2017-07-22 21:19:20 CST; 21s ago
Main PID: 9603 (mysqld_safe)
CGroup: /system.slice/mariadb.service
├─9603 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
└─9760 /usr/libexec/mysqld --basedir=/usr --datadir=/v...
7⽉ 22 21:19:st mariadb-prepare-db-dir[9524]: ...
7⽉ 22 21:19:st mariadb-prepare-db-dir[9524]: ...
7⽉ 22 21:19:st mariadb-prepare-db-dir[9524]: ...
7⽉ 22 21:19:st mariadb-prepare-db-dir[9524]: ...
7⽉ 22 21:19:st mariadb-prepare-db-dir[9524]: ...
7⽉ 22 21:19:st mariadb-prepare-db-dir[9524]: ...
7⽉ 22 21:19:st mariadb-prepare-db-dir[9524]: ...
7⽉ 22 21:19:st mysqld_safe[9603]:
7⽉ 22 21:19:st mysqld_safe[9603]:
7⽉ 22 21:19:st systemd[1]: Started MariaDB ...
# netstat -tulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN 1084/sshd
tcp 0 0 0.0.0.0:mysql 0.0.0.0:* LISTEN 9760/mysqld
tcp6 0 0 [::]:ssh [::]:* LISTEN 1084/sshd
tcp6 0 0 [::]:http [::]:* LISTEN 2449/httpd
udp 0 0 localhost:323 0.0.0.0:* 592/chronyd
udp6 0 0 localhost:323 [::]:* 592/chronyd
2.3 数据库安全设置
# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password,
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] n
... skipping.
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
- Dropping
... Success!
- Removing privileges on
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
... Success!
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
2.4 登陆数据库测试
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论