Hướng dẫn php symlink not working
I am in a Linux environment. We have a CMS with 8 languages, and images are physical files in English: Show
But it is not working, it throws that it does not find the file. Must it be absolute path? asked Apr 29, 2016 at 8:54
The best way to create symlinks is with absolute paths. However you can use relative path, but the symlink path should be relative to the original file. Also chech the webserver if symlinks are on. answered Apr 29, 2016 at 9:14
1 Not the answer you're looking for? Browse other questions tagged php linux internationalization symlink or ask your own question.Laravel là một PHP Framework mã nguồn mở miễn phí, được phát triển bởi Taylor Otwell với phiên bản đầu tiên được ra mắt vào tháng 6 năm 2011. Laravel ra đời nhằm mục đích hỗ trợ phát triển các ứng dụng web, dựa trên mô hình MVC (Model – View – Controller). Laravel hiện được phát hành theo giấy phép MIT, với source code được lưu trữ tại Gitthub. Trong quá trình sử dụng bạn gặp lỗi symlink(): No such file or directory thì bài viết này Hostvn sẽ hướng dẫn các bạn cách xử lý. Xử lý lỗi symlink(): No such file or directory LaravelBước 1: Vào thư mục /publicSau khi vào thư mục /public các bạn chạy dòng lệnh sau:
Bước 2: Vào thư mục root của laravelSau khi vào thư mục root, các bạn chạy lệnh bên dưới để tạo lại symlink cho storage
Chúc các bạn thành công Part 1: macOS 11.0 Big Sur Web Development Environment Developing web applications on macOS is a real joy. There are plenty of options for setting up your development environments, including the ever-popular MAMP Pro that provides a nice UI on top of Apache, PHP and MySQL. However, there are times when MAMP Pro has slow downs, or out of date versions, or is simply behaving badly due to its restrictive system of configuration templates and non-standard builds. It is times like these that people often look for an alternative approach, and luckily there is one, and it is relatively straight-forward to setup. In this blog post, we will walk you through setting up and configuring Apache 2.4 and multiple PHP versions. In the second blog post in this two-post series, we will cover MySQL, Apache virtual hosts, APC caching, and Xdebug installation. 10/31/2021 Added dynamic support for Apple Silicon and Intel homebrew paths If you have followed this guide in the past with the This guide is intended for experienced web developers. If you are a beginner developer, you will be better served using MAMP or MAMP Pro. XCode Command Line ToolsIf you don't already have XCode installed, it's best to first install the command line tools as these will be used by homebrew:
Homebrew InstallationThis process relies heavily on the macOS package manager called Homebrew. Using the
Just follow the terminal prompts and enter your password where required. This may take a few minutes. If
this is a fresh install and you don't have your path setup properly, you can follow the installation "next steps" which are already customized for you, or you can manually add the following paths to your
Now you can test your installation to ensure you have installed
You should probably also run the following command to ensure everything is configured correctly:
It will instruct you if you need to correct anything. Monterey Required LibrariesWhen installing fresh on Monterey, I ran into a few libraries that were missing when completing all the steps below. To make things easier, please simply run this now:
Apache InstallationThe latest macOS 12.0 Monterey comes with Apache 2.4 pre-installed, however, it is no longer a simple task to use this version with Homebrew because Apple has removed some required scripts in this release. However, the solution is to install Apache 2.4 via Homebrew and then configure it to run on the standard ports (80/443). If you already have the built-in Apache running, it will need to be shutdown first, and any auto-loading scripts removed. It really doesn't hurt to just run all these commands in order - even if it's a fresh installation:
Now we need to install the new version provided by Brew:
Without options,
Now we just need to configure things so that our new Apache server is auto-started
You now have installed Homebrew's Apache, and configured it to auto-start with a privileged account. It should already be running, so you can try to reach your server in a browser by pointing it at Troubleshooting TipsIf you get a message that the browser can't connect to the server, first check to ensure the server is up.
You should see a few httpd processes if Apache is up and running. Try to restart Apache with:
You can watch the Apache error log in a new Terminal tab/window during a restart to see if anything is invalid or causing a problem:
Apache is controlled via the
Visual Studio CodeIn past guides, I've always provided instructions to edit files using the default We can make use of the HomeBrew and install VSCode and the accompanying
If you already have Visual Studio Code installed, you can easily create a
Apache ConfigurationNow that we have a working web server, we will want to do is make some configuration changes so it works better as a local development server. In the latest version of Brew, you have to manually set the listen port from the default of If you followed the instructions above you should be able to use Visual Studio Code to edit your files using the
Find the line that says
and change it to
Next we'll configure it to use the to change the document root for Apache. This is the folder
where Apache looks to serve file from. By default, the document root is configured as Search for the term
Change this to point to your user directory where
You also need to change the
In that same
Also we should now enable mod_rewrite which is commented out by default. Search for
User & GroupNow we have the Apache configuration pointing to a
ServernameApache likes to have a server name in the configuration, but this is disabled by default, so search for:
and replace it with:
Sites FolderNow, you need to create a
Restart apache to ensure your configuration changes have taken effect:
If you receive an error upon restarting Apache, try removing the quotes around the DocumentRoot and Directory designations we set up earlier. Pointing your browser to Makes sure you remove the Troubleshooting Non-Sudo httpd Services StartI will be updating this section with more tips and things to try as I find solutions to common problems. Please hop on our #macos Discord Chat to get some "live" help. This year, with macOS Big Sur, I've switched from
using I ran into some problems myself but was able to get it working pretty easily, but others have reported more wide-spread problems. Please try these steps if your Apache is not starting when you use First, try to start apache directly with:
This bypasses the brew services command and often prints out specific issues. If you have issues reported about not being able to write to log files, try removing all the current log httpd log files:
Then try starting again. If you have see a message saying something like
PHP InstallationIf you have existing PHP installations via Brew, you need to first cleanup your setup with our Upgrading Homebrew guide before continuing with this section. Up until the end of March 2018, all PHP related brews were handled by PHP 7.0, and PHP 7.1 have been deprecated and
removed from Brew because they are out of support, and while it's not recommended for production, there are legitimate reasons to test these unsupported versions in a development environment. These versions also need to "built from source" in order to use the latest versions of Remember only PHP 7.2 through 8.1 are officially supported by Brew, but these also have to be built which is pretty slow. For the latest version of our guide we will use the new tap from @shivammahtur as there are many versions (including the latest PHP 8.1) pre-built.
We will proceed by installing various versions of PHP and using a simple script to switch between them as we need. Feel free to exclude any versions you don't want to install.
Also, you may have the need to tweak
configuration settings of PHP to your needs. A common thing to change is the memory settings or the
At this point, I strongly recommend closing ALL your terminal tabs and windows. This will mean opening a new terminal to continue with the next step. This is strongly recommended because some really strange path issues can arise with existing terminals (trust me, I have seen it!). We have installed but not linked these PHP versions. To switch to PHP
Quick test that we're in the correct version:
and to switch to to
And check that it's changed correctly:
Apache PHP Setup - Part 1You have successfully installed your PHP versions, but we need to tell Apache to use them. You will again need to edit the If you have been following this guide correctly, the last entry should be your
Below this add the following
We can only have one module processing PHP at a time, so for now, so we have left our Also you must set the Directory Indexes for PHP explicitly, so search for this block:
and replace it with this:
Save the file and stop Apache then start again, now that we have installed PHP:
Validating PHP InstallationThe best way to test if PHP is installed and running as expected is to make use of phpinfo(). This is not something you want to leave on a production machine, but it's invaluable in a development environment. Simply create a file called
Point your browser to If you see a
similar phpinfo result, congratulations! You now have Apache and PHP running successfully. You can test the other PHP versions by commenting the PHP Switcher ScriptWe hard-coded Apache to use PHP 7.4, but we really want to be able to switch between versions. Luckily, some industrious individuals have already done the hard work for us and written a very handy little PHP switcher script. This We will install the
Testing the PHP SwitchingAfter you have completed these steps, you should be able to
switch your PHP version by using the command
You will probably have to enter your administrator password, and it should give you some feedback:
Test to see if your Apache is now running PHP 7.4 by again pointing your browser to Troubleshooting PHP SwitchingIf you have upgraded from a previous version of this guide and have installed PHP8, you may see message like: If you get a message about conflicting PHP versions, then you probably have a conflict of taps. You will need to uninstall your previous PHP versions, then remove the old tap, then add the new tap, and then reinstall PHP versions using the syntax above. For example:
Test Your Setup with Grav CMS!What better way to test your new powerful setup than to quickly install and test Grav. The best flat-file CMS in the world 😆! We can do this with just a couple of quick terminal commands:
Then just extract the zip file:
This will
extract the zip into a Fill in the relevant information to create a new administator user, and simply click Create User to get into the admin. No other steps needed. All done!!!! Updating PHP and other Brew PackagesBrew makes it super easy to update PHP and the other packages you install. The first step is to update Brew so that it gets a list of available updates:
This will spit out a list of available updates, and any deleted formulas. To upgrade the packages simply type:
You will need to switch to each of your installed PHP versions and run update again to get updates for each PHP version and ensure you are running the version of PHP you intend. Activating Specific/Latest PHP VersionsDue to the way our PHP linking is set up, only one version of PHP is linked at a time, only the current active version of PHP will be updated to the latest version. You can see the current active version by typing:
And you can see the specific versions of a PHP package by typing:
OK, that wraps up Part 1 of this 3 part series You now have a fully functional Apache 2.4 installation with a quick-and-easy way to toggle between PHP 7.0, 7.1, 7.2, 7.3, 7.4, and 8.0. Check out Part 2 to find out how to setup your environment with MySQL, Virtual Hosts, APC caching, YAML, and Xdebug. Also take a gander at Part 3 to find out how to setup SSL for your Apache Virtual Hosts. |