第二步:打开VMware中的CentOS 7虚拟机,查看共享文件夹并进行挂载 [root@localhost ~]# smbclient -L //192.168.10.13/ //此处输入自己宿主机的IP地址 Enter SAMBA/root's password: //此处直接回车 OS=[Windows 10 Home China 18362] Server=[Windows 10 Home China 6.3] Sharename Type Comment --------- ---- ------- ADMIN$ Disk 远程管理 C$ Disk 默认共享 D$ Disk 默认共享 IPC$ IPC 远程 IPC LAMP-test Disk //此处可以看到共享出来的文件夹 Connection to 192.168.0.103 failed (Error NT_STATUS_RESOURCE_NAME_NOT_FOUND) NetBIOS over TCP disabled -- no workgroup available [root@localhost ~]# ls /mnt/ //此时我们查看挂载是空的 [root@localhost ~]# mount.cifs //192.168.0.103/LAMP-test /mnt/ //把共享的文件挂载到mnt目录下 Password for root@//192.168.0.103/LAMP-test: //此处直接回车 [root@localhost ~]# cd /mnt/ //进入mnt目录 [root@localhost mnt]# ls //此时查看详情就可以看到所有我们需要用到的压缩包了 apr-1.6.2.tar.gz Discuz_X2.5_SC_UTF8.zip mysql-5.6.26.tar.gz apr-util-1.6.0.tar.gz httpd-2.4.29.tar.bz2 php-5.6.11.tar.bz2 第三步:安装Apache [root@localhost mnt]# yum install -y gcc gcc-c++ make pcre-devel expat-devel perl //安装必要组件 [root@localhost mnt]# tar zxvf apr-1.6.2.tar.gz -C /opt/ [root@localhost mnt]# tar zxvf apr-util-1.6.0.tar.gz -C /opt/ [root@localhost mnt]# tar jxvf httpd-2.4.29.tar.bz2 -C /opt/ //解压缩以上文件到opt目录下 [root@localhost mnt]# cd /opt/ [root@localhost opt]# ls apr-1.6.2 apr-util-1.6.0 dis httpd-2.4.29 rh [root@localhost opt]# mv apr-1.6.2/ httpd-2.4.29/srclib/apr [root@localhost opt]# mv apr-util-1.6.0/ httpd-2.4.29/srclib/apr-util [root@localhost opt]# cd /opt/httpd-2.4.29/ [root@localhost httpd-2.4.29]# ls ABOUT_APACHE buildconf httpd.dsp libhttpd.mak README.cmake acinclude.m4 CHANGES httpd.mak LICENSE README.platforms Apache-apr2.dsw CMakeLists.txt httpd.spec Makefile.in ROADMAP Apache.dsw config.layout include Makefile.win server apache_probes.d configure INSTALL modules srclib ap.d configure.in InstallBin.dsp NOTICE support build docs LAYOUT NWGNUmakefile test BuildAll.dsp emacs-style libhttpd.dep os VERSIONING BuildBin.dsp httpd.dep libhttpd.dsp README [root@localhost httpd-2.4.29]# ./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi //安装必要组件 [root@localhost httpd-2.4.29]# make [root@localhost httpd-2.4.29]# make install [root@localhost httpd-2.4.29]# cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd cp:是否覆盖"/etc/init.d/httpd"? yes [root@localhost httpd-2.4.29]# vim /etc/init.d/httpd #!/bin/sh # chkconfig: 35 85 21 # description: Apache is a World Wide Web server //在#!/bin/sh下行插入这两行内容,按Esc退出插入模式,按:wq保存退出 [root@localhost httpd-2.4.29]# chkconfig --add httpd [root@localhost httpd-2.4.29]# vim /usr/local/httpd/conf/httpd.conf 输入/Server,找到:ServerName www.example.com:80 把前面的#号注释删除 输入/Listen,查找80端口监听,并开启监听本机的80端口:Listen 192.168.56.128: 80 按Esc退出插入模式,按:wq保存退出 [root@localhost httpd-2.4.29]# ln -s /usr/local/httpd/conf/httpd.conf /etc/ [root@localhost httpd-2.4.29]# ln -s /usr/local/httpd/bin/* /usr/local/bin/ //以上操作为创建软链接 [root@localhost httpd-2.4.29]# systemctl stop firewalld.service [root@localhost httpd-2.4.29]# setenforce 0 //关闭防火墙及增强型安全功能 [root@localhost httpd-2.4.29]# httpd -t Syntax OK [root@localhost httpd-2.4.29]# service httpd start [root@localhost httpd-2.4.29]# netstat -ntuap | grep httpd tcp 0 0 192.168.56.128:80 0.0.0.0:* LISTEN 22697/httpd 第四步:安装MySQL [root@localhost httpd-2.4.29]# cd ~ [root@localhost ~]# yum install -y ncurses-devel autoconf cmake //安装必须组件 [root@localhost ~]# tar zxvf mysql-5.6.26.tar.gz -C /opt/ [root@localhost ~]# cd /opt/mysql-5.6.26/ [root@localhost mysql-5.6.26]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DSYSCONFDIR=/etc/ -DMYSQL_DATADIR=/home/mysql/ -DMYSQL_UNIX_ADDR=/home/mysql/mysql.sock //安装必须组件 [root@localhost mysql-5.6.26]# make [root@localhost mysql-5.6.26]# make install [root@localhost mysql-5.6.26]# cp support-files/my-default.cnf /etc/my.cnf cp:是否覆盖"/etc/my.cnf"? yes [root@localhost mysql-5.6.26]# cp support-files/mysql.server /etc/init.d/mysqld cp:是否覆盖"/etc/init.d/mysqld"? yes [root@localhost mysql-5.6.26]# cd /etc/init.d [root@localhost init.d]# ls functions httpd mysqld netconsole network README [root@localhost init.d]# chmod 755 mysqld [root@localhost init.d]# ls -ln 总用量 56 -rw-r--r--. 1 0 0 17500 5月 3 2017 functions -rwxr-xr-x. 1 0 0 3502 10月 18 22:45 httpd -rwxr-xr-x. 1 0 0 10870 10月 18 23:20 mysqld -rwxr-xr-x. 1 0 0 4334 5月 3 2017 netconsole -rwxr-xr-x. 1 0 0 7293 5月 3 2017 network -rw-r--r--. 1 0 0 1160 8月 5 2017 README [root@localhost init.d]# chkconfig --add /etc/init.d/mysqld [root@localhost init.d]# chkconfig --level 235 mysqld on [root@localhost init.d]# echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile [root@localhost init.d]# source /etc/profile [root@localhost init.d]# echo $PATH /usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/root/bin:/usr/local/mysql/bin:/root/bin:/usr/local/mysql/bin [root@localhost init.d]# useradd -s /sbin/nologin mysql //创建用户“mysql” [root@localhost init.d]# chown -R mysql:mysql /usr/local/mysql/ [root@localhost init.d]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --ldata=/var/lib/mysql --basedir=/usr/local/mysql --datadir=/home/mysql //安装必要组件 [root@localhost init.d]# vim /etc/init.d/mysqld [root@localhost init.d]# service mysqld start Starting MySQL SUCCESS! [root@localhost init.d]# netstat -ntuap | grep mysqld tcp6 0 0 :::3306 :::* LISTEN 1310/mysqld [root@localhost init.d]# mysqladmin -u root -p password "abc123" //给root账号设置新密码 第五步:安装PHP [root@localhost init.d]# cd ~ [root@localhost ~]# yum install -y gd libpng libpng-devel pcre pcre-devel libxml2-devel libjpeg-devel [root@localhost ~]# tar jxvf php-5.6.11.tar.bz2 -C /opt/ [root@localhost ~]# cd /opt/php-5.6.11/ [root@localhost php-5.6.11]# ./configure --prefix=/usr/local/php5 --with-gd --with-zlib --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php5 --enable-mbstring [root@localhost php-5.6.11]# make [root@localhost php-5.6.11]# make install [root@localhost php-5.6.11]# cp php.ini-development /usr/local/php5/php.ini cp:是否覆盖"/usr/local/php5/php.ini"? yes [root@localhost php-5.6.11]# ln -s /usr/local/php5/bin/* /usr/local/bin/ [root@localhost php-5.6.11]# vim /etc/httpd.conf AddType application/x-compress .Z AddType application/x-gzip .gz .tgz AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps //在上两行下面插入下面两行内容 DirectoryIndex index.php index.html //在DirectoryIndex和index.html中间添加index.php //按Esc退出插入模式,按:wq保存退出 [root@localhost php-5.6.11]# vim /usr/local/httpd/htdocs/index.php <?php phpinfo(); ?> //写入以上内容,按Esc退出插入模式,按:wq保存退出 [root@localhost php-5.6.11]# service httpd restart 进入网页进行测试(此处IP地址填写的是安装服务的CentOS 7的IP地址):http://192.168.56.128/index.php,如果配置成功因该出现如下界面:
LAMP架构 —(介绍及实战)
第六步:安装论坛组件并使用论坛 [root@localhost php-5.6.11]# cd ~ [root@localhost ~]# unzip Discuz_X2.5_SC_UTF8.zip -d /opt/Discuz [root@localhost ~]#cp -r /opt/Discuz/upload/ /usr/local/httpd/htdocs/bbs [root@localhost ~]#cd /usr/local/httpd/htdocs/bbs/ [root@localhost bbs]# chown -R daemon ./config/ [root@localhost bbs]# chown -R daemon ./data/ [root@localhost bbs]# chown -R daemon ./uc_client/data/cache/ [root@localhost bbs]# chown -R daemon ./uc_server/data/ [root@localhost bbs]# mysql -uroot -pabc123 Warning: Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or /g. Your MySQL connection id is 1 Server version: 5.6.26 Source distribution
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.