本文共 3551 字,大约阅读时间需要 11 分钟。
这里介绍的LAMP架构是由Linux、Apache、MySQL、PHP组成的。
yum -y install \gcc \gcc-c++ \make \pcre-devel \expat-devel \perl
tar zvxf apr-1.6.2.tar.gz -C /opttar zvxf apr-util-1.6.0.tar.gz -C /opttar zvxf httpd-2.4.29.tar.gz -C /optcd /optmv apr-1.6.2 httpd-2.4.29/srclib/aprmv apr-util-1.6.0 httpd-2.4.29/srclib/apr-util
cd /opt/httpd-2.4.29cd httpd-2.4.29./configure \--prefix=/usr/local/httpd \--enable-so \--enable-rewrite \--enable-charset-lite \--enable-cgimake && make install
vi /usr/local/httpd/conf/httpd.conf //修改如下内容ServerName www.yun.com:80Listen 192.168.100.131:80
创建配置文件的链接到etc目录下
ln -s /usr/local/httpd/conf/httpd.conf /etc/
创建httpd服务脚本
cp /usr/local/httpd/bin/apachectl /etc/init.d/httpdvi /etc/init.d/httpd # chkconfig: 35 85 21 //35级别自动运行 第85个启动 第21个关闭 # description: Apache is a World Wide Web serverchkconfig --add httpd //将httpd加入到SERVICE管理器
方便系统识别httpd命令,创建链接。
ln -s /usr/local/httpd/bin/* /usr/local/bin/
httpd -t apachectl -t
service httpd startnetstat -anpt | grep 80 //查看80端口开启
yum install -y ncurses-devel autoconf cmake
tar xzvf mysql-5.6.26.tar.gzcd mysql-5.6.26cmake \-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \-DDEFAULT_CHARSET=utf8 \-DDEFAULT_COLLATION=utf8_general_ci \-DEXTRA_CHARSETS=all \-DSYSCONFIDIR=/etc \-DMYSQL_DATADIR=/home/mysql/ \-DMYSQL_UNIX_ADDR=/home/mysql/mysql.sockmake && make install
useradd -s /sbin/nologin mysqlchown -R mysql:mysql /usr/local/mysql/ //设置属性
echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profilesource /etc/profileecho $PATH
cd mysql-5.6.26cp support-files/my-default.cnf /etc/my.cnfcp support-files/mysql.server /etc/init.d/mysqld
创建sock文件的链接
ln -s /var/lib/mysql/mysql.sock /home/mysql/mysql.sock
编辑启动脚本并加入系统服务
vi /etc/init.d/mysqldbasedir=/usr/local/mysql //数据库安装路径 datadir=/home/mysql //数据库数据存放路径
chmod 755 /etc/init.d/mysqld chkconfig --add /etc/init.d/mysqldchkconfig mysqld --level 35 on
/usr/local/mysql/scripts/mysql_install_db \--user=mysql \--ldata=/var/lib/mysql \--basedir=/usr/local/mysql \--datadir=/home/mysql
service mysqld startnetstat -anpt | grep 3306
mysqladmin -u root -p password "abc123" //给root账号设置密码
yum -y install \gd \libpng \libpng-devel \pcre \pcre-devel \libxml2-devel \libjpeg-devel
tar xjvf php-5.6.11.tar.bz2cd 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 make && make install
cp php.ini-development /usr/local/php5/php.iniln -s /usr/local/php5/bin/* /usr/local/bin/ln -s /usr/local/php5/sbin/* /usr/local/sbin/
vi /etc/httpd.conf AddType application/x-httpd-php .phpAddType application/x-httpd-php-source .phpsDirectoryIndex index.php index.html
service httpd restart
vi /usr/local/httpd/htdocs/index.php
在网页测试“”
mysql -u root -pCREATE DATABASE sky;GRANT all ON sky.* TO 'skyuser'@'%' IDENTIFIED BY 'admin123';flush privileges
vi /usr/local/httpd/htdocs/index.php Success!!";else echo "Fail!!";mysql_close();?>
在网页测试“”
转载于:https://blog.51cto.com/11134648/2150371