配置LAMP (php-fpm模式)部署步骤
1.安装mariadb
yum install maridb-server -y
1).配置server.cnf
cp /etc/my.cnf.d/server.cnf{,.back} vim /etc/my.cnf.d/server.cnf ##mariadb服务器端配置文件 [mysqld] ##以下项是优化项目可根据需要选择## innodb_file_per_table=ON ##使用独立表空间模式(建议使用 skip_name_resolve=ON ##禁止域名反向解析(可选)
2).安装完成后安全配置
systemctl start mariadb.service ##启动mariadb服务 systemctl enable mariadb.service ##设置为开机启动## mysql_secure_installation ##安装完成后安全初始化,添加root密码,删除匿名登录账户,禁止远程使用root用户登录,删除测试数据库和使用##
2.安装php模块及php-fpm
yum -y install php-fpm php-mysql php-gd php-mbstring php-mcrypt
3.配置或者优化php-fpm
cp /etc/php-fpm.d/www.conf{,.back} vim /etc/php-fpm.d/www.conf pm.max_spare_servers = 15 pm.status_path = /pmstatus ping.path = /ping ping.response = pong #默认/var/lib/php/session目录不存在,所以我们要创建此目录 mkdir -pv /var/lib/php/session chown apache:apache /var/lib/php/session
4.启动php-fpm
systemctl start php-fpm.service ss -tnl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *:22 *:* LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 128 127.0.0.1:9000 *:* LISTEN 0 50 *:3306 *:* LISTEN 0 128 :::22 :::* LISTEN 0 100 ::1:25 :::*
5.安装httpd
yum install httpd -y httpd -M # 确保有 proxy_fcgi_module (shared) 模块 # 否则无法与后端程序进行通信
6.创建应用目录和授权目录
mkdir -p /application/www chown -R apache:apache /application/www #在www目录里面创建test目录,并创建一个index.php测试页 cd /application/www mkdir test && cd test vim index.php <?php phpinfo(); ?>
7.配置代理和httpd虚拟主机,并支持PHP
vim /etc/httpd/conf.d/test.conf <VirtualHost *:80> ServerName www.test.com DocumentRoot /application/www/test ProxyRequests Off #关闭正向代理 DirectoryIndex index.php #反代 ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/application/www/test/$1 ProxyPassMatch ^(/pmstatus.*)$ fcgi://127.0.0.1:9000/$1 <Directory "/application/www/test"> #Options None #使用符号链接 Options FollowSymLinks AllowOverride None Require all granted </Directory> </VirtualHost>
8.添加hosts解析
vim /etc/hosts #add 192.168.42.135 www.test.com
9.浏览器访问www.test.com [ ok ]
10.安装phpmyadmin
cd /application/www/ wget -c http://192.168.42.26/install_package/down/phpMyAdmin-4.0.10.20-all-languages.tar.gz tar xvf phpMyAdmin-4.0.10.20-all-languages.tar.gz ln -s phpMyAdmin-4.0.10.20-all-languages phpmyadmin cd phpmyadmin cp config.sample.inc.php config.inc.php vim config.inc.php #更改一下配置项,在随机码后面随便添加随机码 $cfg['blowfish_secret'] = 'a8b7c6dfs433'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
11.给phpmyadmin添加虚拟主机和hosts解析
echo "192.168.42.135 www.phpmyadmin.com" >>/etc/hosts vim /etc/httpd/conf.d/phpmyadmin.conf <VirtualHost *:80> ServerName www.phpmyadmin.com DocumentRoot /application/www/phpmyadmin ProxyRequests Off #关闭正向代理 DirectoryIndex index.php #反代 ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/application/www/phpmyadmin/$1 <Directory "/application/www/phpmyadmin"> #Options None #使用符号链接 Options FollowSymLinks AllowOverride None Require all granted </Directory> </VirtualHost>
12.重启apache,在浏览器访问www.phpmyadmin.com 就能访问以web界面的方式操作数据库了
原创文章,作者:srayban,如若转载,请注明出处:http://www.178linux.com/77388