Centos搭建原生的LAMP

使用以下命令安装php,测试php,Centos默认集成了Apache
yum -y install php
vi /var/www/html/index.php
/etc/init.d/httpd restart

使用以下命令安装mysql,测试mysql用phpmyadmin (unzip *.zip)
yum install mysql mysql-server
chkconfig –levels 235 mysqld on
/etc/init.d/mysqld start
/etc/init.d/mysqld restart

安装完后mysql数据库目录为 /var/lib/mysql
或者用 ps -ef | grep mysql 查看数据库存放目录
设置root密码:
mysql_secure_installation

关联php和mysql
yum search php
yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml

php-xmlrpc
/etc/init.d/httpd restart
/etc/init.d/httpd restart

apache域名绑定文件
/etc/httpd/conf/httpd.conf

##########################

如果在Ubuntu环境下测试环境可以安装phpstudy

1.wget -c http://lamp.phpstudy.net/phpstudy.bin
2.chmod +x phpstudy.bin
3.sudo ./phpstudy.bin

centos7注意事项:
systemctl start httpd.service #开始httpd
systemctl stop firewalld.service #停止
systemctl disable firewalld.service #禁用
systemctl restart httpd.service #重启httpd

yum install mariadb mariadb-server #安装mysql分支
systemctl start mariadb #启动mariadb
systemctl enable mariadb #开机自启动
mysql_secure_installation #安全配置向导
mysql -uroot -p #测试登录

#相关组件
yum -y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel

#开启伪静态
# vim /etc/httpd/conf/httpd.conf

###增加下面内容

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

发表评论

电子邮件地址不会被公开。 必填项已用*标注