一、在VMware 新建一个虚拟机CentOS 64位,配置好磁盘大小为30G,启动虚拟机进入CentOS安装界面
选择Install CentOS 7 php
二、设置系统语言为English,时区选择Asia/ShangHai
三、SECURITY POLICY选择默认的Default
四、SOFTWARE SELECTION选择GNOME Desktop,安装图形用户界面
五、设置network和hostname,并开启网络链接(若是不开启网络,则会出现Xshell一直链接不上CentOS的问题)
六、设置ROOT PASSWORD
七、建立一个新用户:xiao,并设置密码
八、等待安装完毕,重启CentOS,会出现: centos7 license not accepted的问题
先输入1, read the license information
而后输入2, accept the agreements
再输入q,quit the conversition。最后输入yes,重启便可
九、建立系统快照 css
nginx不是一个CentOS基础库的一部分。所以安装EPEL库来得到nginx:
一、yum install epel-release
二、yum install nginx
三、建立的系统启动nginx的连接和启动它:
systemctl enable nginx.service
systemctl start nginx.service
四、查看是否可用 netstat –tap | grep nginx
安装成功 html
CentOS7以上的版本采用mariadb替代了MySQL,所以安装mariadb。
一、安装mariadb服务 yum install mariadb mariadb-server mariadb-devel
二、建立的系统启动mariadb的连接和启动它:
systemctl enable mariadb.service
systemctl start mariadb.service
三、如今检查网络启用。运行netstat -tap | grep mysql
四、设置mariadb的访问权限,防止任何人都能访问。
mysql_secure_installation
设置新的密码 mysql
一、安装 PHP5相关模块
yum install php-fpm php-cli php-mysql php-gd php-ldap php-odbc php-pdo php-pecl-memcache php-pear php-mbstring php-xml php-xmlrpc php-mbstring php-snmp php-soap
二、安装APC
APC是一个自由和开放的PHP操做码来缓存和优化PHP的中间代码。
从PHP PECL库中安装的APC。 PECL要求CentOS开发工具beinstalled编译APC包。
yum install php-devel
yum groupinstall ‘Development Tools’//安装开发工具包
安装 APC: pecl install apc
3配置php.ini
开启apc扩展extension=apc.so
设置 时区date.timezone =”Asia/ShangHai” linux
四、建立系统启动连接的PHP-FPM并启动它:
systemctl enable php-fpm.service
systemctl start php-fpm.service nginx
遇到的问题:unable to bind listening socket for address ‘127.0.0.1:9000‘: Address already in use (98)
解决方法:先杀死该进程,而后重启
netstat -lntup | grep 9000
killall php-fpm
systemctl start php-fpm.service web
一、在浏览器窗口输入localhost,出现如下页面,则nginx安装成功
二、配置nginx.conf,解析php文件
而后 在/usr/share/nginx/html下新建index.php 文件 sql
一、配置nginx.conf
将root目录改成网站的目录
并添加如下配置,使nginx转发php请求给php-fpm解析。shell
location ~ .+\.php($|/){ root /usr/share/nginx/html/website; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/website$fastcgi_script_name; include fastcgi_params; } 设置图片,css,js等资源的缓存配置。 location ~ .*\.(gif|jpg|jpeg|png|bmp|flv|ico|swf)$ { access_log off; expires 24h; } location ~ .*\.(htm|html)$ { access_log off; expires 24h; } location ~ .*\.(js|css)?$ { access_log off; expires 24h; }
二、关闭selinux,以避免在配置ThinkPHP项目时老是遇到权限的问题
临时关闭selinux:setenforce 0
三、部署ThinkPHP项目。
将项目的’URL_MODEL’配置为3,兼容模式,避免须要nginx才能使用pathinfo模式。 centos
四、在浏览器中输入:localhost//index.php
运行成功