如果安装NGINX 那么修改如下
如果没有nginx.repo就新建一个
cd /etc/yum.repos touch nginx.repo vi /etc/yum.repos.d/nginx.repo
修改为:
[nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=0 enabled=1
接下来安装apache nginx php mysql
yum install nginx #yum install httpd httpd-devel yum install mariadb* yum install php php-devel php-gd php-xml php-mbstring php-session php-pecl-memcache php-fpm php-pdo php-pear php-mysql
[root@localhost~]# mysql_secure_installation /usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we’ll need the current password for the root user. If you’ve just installed MariaDB, and you haven’t set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): OK, successfully used password, moving on… Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. Set root password? [Y/n] <�C 回车 New password: <�C 输入ROOT密码 Re-enter new password: <�C 再输入一次ROOT密码 Password updated successfully! Reloading privilege tables.. … Success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] <�C 回车 … Success! Normally, root should only be allowed to connect from ‘localhost’. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] <�C 回车 … Success! By default, MariaDB comes with a database named ‘test’ that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] <�C 回车 �C Dropping test database… … Success! �C Removing privileges on test database… … Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] <�C 回车 … Success! Cleaning up… All done! If you’ve completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB! [root@localhost ~]#
开启服务并永久通过防火墙 CentOS的防火墙改变了 是用firewall
systemctl stop httpd.service systemctl disable httpd.service systemctl enable nginx.service systemctl start nginx.service systemctl enable php-fpm.service systemctl start php-fpm.service firewall-cmd �Cpermanent �Czone=public �Cadd-service=http firewall-cmd �Cpermanent �Czone=public �Cadd-service=https firewall-cmd �Creload
APC是一个自由和开放的PHP操作码来缓存和优化PHP的中间代码。它类似于其他PHP操作码cachers,如eAccelerator和XCache。强烈建议有这些安装,以加快您的PHP页面。
从PHP PECL库中安装的APC。 PECL要求CentOS开发工具beinstalled编译APC包。
确认安装了开发包 如果没有安装
yum groupinstall ‘Development Tools’
命令 pecl install apc
[root@localhost ~]# pecl install apc downloading APC-3.1.13.tgz … Starting to download APC-3.1.13.tgz (171,591 bytes) ……………..done: 171,591 bytes 55 source files, building running: phpize Configuring for: PHP Api Version: 20100412 Zend Module Api No: 20100525 Zend Extension Api No: 220100525 Enable internal debugging in APC [no] : <�C 回车 Enable per request file info about files used from the APC cache [no] : <�C 回车 Enable spin locks (EXPERIMENTAL) [no] : <�C 回车 Enable memory protection (EXPERIMENTAL) [no] : <�C 回车 Enable pthread mutexes (default) [no] : <�C回车 Enable pthread read/write locks (EXPERIMENTAL) [yes] : <�C 回车 building in /var/tmp/pear-build-rootVrjsuq/APC-3.1.13
然后打开 /etc/php.ini 并设置 cgi.fix_pathinfo=0:
vi /etc/php.ini
然后再在PHP.INI添加如下:
[APC] extension=apc.so
然后编辑/etc/nginx/conf.d/default.conf
把厦门的注释去掉 并改为如下:
location ~ .php$ { root /usr/share/nginx/html; try_files $uri =404; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
默认情况下监听端口 9000 。 另外,也可以使PHP-FPM使用Unix套接字,这避免了TCP的开销。要做到这一点,打开 /etc/php-fpm.d/www.conf
vi /etc/php-fpm.d/www.conf
… 修改后如下:
[...] ;listen = 127.0.0.1:9000 listen = /var/run/php-fpm/php5-fpm.sock [...]
然后重新加载 PHP-FPM:
systemctl restart php-fpm.service
接下来通过你的nginx的配置和所有的虚拟主机和改线 fastcgi_pass 127.0.0.1:9000; to fastcgi_pass unix:/tmp/php5-fpm.sock;,像这样:
vi /etc/nginx/conf.d/default.conf location ~ .php$ { root /usr/share/nginx/html; try_files $uri =404; fastcgi_pass unix:/var/run/php-fpm/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
最后重新加载 nginx:
systemctl restart nginx.service