2022年CentOS.系统yum安装配置LAMP .pdf
《2022年CentOS.系统yum安装配置LAMP .pdf》由会员分享,可在线阅读,更多相关《2022年CentOS.系统yum安装配置LAMP .pdf(20页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、CentOS 6.5系统安装配置 LAMP(Apache+PHP5+MySQL)服务器环境一、安装Apache rootcet6 # yum install -y httpd启动服务:rootcet6 # service httpd start正在启动httpd :确定 rootcet6 # 设置开机启动:rootcet6 # chkconfig | grep httpdhttpd 0:关闭1:关闭2:关闭3:关闭4:关闭5:关闭6:关闭rootcet6 # chkconfig httpd onrootcet6 # chkconfig | grep httpdhttpd 0:关闭1:关闭2:启
2、用3:启用4:启用5:启用6:关闭rootcet6 # 查看 80 端口:rootcet6 # netstat -lntp | grep httpdtcp 0 0 :80 :* LISTEN 3294/httpd rootcet6 # 查看 httpd 进程:rootcet6 # ps -aux | grep httpdWarning: bad syntax, perhaps a bogus -? See /usr/share/doc/procps-3.2.8/FAQ root 3294 0.0 0.1 186228 3932 ? Ss 15:57 0:00 /usr/sbin/httpd a
3、pache 3297 0.0 0.1 186364 3092 ? S 15:57 0:00 /usr/sbin/httpd apache 3298 0.0 0.1 186364 3184 ? S 15:57 0:00 /usr/sbin/httpd apache 3299 0.0 0.1 186364 3092 ? S 15:57 0:00 /usr/sbin/httpd apache 3300 0.0 0.1 186364 3116 ? S 15:57 0:00 /usr/sbin/httpd apache 3301 0.0 0.1 186228 2456 ? S 15:57 0:00 /u
4、sr/sbin/httpd apache 3302 0.0 0.1 186228 2456 ? S 15:57 0:00 /usr/sbin/httpd apache 3303 0.0 0.1 186228 2456 ? S 15:57 0:00 /usr/sbin/httpd apache 3304 0.0 0.1 186228 2456 ? S 15:57 0:00 /usr/sbin/httpd root 3445 0.0 0.0 103240 876 pts/1 S+ 16:03 0:00 grep httpd rootcet6 # 浏览器访问:http:/192.168.1.233/
5、 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 1 页,共 20 页 - - - - - - - - - 二、安装MySQL rootcet6 # yum list | grep mysqlrootcet6 # yum install -y mysql mysql-server安装完成后,第一次启动mysql服务进行初始化:rootcet6 # service mysqld start初始化MySQL 数据库:Installing MySQL system tables. OK F
6、illing help tables. OK To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: /usr/bin/mysqladmin -u root password new-passw
7、ord /usr/bin/mysqladmin -u root -h password new-password Alternatively you can run: /usr/bin/mysql_secure_installation which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers. See the manual for mor
8、e instructions. You can start the MySQL daemon with: cd /usr ; /usr/bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl cd /usr/mysql-test ; perl mysql-test-run.pl Please report any problems with the /usr/bin/mysqlbug script! 确定 正在启动mysqld:确定 rootcet6 # 查看 mysql端口:rootcet6 # netst
9、at -lntp | grep mysqldtcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 3673/mysqld rootcet6 # 连接 mysql测试:rootcet6 # mysqlWelcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 2 Server version: 5.1.73 Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All r
10、ights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 2 页,共 20 页 - - - - - - - - - owners. Type help; or h for help. Type c to cle
11、ar the current input statement. mysql 说明:mysql 客户端选项:-u 用户名:指定以哪个用户进行连接。-p :直接回车输入密码。-h mysql 服务器:指定连接服务器ip。-u 不指定默认是以root 登陆。-p 不指定默认为空密码。-h 不指定默认为localhost。设置开机启动:rootcet6 # chkconfig | grep mysqldmysqld 0:关闭1:关闭2:关闭3:关闭4:关闭5:关闭6:关闭rootcet6 # chkconfig mysqld onrootcet6 # chkconfig | grep mysqldmy
12、sqld 0:关闭1:关闭2:启用3:启用4:启用5:启用6:关闭rootcet6 # 复制 mysql主配置文件到/etc 下:rootcet6 mysql# pwd/usr/share/mysql rootcet6 mysql# cp my-f /etc/fcp:是否覆盖 /etc/f ? yrootcet6 mysql# 为 mysql的 root 账户设置密码:可以使用: mysqladmin -u root password 123456设置密码。也可以使用mysql_secure_installation命令:安装完mysql-server 会提示可以 运行mysql_secure
13、_installation。运行mysql_secure_installation 会执行几个设置:a)为 root 用户设置密码b)删除匿名账号c)取消 root 用户远程登录d)删除 test 库和对 test 库的访问权限e)刷新授权表使修改生效通过这几项的设置能够提高mysql 库的安全。 建议生产环境中mysql 安装这完成后一定要运行一次 mysql_secure_installation rootcet6 # mysql_secure_installationNOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL
14、 MySQL SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MySQL to secure it, well need the current 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 3 页,共 20 页 - - - - - - - - - password for the root user. If youve just installed MySQL, an
15、d you havent 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, moving on. Setting the root password ensures that nobody can log into the MySQL root user without the pro
16、per authorisation. Set root password? Y/n y 是否设置root 用户密码,输入y 并回车或直接回车New password: Re-enter new password: Password updated successfully! Reloading privilege tables. . Success! By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user acc
17、ount 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. Thi
18、s ensures that someone cannot guess at the root password from the network. Disallow root login remotely? Y/n n 是否禁止root 远程登录. skipping. By default, MySQL 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 produc
19、tion environment. Remove test database and access to it? Y/n n 是否删除 test 数据库. skipping. Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? Y/n y 是否重新加载权限表. Success! Cleaning up. All done! If youve completed all of the ab
20、ove steps, your MySQL installation should now be secure. Thanks for using MySQL! rootcet6 # 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 4 页,共 20 页 - - - - - - - - - 三、安装PHP5 rootcet6 # yum install -y php安装 PHP组件,使PHP5 支持MySQL:yum install php-mysql php-gd libjpeg*
21、php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt 或者都装上:rootcet6 # yum list | grep phprootcet6 # yum install -y php*重新启动httpd 服务和 mysql服务:rootcet6 # service httpd restart停止httpd :确定 正在启动httpd :确定 rootcet6 # service mysqld restart停止mysqld:确定
22、 正在启动mysqld:确定 rootcet6 # 提供 php 脚本测试:rootcet6 html# pwd/var/www/html rootcet6 html# vim index.php index.php 新 3L, 20C 已写入rootcet6 html# 可在 httpd 配置文件中DirectoryIndex 项增加 index.php。提供 php 脚本连接mysql数据库:查看是否能够连接mysql:rootcet6 html# pwd/var/www/html rootcet6 html# vim index.php rootcet6 html# 连接 mysql 成
23、功网页会显示OK!名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 5 页,共 20 页 - - - - - - - - - 安装 phpMyAdmin图形化数据库:软件包版本:rootcet6 bao# ll总用量9836 -rwxrw-rw-. 1 root root 8074883 4 月17 17:27 phpMyAdmin-4.0.10.9-all-languages.tar.gz rootcet6 bao# 解压缩:rootcet6 bao# tar xf phpMyAdm
24、in-4.0.10.9-all-languages.tar.gz复制解压的包到网页目录下:rootcet6 bao# cp -r phpMyAdmin-4.0.10.9-all-languages /var/www/html/pma 浏览器登陆:http:/192.168.1.233/pma/ 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 6 页,共 20 页 - - - - - - - - - 安装完 lamp后,建议相关配置,提高安全性和性能:一、 Apache配置vi /et
25、c/httpd/conf/httpd.conf #编辑文件ServerTokens OS#在 44 行 修改为: ServerTokens Prod (在出现错误页的时候不显示服务器操作系统的名称)ServerSignature On#在 536 行 修改为: ServerSignature Off (在错误页中不显示Apache的版本)Options Indexes FollowSymLinks# 在331行修 改 为 : Options Includes ExecCGI FollowSymLinks(允许服务器执行CGI 及 SSI ,禁止列出目录)#AddHandler cgi-scri
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 2022年CentOS.系统yum安装配置LAMP 2022 CentOS 系统 yum 安装 配置 LAMP
限制150内